Skip to content

support dashboard websocket attach on Node 20 - #37030

Closed
PAW122 wants to merge 1 commit into
NousResearch:mainfrom
PAW122:fix/dashboard-tui-websocket-node20
Closed

support dashboard websocket attach on Node 20#37030
PAW122 wants to merge 1 commit into
NousResearch:mainfrom
PAW122:fix/dashboard-tui-websocket-node20

Conversation

@PAW122

@PAW122 PAW122 commented Jun 1, 2026

Copy link
Copy Markdown

Fixes two dashboard-embedded TUI failures:

- prevents a React render-phase update loop by removing the eager ensureAgentsNudgeConfig() call from gateway event handler creation
- fixes gateway exited / gateway websocket unavailable in the dashboard when the PTY child runs under Node 20, where globalThis.WebSocket may be unavailable

The gateway client now resolves a runtime WebSocket constructor by using:

1. globalThis.WebSocket when available
2. require("undici").WebSocket as a fallback for Node 20

This keeps dashboard /chat attach mode working with the Node runtime used by the system service.

Root cause

The dashboard launches the embedded TUI through /usr/bin/node, which on this host is Node v20.19.2. In that runtime:

txt
typeof WebSocket === "undefined"


Manual CLI checks used a newer node from PATH where WebSocket exists globally, so the issue only reproduced inside the dashboard PTY path.

Because attach mode depends on HERMES_TUI_GATEWAY_URL, the TUI exited early with:

txt
gateway websocket unavailable
gateway exited


Changes

- Add resolveRuntimeWebSocket() in ui-tui/src/gatewayClient.ts
- Use the resolved WebSocket constructor for:
  - gateway attach mode
  - sidecar mirror connection
- Add HERMES_TUI_DISABLE_UNDICI_WEBSOCKET=1 test switch so tests can still simulate a runtime with no WebSocket support
- Update gateway client tests for the fallback behavior
- Remove eager nudge config fetch during gateway handler creation to avoid render-phase RPC/state updates

Test plan

Ran:

bash
npm test -- gatewayClient.test.ts


Result:

txt
10 tests passed


Ran:

bash
npm run build


Result:

txt
built ui-tui/dist/entry.js


Verified dashboard /chat locally with the same Node runtime used by the service:

txt
/usr/bin/node --expose-gc /home/pawiu/.hermes/hermes-agent/ui-tui/dist/entry.js


Dashboard verification:

- gateway exited: false
- gateway websocket unavailable: false
- React errors: 0
- resumed session renders correctly in /chat

Fix embedded dashboard TUI failures when the PTY process runs under Node 20, where global WebSocket may be unavailable. Fall back to undici's WebSocket constructor and cover the attach-mode behavior in gateway client tests.

Also keeps the prior render-phase update fix for gateway event handler creation, preventing eager config RPC during React render.
@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 Jun 2, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused dashboard/TUI investigation. This is an automated hermes-sweeper review; the requested behavior is already present on current main.

  • Merged PR fix(ui-tui): stabilize embedded dashboard chat gateway #44528 implemented the same two fixes in e2145a5c9cae337fad64ab6cf34fed730c00595b (fix(ui-tui): stabilize embedded dashboard chat gateway), shipped in v2026.6.19.
  • ui-tui/src/gatewayClient.ts:24-25 resolves Undici's WebSocket when the global constructor is unavailable; both sidecar and attached-gateway construction use it at :275 and :429-442.
  • ui-tui/src/app/createGatewayEventHandler.ts:314-318 starts the nudge-config read from gateway.ready, rather than during render-time handler construction.
  • Current regression coverage includes the missing-global-WebSocket fallback at ui-tui/src/__tests__/gatewayClient.test.ts:399-410 and deferred config loading at ui-tui/src/__tests__/createGatewayEventHandler.test.ts:1105-1126.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 13, 2026
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 sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants