From 2c2e32cc4519973c77b63016316b065c0f656704 Mon Sep 17 00:00:00 2001 From: emozilla Date: Tue, 21 Apr 2026 02:10:59 -0400 Subject: [PATCH] docs: document the dashboard Chat tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AGENTS.md — new subsection under TUI Architecture explaining that the dashboard embeds the real hermes --tui rather than rewriting it, with pointers to the pty_bridge + WebSocket endpoint and the rule 'never add a parallel chat surface in React.' website/docs/user-guide/features/web-dashboard.md — user-facing Chat section inside the existing Web Dashboard page, covering how it works (WebSocket + PTY + xterm.js), the Sessions-page resume flow, and prerequisites (Node.js, ptyprocess, POSIX kernel / WSL on Windows). --- AGENTS.md | 11 ++++++++++ .../docs/user-guide/features/web-dashboard.md | 22 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 0f5ce15f2..2deb4217c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -243,6 +243,17 @@ npm run fmt # prettier npm test # vitest ``` +### TUI in the Dashboard (`hermes dashboard` → `/chat`) + +The dashboard embeds the real `hermes --tui` — **not** a rewrite. See `hermes_cli/pty_bridge.py` + the `@app.websocket("/api/pty")` endpoint in `hermes_cli/web_server.py`. + +- Browser loads `web/src/pages/ChatPage.tsx`, which mounts xterm.js's `Terminal` with the WebGL renderer, `@xterm/addon-fit` for container-driven resize, and `@xterm/addon-unicode11` for modern wide-character widths. +- `/api/pty?token=…` upgrades to a WebSocket; auth uses the same ephemeral `_SESSION_TOKEN` as REST, via query param (browsers can't set `Authorization` on WS upgrade). +- The server spawns whatever `hermes --tui` would spawn, through `ptyprocess` (POSIX PTY — WSL works, native Windows does not). +- Frames: raw PTY bytes each direction; resize via `\x1b[RESIZE:;]` intercepted on the server and applied with `TIOCSWINSZ`. + +**Never add a parallel chat surface in React.** If you catch yourself re-implementing slash popover / model picker / tool cards for the dashboard, stop — the TUI already does those, and anything new you add to Ink will appear in the dashboard automatically. + --- ## Adding New Tools diff --git a/website/docs/user-guide/features/web-dashboard.md b/website/docs/user-guide/features/web-dashboard.md index 2ef04297d..65a843302 100644 --- a/website/docs/user-guide/features/web-dashboard.md +++ b/website/docs/user-guide/features/web-dashboard.md @@ -60,6 +60,28 @@ The landing page shows a live overview of your installation: The status page auto-refreshes every 5 seconds. +### Chat + +The **Chat** tab embeds the full Hermes TUI (the same interface you get from `hermes --tui`) directly in the browser. Everything you can do in the terminal TUI — slash commands, model picker, tool-call cards, markdown streaming, clarify/sudo/approval prompts, skin theming — works identically here, because the dashboard is running the real TUI binary and rendering its ANSI output through [xterm.js](https://xtermjs.org/) with its WebGL renderer for pixel-perfect cell layout. + +**How it works:** + +- `/api/pty` opens a WebSocket authenticated with the dashboard's session token +- The server spawns `hermes --tui` behind a POSIX pseudo-terminal +- Keystrokes travel to the PTY; ANSI output streams back to the browser +- xterm.js's WebGL renderer paints each cell to an integer-pixel grid; mouse tracking (SGR 1006), wide characters (Unicode 11), and box-drawing glyphs all render natively +- Resizing the browser window resizes the TUI via the `@xterm/addon-fit` addon + +**Resume an existing session:** from the **Sessions** tab, click the play icon (▶) next to any session. That jumps to `/chat?resume=` and launches the TUI with `--resume`, loading the full history. + +**Prerequisites:** + +- Node.js (same requirement as `hermes --tui`; the TUI bundle is built on first launch) +- `ptyprocess` — included when you `pip install hermes-agent[web]` +- POSIX kernel (Linux, macOS, or WSL). Native Windows Python is not supported — use WSL. + +Close the browser tab and the PTY is reaped cleanly on the server. Re-opening spawns a fresh session. + ### Config A form-based editor for `config.yaml`. All 150+ configuration fields are auto-discovered from `DEFAULT_CONFIG` and organized into tabbed categories: