Route from / once the persisted store has hydrated - #247
Merged
Merged
Conversation
Opening the simulator flashed the identity picker before landing on the active identity. The redirect effect on `/` read `activeIdentityID` from the React snapshot, which is the pre-hydration state during the first render, so it pushed `/select-id` and then, one render later, `/id/<id>`. Decide once from the live store after `persist` has hydrated, mirroring the seeding fix, and use `replace` so the redirect page stays out of history and Back never bounces through it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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
Opening the simulator briefly showed the Test identities picker before landing on the active identity's home.
Root cause. Same hydration snapshot as #244: while the server-rendered
/page hydrates, React renders with the store's pre-hydration state, in which no identity is active yet. The redirect effect acted on that and pushed/select-id; one render later it saw the real active identity and pushed/id/<id>.Fix. The redirect now decides once, reading the live store after
persist.hasHydrated()(or ononFinishHydration), and usesrouter.replaceso/stays out of the history and Back doesn't bounce through it. Seeding runs first in the same commit phase and inserts synchronously, so a cold start still lands directly on the freshly seeded identity.Verification
pnpm typecheck,pnpm lint,pnpm test(31/31),pnpm run spellcheckclean./→/select-id→/id/0x18310f83/→/id/0x18310f83🤖 Generated with Claude Code