fix(desktop): prevent stale session recovery across profile switches - #66889
fix(desktop): prevent stale session recovery across profile switches#66889akivavh wants to merge 1 commit into
Conversation
|
Thanks for the focused Desktop race fix. The premise is verified against current main: The patch makes the fresh-session reset synchronous at the atom mutation boundary and prevents recovery when the submit context has drifted. The added tests cover both the reset ordering and the in-flight 4007 path. No blocking issue identified from the diff. Automated hermes-sweeper review. |
|
Superseded by #81261. Thanks for this — the no-cross-profile-resume constraint is carried over there, with you credited via Consolidating because this is one bug class across several PRs: |
Summary
Fixes a Desktop race that could show
Prompt failed: session not foundwhen switching profiles.Root cause
The fresh-session request was handled through a passive React effect. Profile activation could therefore complete before the old foreground session references were cleared.
If an earlier
prompt.submitsubsequently returned4007 session not found, the recovery path could attemptsession.resumewith the previous profile's durable session ID against the new profile gateway.Behavior after this change
Profile switching tears down the old foreground identity before gateway activation continues. Any prompt or recovery already in flight for the abandoned context is silently cancelled instead of producing an error or crossing profile boundaries.
This does not modify or delete chats, profiles, or configuration data.
Scope
Desktop-only change across five files:
apps/desktop/src/app/contrib/wiring.tsxapps/desktop/src/app/hooks/use-fresh-session-requests.tsapps/desktop/src/app/hooks/use-fresh-session-requests.test.tsxapps/desktop/src/app/session/hooks/use-prompt-actions/submit.tsapps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsxValidation