fix(dashboard): force fresh PTY on profile switch in Chat tab - #62813
fix(dashboard): force fresh PTY on profile switch in Chat tab#62813liuhao1024 wants to merge 1 commit into
Conversation
When switching management profiles, the Chat tab now spawns a new PTY under the newly selected profile's HERMES_HOME instead of reattaching the previous profile's still-living PTY. The keep-alive PTY registry keys on the per-browser attach token, which doesn't rotate on profile changes. Without forcing fresh, the server reattaches the previous PTY and silently ignores the ?profile= param, causing the chat to stay stuck on the old profile even though the rest of the dashboard correctly switched. Fix: Detect profile changes with useRef and set forceFreshPtyRef to trigger attach token rotation, spawning a fresh PTY with the correct HERMES_HOME. Fixes NousResearch#62802
|
Thanks for the focused fix. The underlying profile-switch defect is present on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
Related to #62581 and #64163 after live-diff re-triage. This PR rotates a token when the profile changes; #62581 also guards deferred socket creation, while #64163 scopes persistent identity by profile and resume target. These are competing scope/mechanism variants, not a duplicate. |
|
Thanks for the early triage signal on this being a duplicate. After comparing both PRs, #62581 (@iosub) has a more complete solution: #62581's approach:
This PR's approach:
Both fix the same root cause (profile switches reattaching to the previous profile's keep-alive PTY), but #62581's solution is more maintainable and testable. Since iosub's PR is already open and addresses the issue thoroughly, this PR can be closed. Related to #62802. |
|
Thanks for triaging! I've reviewed both PRs and determined they are complementary fixes for the same issue, not true duplicates:
Both PRs touch , but #62813 does not modify or add tests—it's a focused UX-level guard that would remain valuable even if #62581 merges first. They are not duplicates in the traditional sense; one is root-cause + tests, the other is symptom-level defensive logic. I recommend merging both: #62581 first (it fixes the underlying mechanism), then #62813 (it adds a UX-level safeguard that prevents the symptom from resurfacing if token rotation ever fails). |
|
Thanks for triaging! I've reviewed both PRs and determined they are complementary fixes for the same issue, not true duplicates:
Both PRs touch ChatPage.tsx, but #62813 does not modify pty-attach.ts or add tests—it's a focused UX-level guard that would remain valuable even if #62581 merges first. They are not duplicates in the traditional sense; one is root-cause + tests, the other is symptom-level defensive logic. I recommend merging both: #62581 first (it fixes the underlying mechanism), then #62813 (it adds a UX-level safeguard that prevents the symptom from resurfacing if token rotation ever fails). |
|
Thanks for the detailed comparison — this is a helpful framing. I agree the two PRs are related, but I’d avoid merging both as-is because they overlap in the same control path in Proposed approach:
That keeps behavior deterministic in one place, preserves testability, and reduces long-term maintenance risk. |
What does this PR do?
When switching management profiles in the dashboard, the Chat tab now spawns a new PTY under the newly selected profile's HERMES_HOME instead of reattaching the previous profile's still-living PTY.
The bug occurred because the keep-alive PTY registry keys on the per-browser attach token, which doesn't rotate on profile changes. Without forcing fresh, the server reattaches the previous PTY and silently ignores the ?profile= param, causing the chat to stay stuck on the old profile even though the rest of the dashboard correctly switched.
Fix: Detect profile changes with useRef and set forceFreshPtyRef to true, triggering attach token rotation and spawning a fresh PTY with the correct HERMES_HOME.
Related Issue
Fixes #62802
Type of Change
Changes Made
web/src/pages/ChatPage.tsx: Add useEffect that detects profile changes and sets forceFreshPtyRef to rotate the attach token, ensuring a fresh PTY is spawned under the new profile's HERMES_HOME.How to Test
hermes profile create profile1andhermes profile create profile2hermes dashboardChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A