fix(desktop): sync $activeSessionId atom after session-recovery auto-retry - #62471
fix(desktop): sync $activeSessionId atom after session-recovery auto-retry#62471luxles wants to merge 1 commit into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the atom/ref divergence; the premise remains valid on current main.
Problems
- The submitted diff changes
apps/desktop/src/app/session/hooks/use-prompt-actions.ts, but the live retry branch was extracted by7337248a4c182d65b6c101acac1e21be5101c4ccand now lives atapps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts:298-309. The current branch still only writesactiveSessionIdRef.currentatsubmit.ts:306, so the fix must be transplanted there. - The same ref-only recovery pattern also appears in
submit.ts:226-233andindex.ts:548-557; please keep the atom and ref synchronized across these current recovery paths. index.test.tsx:1050-1095verifies the retry RPC sequence but not$activeSessionId; add a regression assertion for the recovered atom value and a subsequent submit.
Suggested changes
- Import and call
setActiveSessionId(recoveredId)beside the current ref updates, then extend the existing recovery test.
Automated hermes-sweeper review.
| @@ -505,6 +506,7 @@ export function usePromptActions({ | |||
| const recoveredId = resumed?.session_id | |||
There was a problem hiding this comment.
This is the correct state transition, but current main extracted this retry branch to apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts:298-309 (commit 7337248a4c182d65b6c101acac1e21be5101c4cc). Please transplant the atom update there; this file is no longer the live implementation.
…retry (transplanted to refactored files)
a52360e to
5bd5909
Compare
Updated per review feedbackRebased on latest main and transplanted the fix to the refactored file structure: Fixed 2 recovery paths:
Added regression tests:
cc @teknium1 |
|
Superseded by #81261. Thanks for this — the Consolidating because this is one bug class across several PRs: |
Problem
When
prompt.submitreturns "session not found" (stale runtime session ID after Gateway restart, WS orphan reap, or context compression), the frontend auto-recovers by callingsession.resumeto get a fresh runtime ID, then retries the submit.However, the recovery only updates
activeSessionIdRef.current(a ref) without callingsetActiveSessionId()(the React atom).The next
submitPromptcall getssessionIdfromuseStore($activeSessionId)— the atom, which still holds the old stale runtime ID. So every other message fails with "session not found", creating a retry loop.Fix
Add
setActiveSessionId(recoveredId)on the recovery path alongside the ref update.File:
apps/desktop/src/app/session/hooks/use-prompt-actions.tsRelated Issues
Fixes #51058
Related: #38704, #44183, #47709