Merge: chat list shows running turns and background tasks for every chat
This commit is contained in:
@@ -1,35 +1,58 @@
|
||||
# Session list: background-task indicator (blocked on server data)
|
||||
# Session list: turn and background-task indicators
|
||||
|
||||
Request: show a quieter indicator on a chat list row when the turn is not running
|
||||
but the session still has live background work (shells, Claude background Bash,
|
||||
subagents). The turn spinner would win.
|
||||
Request: besides the turn spinner, show a quieter indicator on a chat list row
|
||||
when the turn is idle but the session still runs background work (shells,
|
||||
Claude Code background Bash and Agent/Task subagents, Codex command executions,
|
||||
OpenCode shells). Also make the spinner reliable for every listed chat, not
|
||||
only chats this connection opened.
|
||||
|
||||
Not implemented. The client cannot know this per listed chat without guessing.
|
||||
Implemented, with an approved server change.
|
||||
|
||||
## What exists
|
||||
- Background work is modelled server-side as shells for all three harnesses
|
||||
(OpenCode shell API, Codex `commandExecution` items, Claude background Bash
|
||||
and Agent/Task in `internal/claude/translate.go`).
|
||||
- `chat_event` kind `shell` frames: sent only to subscribers of that session's
|
||||
room (`chatHub.emitRoom`, `internal/server/chat_room.go`). The app subscribes
|
||||
only the chat it opens; subscriptions end when the socket closes.
|
||||
- `chat_shells` (`handleChatShells`, `internal/server/chat_shell_output.go`):
|
||||
an on-demand per-session readback. It is not pushed, and for Codex/Claude it
|
||||
goes through `chatManager.harness`, which can start the harness.
|
||||
## Server
|
||||
- `protocol.ChatSession.Activity` (`activity`: `turn_running`,
|
||||
`background_tasks`, `seq`) is set on every `chat_sessions` row from the hub's
|
||||
own state (`internal/server/chat_activity.go`, `handleChatSessions`).
|
||||
- `chat_activity` is pushed to every connection (through `chatSessionChanges`)
|
||||
when a session's turn starts or ends or its running-shell count changes. It
|
||||
is computed under the hub mutex at those points only: turn admitted or
|
||||
finished, step frames, shell frames, shell readback, and room release. Text
|
||||
and tool chunks never push. `seq` starts from the wall clock in microseconds,
|
||||
so it orders across a restart.
|
||||
- Keep-alive: `keepUnattendedLocked` keeps an unwatched room while it holds
|
||||
running shells, so their exits are seen and the badge clears. When the last
|
||||
shell exits, the room is released at once (`emitRoom`) or by the reaper.
|
||||
Bounds: the existing 16-room unattended cap, the 6-hour
|
||||
`chatUnattendedTurnLimit` (measured from when the room became unattended),
|
||||
and the harness itself. A Claude Code process exit now reports its running
|
||||
background tasks as exited (`processExit`, `internal/claude`). A released
|
||||
room reports 0 tasks rather than a stale count.
|
||||
|
||||
## What is missing
|
||||
- `protocol.ChatSession` (`internal/protocol/chat.go`) has no background field,
|
||||
and `handleChatSessions` (`internal/server/chat_sessions.go`) sets none.
|
||||
- No push to every connection when a session's running-shell set changes
|
||||
(`chat_session_changed` goes to all connections but carries no such field).
|
||||
- `keepUnattendedLocked` (`internal/server/chat_unattended.go`) does not keep a
|
||||
room alive for running shells, so after the last viewer leaves the server stops
|
||||
observing that session's shell exits.
|
||||
## App
|
||||
- `ChatSessionsController` applies `chat_activity` and row `activity` by `seq`
|
||||
(the larger wins), deriving `running` and `background_tasks` on the row.
|
||||
The list re-reads on reconnect (the existing `syncToken`). A server without
|
||||
`activity` leaves the list as before.
|
||||
- `session_activity_badge.dart`: the turn spinner, or, when idle with tasks,
|
||||
a muted `Icons.pending` / `CupertinoIcons.ellipsis_circle_fill` glyph with
|
||||
tooltip and semantics "Background tasks running (N)". The tooltip shows on
|
||||
hover only (`TooltipTriggerMode.manual`), so a touch long press stays the
|
||||
row's own gesture.
|
||||
- Fixture: `?chats=N&activity=1` in the capture app lists one running chat,
|
||||
one with two background tasks and idle chats (`tool/perf/perf_fixture.dart`).
|
||||
|
||||
A server change that adds a count to the list row, sends it with
|
||||
`chat_session_changed` (or a dedicated frame) on each running-set change, and keeps
|
||||
observing sessions with live shells would let the client draw this accurately
|
||||
through `chatSessionFrameEffect` and `session_row_content.dart`.
|
||||
## Evidence
|
||||
- Go: `chat_activity_test.go` covers the list payload, the pushes on turn start
|
||||
and end and on task start and exit, unattended keep and release on exit, and
|
||||
expiry of a task that never reports an exit. `background_tasks_test.go` covers
|
||||
the Claude process exit.
|
||||
- Flutter: `test/features/chat/ui/sessions/chat_sessions_activity_test.dart`.
|
||||
- Captures (fixture app): Material phone 560x1000, Material desktop
|
||||
1280x900 with the hover tooltip, and Cupertino dark phone.
|
||||
|
||||
The existing turn spinner has the same limit: it follows only rooms this connection
|
||||
subscribed to.
|
||||
## Unverified
|
||||
- Real harness behaviour. Shell start and exit events come from each adapter's
|
||||
existing translation. Whether a real Codex or OpenCode background command
|
||||
always reports its exit was not exercised against live harnesses here.
|
||||
- Background Bash outliving a crashed Claude Code CLI. It is reported exited
|
||||
on process exit, on the assumption that the CLI's tasks end with it.
|
||||
- Device (Android/iOS) rendering; only the browser was captured.
|
||||
|
||||
Reference in New Issue
Block a user