Skip to content

fix(tui): avoid creating chat sessions on dashboard mount#17128

Open
nova-celestials-sh wants to merge 4 commits into
NousResearch:mainfrom
nova-celestials-sh:fix/chat-empty-session-lifecycle
Open

fix(tui): avoid creating chat sessions on dashboard mount#17128
nova-celestials-sh wants to merge 4 commits into
NousResearch:mainfrom
nova-celestials-sh:fix/chat-empty-session-lifecycle

Conversation

@nova-celestials-sh

@nova-celestials-sh nova-celestials-sh commented Apr 28, 2026

Copy link
Copy Markdown

Summary

  • stop the embedded TUI from creating a persisted session as soon as the dashboard Chat route mounts
  • lazily create the TUI session on first prompt submit, with an in-flight guard to avoid duplicate first-session creation
  • stop the dashboard Chat sidebar from creating its own sidecar session on mount; it now adopts the PTY session from session.info events

Why

Opening the dashboard Chat page currently creates empty source=tui rows even when the user is only browsing. In the dashboard this makes the session list noisy and makes resuming real conversations harder. Session persistence should happen when a conversation begins, not when the route renders.

How to test

  1. Start the dashboard with embedded chat enabled: hermes dashboard --host 127.0.0.1 --port 9119 --tui --no-open
  2. Open /chat without sending a prompt.
  3. Confirm no new source=tui session row is persisted.
  4. Send a prompt and confirm a TUI session is created normally.

Platforms tested

  • macOS 15.5 / Darwin, local dashboard runtime smoke in Chromium
  • Cross-platform impact considered: this change is limited to TypeScript/React TUI and dashboard session lifecycle code; it does not add OS-specific file, process, shell, or path handling.

Verification

  • npm run type-check --prefix ui-tui
  • npm test --prefix ui-tui -- createGatewayEventHandler
  • npm run build --prefix web
  • Runtime smoke: launched a clean temporary HERMES_HOME dashboard with --tui, loaded /chat in Chromium, and confirmed state.db still had 0 sessions / 0 empty TUI sessions after page load.

Full test suite note

  • Attempted the contributing-guide command via the repo venv: ./venv/bin/pytest tests/ -v
  • Result in this local checkout: 104 failed, 17249 passed, 52 skipped, 210 warnings, 1 error in 174.86s
  • The failures are outside this patch's touched TUI/dashboard files, including existing gateway/Discord/config/tool tests and an import error collecting tests/gateway/test_session.py (normalize_whatsapp_identifier missing from gateway.session).

@nova-celestials-sh nova-celestials-sh force-pushed the fix/chat-empty-session-lifecycle branch from 54d1d82 to 498a4e3 Compare April 28, 2026 19:30
@nova-celestials-sh nova-celestials-sh changed the title Avoid creating chat sessions on dashboard mount fix(tui): avoid creating chat sessions on dashboard mount Apr 28, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Complementary to #18370 (backend lazy creation). This PR handles the frontend/TypeScript side. Both can merge independently.

@nova-celestials-sh

Copy link
Copy Markdown
Author

@alt-glitch conflicts are resolved and the branch is ready for merge.

Verification:

  • scripts/run_tests.sh tests/test_tui_gateway_server.py::test_session_compress_uses_compress_helper tests/test_tui_gateway_server.py::test_session_compress_syncs_session_key_after_rotation tests/test_tui_gateway_server.py::test_session_create_close_race_does_not_orphan_worker
  • python -m py_compile tui_gateway/server.py tests/test_tui_gateway_server.py
  • npx --yes esbuild src/app/useSubmission.ts --bundle --platform=node --format=esm --outfile=/tmp/useSubmission-check.js --external:react --external:nanostores

GitHub now reports the PR as mergeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants