Skip to content

fix: sync active session across tabs#1359

Closed
dso2ng wants to merge 1 commit intonesquena:masterfrom
dso2ng:fix/session-cross-tab-sync
Closed

fix: sync active session across tabs#1359
dso2ng wants to merge 1 commit intonesquena:masterfrom
dso2ng:fix/session-cross-tab-sync

Conversation

@dso2ng
Copy link
Copy Markdown
Contributor

@dso2ng dso2ng commented Apr 30, 2026

Thinking Path

  • Multiple browser tabs can keep different in-memory active sessions while sharing the same localStorage active-session key.
  • When one tab switches sessions, another idle tab should notice before the next send/load action keeps using stale state.
  • The safe behavior is to follow the changed active-session key only when the current tab is idle.

What Changed

  • Add a storage event listener for the hermes-webui-session key.
  • Idle tabs load the new active session and re-render the sidebar cache.
  • Busy tabs do not auto-switch during an active turn; they show a short toast instead.
  • Add regression tests pinning the listener and busy guard.

Why It Matters

This reduces accidental writes into stale sessions when users switch between browser tabs while using the same Hermes WebUI instance.

Verification

  • pytest tests/test_session_cross_tab_sync.py tests/test_sprint9.py::test_sessions_js_served -q

Risks / Follow-ups

  • This intentionally ignores removal/empty values and does not interrupt active turns.
  • A later UI pass could add a persistent banner for busy-tab conflicts instead of a toast.

Model Used

AI-assisted: OpenAI Codex GPT-5.5 via Hermes Agent tools.

@nesquena-hermes nesquena-hermes mentioned this pull request Apr 30, 2026
6 tasks
nesquena-hermes pushed a commit that referenced this pull request Apr 30, 2026
Adds a 'storage' event listener for the hermes-webui-session localStorage key. Idle tabs auto-load the new active session and re-render the sidebar; busy tabs show a toast and do not interrupt the active turn.

Co-authored-by: Dennis Soong <[email protected]>
nesquena-hermes added a commit that referenced this pull request Apr 30, 2026
Bundles 5 community PRs:
- #1355 feat(clarify): SSE long-connection (mirrors #1350 pattern, includes all correctness lessons)
- #1356 fix: context window indicator overflow (live SSE fallback) + uploading status clear
- #1357 fix: preserve imported session source metadata
- #1358 fix: collapse sidebar session lineage rows
- #1359 fix: sync active session across tabs

Tests: 3444 passing (3411 -> 3444, +33)
@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Shipped in v0.50.249 (merge d72399ae, tag https://github.com/nesquena/hermes-webui/releases/tag/v0.50.249) via batch release PR #1365.

Production verified live at port 8787, ?v=v0.50.249 cache-bust active.

Three guards verified: (1) skip if not the right localStorage key, (2) skip if already on this session, (3) skip and toast if S.busy so active turns aren't interrupted. Cross-tab + new SSE long-connections traced clean: loadSession() calls stopApprovalPolling()+stopClarifyPolling() before opening new SSEs, so each tab maintains exactly one of each per active session.

Thanks @dso2ng! 🙏

@nesquena nesquena mentioned this pull request Apr 30, 2026
6 tasks
GeoffBao pushed a commit to GeoffBao/hermes-webui that referenced this pull request May 1, 2026
Adds a 'storage' event listener for the hermes-webui-session localStorage key. Idle tabs auto-load the new active session and re-render the sidebar; busy tabs show a toast and do not interrupt the active turn.

Co-authored-by: Dennis Soong <[email protected]>
GeoffBao pushed a commit to GeoffBao/hermes-webui that referenced this pull request May 1, 2026
Bundles 5 community PRs:
- nesquena#1355 feat(clarify): SSE long-connection (mirrors nesquena#1350 pattern, includes all correctness lessons)
- nesquena#1356 fix: context window indicator overflow (live SSE fallback) + uploading status clear
- nesquena#1357 fix: preserve imported session source metadata
- nesquena#1358 fix: collapse sidebar session lineage rows
- nesquena#1359 fix: sync active session across tabs

Tests: 3444 passing (3411 -> 3444, +33)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants