Skip to content

feat(tui-gateway): add websocket transport foundation for dashboard chat - #14814

Closed
DChells wants to merge 1 commit into
NousResearch:mainfrom
DChells:chells/tui-ws-transport-foundation
Closed

feat(tui-gateway): add websocket transport foundation for dashboard chat#14814
DChells wants to merge 1 commit into
NousResearch:mainfrom
DChells:chells/tui-ws-transport-foundation

Conversation

@DChells

@DChells DChells commented Apr 23, 2026

Copy link
Copy Markdown

Summary

Ports the transport layer from #12710 onto current main so tui_gateway can speak the existing JSON-RPC protocol over either stdio or WebSocket.

This PR intentionally stops at the transport boundary. It does not include the /chat dashboard UI.

Why

#12710 showed the right overall architecture, but it bundled two separate review surfaces into one PR:

  • transport / protocol plumbing
  • dashboard chat UI

Per the contribution guidance to keep PRs focused to one logical change, this PR isolates the backend foundation first.

That keeps the review question narrow:

Is a transport-aware tui_gateway plus authenticated /api/ws the right foundation for native dashboard chat?

It also preserves current main behavior around runtime provider resolution and graceful state.db failure handling instead of trying to merge an older branch wholesale.

What changed

  • added tui_gateway/transport.py
    • minimal Transport protocol
    • contextvar-based request transport binding
    • StdioTransport wrapper for current stdio behavior
  • added tui_gateway/ws.py
    • WSTransport implementation
    • WebSocket JSON-RPC receive/send loop
    • gateway.ready emit on connect
    • parse-error handling and disconnect cleanup
  • updated tui_gateway/server.py
    • transport-aware dispatch() / write_json()
    • request transport propagation into pooled handlers
    • session-bound event routing to the owning transport
  • updated hermes_cli/web_server.py
    • authenticated /api/ws endpoint using the existing dashboard token
  • added focused tests in tests/hermes_cli/test_web_server.py
    • auth rejection
    • parse error / unknown method
    • inline vs pooled handler round-trip
    • session event routing
    • disconnect cleanup
    • stdio / WebSocket parity

How to test

python -m pytest tests/hermes_cli/test_web_server.py -k 'TuiGatewayWebSocket or TuiGatewayTransportParity' -q
python -m pytest tests/test_tui_gateway_server.py -q
python -m pytest tests/hermes_cli/test_web_server.py -q

Tested on

  • Ubuntu Linux

Observed locally after rebasing onto current main:

  • 13 passed — focused WebSocket/parity slice
  • 52 passedtests/test_tui_gateway_server.py
  • 123 passed — full tests/hermes_cli/test_web_server.py

Cross-platform impact

This change touches transport/session routing inside the Python gateway and the FastAPI WebSocket endpoint. It does not add shell-specific behavior or platform-specific path logic.

I only tested on Linux, so Windows/macOS verification would still be useful from maintainers or CI.

Related issues / PRs

Notes for reviewers

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/gateway Gateway runner, session dispatch, delivery labels Apr 23, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the thoughtful PR and for splitting the transport foundation from the dashboard UI (@DChells)! This is an automated hermes-sweeper review.

The transport layer this PR proposes is already present on main — it landed two days before this PR was filed:

  • tui_gateway/transport.pyTransport protocol, StdioTransport, TeeTransport, bind_transport/current_transport/reset_transport — all present (commit f49afd312)
  • tui_gateway/ws.pyWSTransport + handle_ws with gateway.ready emit, parse-error handling, disconnect cleanup — all present (commit f49afd312)
  • hermes_cli/web_server.py line 2489@app.websocket('/api/ws') with token-gated auth calling handle_ws — already live
  • tui_gateway/server.py lines 286–407 — transport-aware write_json() and dispatch(req, transport) — already present

The follow-up dashboard UI PR #14815 is the right place to continue — the foundation it depends on is already in place.

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/) P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split from #501: define Phase 1 Web UI gateway MVP contract

3 participants