Merge: chat list shows running turns and background tasks for every chat

This commit is contained in:
2026-11-03 19:54:35 +00:00
33 changed files with 1148 additions and 164 deletions
+13
View File
@@ -95,6 +95,19 @@ Claude Code also accepts `/clear` in `-p --input-format stream-json` mode, but
the CLI then picks the new session id itself. Re-keying keeps one path for all
three harnesses and lets the server choose the id.
## Chat list activity
Every `chat_sessions` row carries `activity` (turn running, running background
tasks), and `chat_activity` pushes each change to every connection (see
`docs/cli.md`). Background tasks are the same shells all three harnesses already
report: OpenCode shells, Codex `commandExecution` items, and Claude Code
background Bash and Agent/Task subagents. A chat whose last viewer left stays
observed while its tasks run, so their exits are seen. That is bounded by the
unattended limits (16 chats, 6 hours) and by the harness: when a Claude Code
process exits, its background tasks are reported exited because they ran inside
it. After an OpenCode or Codex stream reconnects, the shell set is re-read from
the harness.
## Web interaction contract
All advertised chat adapters (OpenCode V2, Codex and Claude Code) implement the
+14
View File
@@ -455,6 +455,20 @@ sessions pipeline runs create. The protocol types are:
for the run that owns them. The list is fail-closed: with no registry and no
store it returns an empty list, never the endpoint's whole session list. A
session is never marked `busy`: any number of clients may watch and write one.
Each row carries `activity` (`turn_running`, `background_tasks`, `seq`): the
server's live view of the session. An older server omits it.
- `chat_activity` is pushed to every open connection, not only the chat's
watchers, when a session's turn starts or ends or its count of running
background tasks changes (shells, background commands, Claude Code background
Bash and subagents, Codex command executions). The body is `chat_activity`
(`session_id`, `turn_running`, `background_tasks`, `seq`). It is sent on those
transitions only, never per output chunk. `seq` increases with every change
and keeps increasing across a restart, so a client keeps the snapshot (list
row or push) with the larger `seq`. Background tasks are counted only while
the server observes the session: after a chat's last viewer leaves, the
server keeps observing it while its tasks run (bounded like an unattended
turn: at most 16 such chats and 6 hours). Once released it reports none
rather than a stale count.
- `chat_subscribe` attaches a connection to one session's shared live stream (body
`session_id`) and replays the session's still-pending approval requests, so every
client that watches a session sees every frame any client's turn produces — the