feat(web): a chat view shows a Claude session's conversation, rendered and live

A local or Docker Claude session can show its conversation as rendered text,
the way the Response Viewer draws it, in place of the terminal. The terminal
stays attached and sized underneath, so switching views never resizes the pane,
and the user still types in the terminal. Discussion #858 has the background.

- A Chat / Terminal switch and Alt+Shift+C change the view, and each session
  remembers its choice on this device until the session is gone. Two per-device
  settings pick the default view and hide the switch. Phones, remote and
  adopted sessions keep the terminal.
- The server broadcasts `transcript:update`, at most one per 750 ms per session,
  and the view re-reads the conversation on it, so an answer fills in mid-turn.
- The server keeps each transcript's parse and the byte offset it reached, so a
  read parses only the bytes appended since the last one, in chunks with an await
  between them. Overlapping reads of one file share one pass. The Response
  Viewer and the Discord bridge read through it too.
- A full conversation read starts a transcript watcher for a session that has
  none, such as one picked up after a server restart.
- A Docker session's hook reports the container's transcript path, and the
  server watches the host's copy of that file.
- After `/clear`, Claude Code runs the statusline command with the new
  conversation's id and transcript path. The statusline exporter posts them, and
  the server follows the new conversation the way it follows a hook's report.
- Keep-warm turns are hidden, long prompts fold, a "Working" line shows the turn's
  running time, and a pending dialog shows a notice that opens the terminal.

The design note, docs/chat-view-plan.md, covers this and the four steps that
follow it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michael GrundbergandClaude Opus 5.5 committed 2026-11-27 10:18:29 +01:00
1 parent babb55e4d9
commit c6fff5e6a8
39 files changed
+3844 -244

No files matched your search

+27
View File
@@ -601,6 +601,26 @@ request returns. The capture runs synchronous tmux calls on the server; the
| `lines=<n>` | With `full=1` only: read at most `<n>` lines of tmux history above the visible frame. An integer of at least 1, clamped to the configured history limit; absent or malformed, the whole limit (100,000 lines by default), as before. When a bound below the configured limit left older lines in tmux (its `history_size` is deeper), `truncated` is true with `truncationReason: 'tail'`; a byte cap still reports `'capped'`. Without it a full capture reads all of that history before `tail` cuts it, so a client that keeps a fixed number of lines (the tile grid sends its xterm's scrollback plus its rows) should send it. |
| `alt=recording` | With `full=1` only: if the pane is in the alternate screen (a nested tmux, where tmux keeps no history, or any full-screen app such as vim or less while it is open), answer with the visible frame over the byte recording instead (`source: 'mux-visible'`, `tail` applied as without `full=1`). Shells' automatic loads send it. |
## Conversation reads for the chat view
### `GET /api/v1/sessions/:id/last-response?context=full`
With `context=full`, the response carries the whole conversation as `messages`. Each
message read from a Claude transcript has `kind`, `label`, `role`, `text`, `turn` and,
when known, `timestamp`. A prompt the user typed while Claude was working also carries
`queued: true`. That reader also marks the turns that Codeman's prompt-cache
keep-warm sent. The nudge prompt and the reply to it both carry `keepAlive: true`, so a
client can leave them out as the chat view does. A prompt the user queued during that
turn makes the turn theirs, and its later messages carry no flag.
A full read of a Claude transcript also starts a transcript watcher when none runs for
the session. A watcher normally starts at the session's first hook or statusline report,
so a session picked up after a server restart has none until one of those arrives. The
read starts one from the file it found, and the session's `transcript:*` events then flow
mid-turn. After a `/clear`, a read moves a watcher it started itself to the conversation's
new file. It never replaces or moves a watcher that a hook or a statusline report started,
and it starts none for a remote SSH session, whose transcript is not on this host.
## Experimental bounded agent inspection and guarded input
**Experimental:** `codeman agent inspect`, `stage` and `submit`, and their
@@ -1903,6 +1923,13 @@ the stable contract — event names are not renamed without a major bump. An
optional `?sessions=<id,...>` filter suppresses only the high-volume terminal
stream; lifecycle/metadata events are delivered to all clients regardless.
### `transcript:update` (the chat view's re-read)
The server broadcasts `transcript:update` (`{ sessionId, timestamp }`) for a session whose
transcript watcher runs, whenever new lines arrive in its transcript. It throttles the event
to one per 750 ms per session. The first update after a quiet spell goes out at once, and a
burst after it collapses into one trailing event.
### `sse:heartbeat` (liveness)
Every 15s the server writes a `sse:heartbeat` frame to every connected client: