fix(web): force PTY re-spawn on session resume to respect new resume target - #63731
Closed
kyssta-exe wants to merge 1 commit into
Closed
fix(web): force PTY re-spawn on session resume to respect new resume target#63731kyssta-exe wants to merge 1 commit into
kyssta-exe wants to merge 1 commit into
Conversation
…target When the web dashboard resumes a different session, both ?resume=SESSION_ID and ?attach=TOKEN are sent to /api/pty. The keep-alive registry returned the existing PTY (spawned for the previous session) without calling the spawn function, so the new argv/env with the correct HERMES_TUI_RESUME was silently discarded. This made every resume-after-the-first land back on the original session's PTY regardless of which session was clicked. The first click after a dashboard restart worked because no PTY existed yet, so spawn was called. The fix discards any existing keep-alive PTY when a resume target is provided, forcing a fresh spawn with the correct resume arguments. A new close_if_exists method on PtySessionRegistry handles the safe teardown. Fixes NousResearch#63701
Collaborator
Related: this is the backend teardown mechanism in the wrong-session dashboard-chat PTY-reattach cluster (regression from keep-alive PTY #60515). Competing/complementary with #60745 (backend attach-token scoping), #62058 (frontend token rotation), and #61313 (frontend force-fresh) — same goal, different layers/mechanisms. A maintainer should pick the canonical approach across these. |
1 task
|
This PR resolves #63701. I have verified the fix in hermes_cli/web_server.py and hermes_cli/pty_session.py, and required checks have passed. |
Contributor
Author
|
Stale — oldest open PR, no merge activity for weeks. |
This was referenced Jul 31, 2026
Closed
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.
Fixes #63701
Problem
When the web dashboard resumes a different session from Sessions → History, both
?resume=SESSION_IDand?attach=TOKENare sent to/api/pty. The keep-alivePtySessionRegistry.attach_or_spawn()found the existing PTY (spawned for the previous session) and returned it without calling the_spawnclosure. The new argv/env with the correctHERMES_TUI_RESUMEwas silently discarded, so every resume-after-the-first landed back on the original session's PTY.Only the first click after a dashboard restart worked — because no PTY existed yet, so
_spawnwas called.Fix
When a
resumequery parameter is present alongsideattach, discard any existing keep-alive PTY via a newclose_if_existsmethod onPtySessionRegistrybefore callingattach_or_spawn. This forces a fresh spawn with the correct resume arguments.A future enhancement could skip the teardown when the resume target matches the existing PTY's session (by tracking the resolved session id), but the restart is fast (Node.js TUI spawn) and only happens on explicit user navigation, so the simpler unconditional teardown is sufficient.
Changes
PtySessionRegistry.close_if_exists(key)— safely closes and removes a session if present, returnsTrueif one was removed.pty_ws(), callclose_if_exists(attach_token)whenresumeis set, so the registry creates a fresh PTY with the correct resume target.