Skip to content

fix(cli): prevent desktop session transcript bleed from unscoped events - #49659

Closed
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/desktop-session-event-isolation
Closed

fix(cli): prevent desktop session transcript bleed from unscoped events#49659
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/desktop-session-event-isolation

Conversation

@konsisumer

Copy link
Copy Markdown
Contributor

What does this PR do?

Stops the desktop renderer from attributing unscoped turn events to whichever chat is currently focused. Desktop now treats transcript-mutating and prompt-blocking gateway events as malformed unless they include session_id, which prevents live turns from another session/window from bleeding into the visible transcript. The backend already stamps these per-session events explicitly, so tightening the client-side routing matches the current transport contract.

Related Issue

Fixes #49106

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • apps/desktop/src/lib/gateway-events.ts: require session_id for session-scoped desktop gateway events (message.*, reasoning.*, tool.*, prompt requests, status/review events) while keeping truly global events unscoped.
  • apps/desktop/src/lib/gateway-events.test.ts: update regression coverage to assert that unscoped session-scoped events are dropped instead of being attached to the focused chat.

How to Test

  1. Open two Hermes Desktop chat windows/tabs on different active sessions.
  2. Run turns in both sessions and switch between them while they are still live.
  3. Verify a session only updates from events that carry its own session_id; malformed unscoped turn events are ignored instead of appearing in the focused transcript.
  4. Local validation run for this change:
    • "$VIRTUAL_ENV/bin/python" scripts/check-windows-footguns.py --diff HEAD~1
    • git diff --check HEAD~1..HEAD
    • /opt/homebrew/bin/timeout -k 30 480 sh -c '"$VIRTUAL_ENV/bin/pytest" tests/ -q -x --timeout=60 "$@"' sh currently stops early on unrelated pre-existing failure tests/acp/test_approval_isolation.py::TestAcpExecAskGate::test_interactive_env_var_routes_to_callback
    • Workspace JS tests could not be executed in this checkout because node_modules are not installed

What platforms tested on

  • macOS 26.5.1 on darwin-arm64 (local)

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.5.1 (darwin-arm64)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/gateway Gateway runner, session dispatch, delivery labels Jun 20, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related: #47743 (resolve-session-id refactor across desktop hooks), #48281 (pin unscoped stream events to their originating session), #42359 (merged: don't drop the focused chat's own unscoped stream), #49106 (the open issue this fixes).

These are three open competing approaches to the same cross-session transcript-bleed symptom in apps/desktop/src/lib/gateway-events.ts, with different mechanisms: this PR widens gatewayEventRequiresSessionId to require session_id for all session-scoped events and DROP unscoped ones (reversing the #42178 behavior after re-verification), whereas #47743/#48281 RESOLVE/PIN the correct session for unscoped events instead of discarding them. Not a duplicate — maintainers should pick the preferred mechanism.

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

Acknowledged: noted competing PR(s) #47743, #48281, #42359, #49106, #42178, #47743, #48281. My approach differs and is complementary, not mutually exclusive. Open to consolidating if reviewers prefer one direction.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Thanks for the analysis. I verified locally that current main already includes 28f1590b7 (fix(desktop): stop background session messages bleeding into the active transcript), so the desktop symptom this PR targets is already addressed there. This branch instead changes apps/desktop/src/lib/gateway-events.ts to drop unscoped foreground message.*/tool.*/prompt events again, which conflicts with the post-#42359 behavior that kept those events from swallowing the live answer. Given the remaining discussion is about the web /api/events sidebar path rather than the desktop path this PR edits, this PR should be closed.

@konsisumer konsisumer closed this Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web/WeChat sessions leak history: turns from one Hermes session appear in another

3 participants