fix(web): rotate PTY attach token on session switch - #62058
fix(web): rotate PTY attach token on session switch#62058mario841859784 wants to merge 1 commit into
Conversation
Related to the dashboard wrong-session-on-switch cluster (#61284 issue; #61045 earliest-open frontend anchor, #60745 backend anchor, #61107 frontend sibling), all stemming from the merged keep-alive PTY regression #60515. This is not a duplicate — it uses a different mechanism: it rotates/mints a new attach token on every |
When switching sessions via the resume parameter, the localStorage-persisted attach token remained unchanged, causing the server to reattach to the old PTY instead of spawning a new one for the new session. This prevented the previous conversation history from loading. Now listens for resumeParam changes and forces a token rotation via ptyAttachToken(true), triggering a fresh PTY connection that loads the correct session history. Fixes the issue where switching between sessions in the Dashboard Chat page showed an empty terminal instead of the selected session's history.
b5ca55b to
1a7ad69
Compare
|
Thanks for the focused session-switch fix. The current-main premise is confirmed: ChatPage sends a persistent bare attach token ( Problems
Suggested changes
Automated hermes-sweeper review. |
Problem
In the Dashboard Chat page, switching between sessions via the sidebar updates the
resumequery parameter but the terminal shows an empty view instead of the selected session's conversation history.Root Cause
ptyAttachToken()inChatPage.tsxpersists the attach token inlocalStorageso page refreshes can reattach to the same live PTY. However, when the user switches to a different session,resumechanges but the token stays the same. The server sees the identical attach token and reattaches to the old PTY instead of spawning a new one for the new session — so no history is loaded.Fix
Add a
useEffectthat watchesresumeParamchanges. When it changes (and it's not the initial mount), callptyAttachToken(true)to force-rotate the token, then bumpreconnectNonceto trigger a fresh WebSocket connect. The server sees the new token, starts a new PTY bound to the new session, and replays its history.Changes
web/src/pages/ChatPage.tsx: addprevResumeRefand auseEffectthat rotates the attach token onresumeParamchange.Verification
tsc --noEmitpassesnpm run buildsucceeds