Skip to content

fix: recover dashboard chat sessions after token rotation - #22010

Draft
mfaiz-007 wants to merge 5 commits into
NousResearch:mainfrom
mfaiz-007:fix/dashboard-session-resume-reliability
Draft

fix: recover dashboard chat sessions after token rotation#22010
mfaiz-007 wants to merge 5 commits into
NousResearch:mainfrom
mfaiz-007:fix/dashboard-session-resume-reliability

Conversation

@mfaiz-007

@mfaiz-007 mfaiz-007 commented May 8, 2026

Copy link
Copy Markdown

Summary

  • Recover dashboard chat sessions after dashboard token/session-token rotation.
  • Store and resume the durable SessionDB id instead of the short in-process TUI gateway sid.
  • Resolve resume targets before PTY spawn, guard stale/invalid sessionStorage, and fall back to the latest valid server-side session.
  • Harden dashboard PTY attach failure cleanup so a dropped socket during replay does not leave the PTY attached to a dead WebSocket.

Tests

  • scripts/run_tests.sh tests/test_tui_gateway_server.py::test_session_info_exposes_persistent_resume_session_id tests/test_tui_gateway_server.py::test_session_most_recent_returns_first_non_denied tests/test_tui_gateway_server.py::test_session_most_recent_returns_null_when_only_tool_rows tests/test_tui_gateway_server.py::test_session_most_recent_folds_db_exception_into_null_result tests/test_tui_gateway_server.py::test_session_most_recent_handles_db_unavailable tests/hermes_cli/test_web_server.py::TestWebServerEndpoints::test_get_most_recent_session_filters_internal_and_empty_rows tests/hermes_cli/test_web_server.py::TestWebServerEndpoints::test_get_sessions_defaults_hide_cron_and_empty_sessions tests/hermes_cli/test_web_server.py::TestPtyWebSocket::test_attach_failure_detaches_dead_websocket tests/hermes_cli/test_web_server.py::TestPtyWebSocket::test_channel_disconnect_keeps_pty_alive_for_reconnect tests/test_hermes_state.py::TestCompressionChainProjection::test_resumable_only_includes_empty_compression_root_with_message_tip tests/test_hermes_state.py::TestCompressionChainProjection::test_resumable_only_does_not_count_empty_orphan_compression_root ✅ 11 passed
  • npm --prefix web run build
  • git diff --check ✅ for the focused branch diff before push

Notes

  • npm --prefix web run lint currently reports unrelated existing repo-wide lint errors outside this focused change set, so it is not used as a pass/fail signal for this PR.

@mfaiz-007
mfaiz-007 force-pushed the fix/dashboard-session-resume-reliability branch from 76351a9 to 7813c5f Compare May 9, 2026 01:35
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels May 9, 2026
@mfaiz-007
mfaiz-007 force-pushed the fix/dashboard-session-resume-reliability branch from 7813c5f to 1f20c19 Compare May 12, 2026 13:14
@mfaiz-007 mfaiz-007 changed the title fix(web): improve dashboard chat resume reliability fix: recover dashboard chat sessions after token rotation May 12, 2026
@mfaiz-007
mfaiz-007 force-pushed the fix/dashboard-session-resume-reliability branch from 1f20c19 to 418453a Compare May 19, 2026 11:26
@alt-glitch alt-glitch added comp/dashboard Web dashboard / control panel UI (dashboard/, landing) sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state and removed comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Jun 27, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pursuing durable dashboard recovery. The underlying issue remains relevant, but this draft predates the current keep-alive PTY registry and needs a focused transplant.

Problems

  • Current main attaches through hermes_cli/web_server.py:15464 and replays buffered bytes after setting the socket in hermes_cli/pty_session.py:88-93. A replay-send exception can leave the dead socket marked attached. The draft's _DashboardPtySession cleanup targets a replaced architecture, and git apply --check shows the patch no longer applies.
  • The draft's latest-session recovery is not profile-scoped. Current descendant lookup carries the management profile in web/src/lib/api.ts:362-367; recovery must preserve that boundary.
  • The added non-secret dashboard HERMES_* tuning variables conflict with the repository configuration policy; use existing behavior or config.yaml-backed settings.

Suggested changes

  • Salvage the replay-failure cleanup and regression test against PtySessionRegistry.
  • Rebuild durable resume around the current profile-scoped APIs and attach-token flow.

Automated hermes-sweeper review.

Comment thread hermes_cli/web_server.py
@@ -3287,6 +3342,12 @@ class PtyUnavailableError(RuntimeError): # type: ignore[no-redef]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add behavioral configuration through a new non-secret HERMES_* variable. Dashboard PTY limits should remain fixed or be exposed through the config.yaml mechanism; this PR's recovery fix should not introduce an env-var configuration surface.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your reply.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/sessions Session lifecycle, resume, persistence, history labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/dashboard Web dashboard / control panel UI (dashboard/, landing) P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants