Fix signed-in state handling and improve standalone mode UX - #47
Merged
Merged
Conversation
Favorites carried a `placeholderData` of no favorites for the signed-out case, which also made the pending query look settled and empty: a user with favorites got the "No favorites" zero state on every open. The query now resolves its own sign-in dependency, the way useSaveSettings does, so it stays enabled and its own pending state covers both fetches. Same bug in two other spots: useIsSignedIn reported the access-data placeholder as signed out, so the insert menu's preview showed the static thumbnail before swapping to the live one and toasted a signed-in caller to sign in. It now reports undefined until the answer lands. The configuration menu waits on the document's units rather than rendering parameters in the defaults first. Also add a settings button that opens the app outside the Onshape panel, on the current library and theme with none of Onshape's launch params. Trim the README to setup and a high-level description, keeping the local D1/R2 dump import and FORCE_SIGNED_IN with the rest of the setup steps. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qHUwx6dKD8xCnfMwa5JvK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves how the app handles signed-in state and enhances the standalone (non-Onshape) mode experience. The main changes involve distinguishing between "pending" and "signed out" states, moving sign-in checks into queries, and adding a button to open the app outside of Onshape's panel.
Key Changes
Signed-in state handling:
useIsSignedIn()now returnsboolean | undefinedto distinguish between "not yet known" (pending) and "definitely signed out". This prevents UI flashing and incorrect sign-in prompts while access data is loading.Favorites query refactoring: Moved the sign-in check from the component level into
getFavoritesQuery()itself usingensureQueryData(). This ensures the query resolves the access state before attempting to fetch, eliminating the need for theenabledflag and preventing the "pending forever" issue.Thumbnail preview loading state: Added explicit handling for the
isSignedIn === undefinedcase to show a loader while access data is being resolved, preventing premature fallback to stored thumbnails.Standalone mode improvements:
standaloneUrl()helper generates clean URLs without Onshape launch parametersFORCE_SIGNED_INenvironment variable and its testing-only purposeConfiguration loading: Fixed
ConfigurationWrapperto checkunitInfoQuery.isLoadingin addition toquery.isPending, since disabled queries remain pending indefinitely.Insert menu sign-in check: Changed from
!isSignedIntoisSignedIn === falseto only show the sign-in prompt once the state is definitively known, not while pending.Documentation: Reorganized README to better explain the app architecture and consolidated standalone mode documentation with the
FORCE_SIGNED_INvariable explanation.Implementation Details
The core insight is that React Query's placeholder data and
enabledflag can mask the distinction between "loading" and "not signed in". By moving sign-in checks into the query functions themselves and usingensureQueryData()for dependencies, we get clearer state management and better UX when data is still loading.https://claude.ai/code/session_017qHUwx6dKD8xCnfMwa5JvK