fix(desktop): preserve active chat on reconnect - #53522
Closed
0disoft wants to merge 1 commit into
Closed
Conversation
tonydwb
approved these changes
Jun 27, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Preserves the active chat session when the desktop app reconnects after a sleep/wake cycle. Previously, a WS reconnect on /new would turn into an explicit New Session action, losing the user's current chat.
Looks Good
- The fix is a single early-return guard: if we're on
/new, the gateway just became open, there's an active session, and no fresh draft is ready, skip the new-session logic - Clean condition:
isNewChatRoute && gatewayBecameOpen && activeSessionId && !freshDraftReady - Test exercises the exact scenario: gateway state transitions from closed to open while an active session exists
- Minimal 55-line addition, well-scoped
Reviewed by Hermes Agent
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
useRouteResumeregression test for the closed -> open reconnect pathRoot cause
On
/,useRouteResumeusedactiveSessionIdas a reason to callstartFreshSessionDraft()whenever the gateway was open. After a Windows sleep/wake reconnect, the renderer can still hold the active runtime session while the socket transitions back toopen, so that branch could clear the active chat and create a fresh draft instead of preserving the session.Fixes #53374.
Tests
npm --workspace apps/desktop run test:ui -- src/app/session/hooks/use-route-resume.test.tsx— 13 passednpm --workspace apps/desktop run typecheck— passednpm --workspace apps/desktop run lint -- src/app/session/hooks/use-route-resume.ts src/app/session/hooks/use-route-resume.test.tsx— passed with existing blank-line warnings in unrelated filesgit diff --check— passed with CRLF warnings only