Merge main into session-html-only: combine the html-only session export with chat-tool-group and chat-activity

This commit is contained in:
2026-10-18 10:06:54 +01:00
18 changed files with 1471 additions and 158 deletions
@@ -0,0 +1,98 @@
# Chat: an honest in-flight state and background processes
## What this item changed
Both areas, the chat's in-flight feedback.
**Server (`internal/`).**
- `protocol/chat.go` adds the `shell` frame kind (`ChatEventShell`), the
`ChatShell` payload (`id`, `status`, `command`, optional `exit` — a pointer so
exit `0` is not "absent"), the `ChatShellRunning`/`ChatShellExited` statuses and
the `ChatEventFrame.shell` field.
- `opencode/chat.go` maps the location-scoped `shell.created`/`shell.exited`
firehose events onto that frame. A shell belongs to the session that started it
only through `data.info.metadata.sessionID` (the agent's shell tool sets it);
the exit event carries no session at all, so it is emitted only for a shell id
the stream already surfaced. Another session's shell, and a shell with no
attributed session, are ignored; a shell event with no id fails the stream.
`NormalizeChatEvent` now folds a `ChatStreamState` (the retained last message id
plus the session's running shell ids) across frames instead of a bare
`*string`.
- `server/chat_hub.go` retains each session's still-running shells (bounded by
`chatShellLimit` and the per-session byte cap) and clears them on exit;
`server/chat_stream.go` replays them on `chat_subscribe`, the shell half of the
resume (the message snapshot cannot carry a shell, because a shell is not a
turn).
**App (`android/`).**
- `data/protocol/Chat.kt` adds `ChatShell`, `ChatEventFrame.shell`, `EVENT_SHELL`,
`SHELL_RUNNING`/`SHELL_EXITED`.
- `ui/chat/ChatFormat.kt` adds the one pure derivation of a running turn's phase
(`TurnPhase` + `turnPhase` + `turnPhaseLabel` + `TURN_THINKING_WINDOW_MILLIS`)
and of the background processes (`runningBackgroundShells`,
`shellCommandSummary`).
- `ui/chat/ChatStore.kt`: `ChatThread.lastDeltaAt` (stamped on every text/reasoning
delta, cleared when the turn settles) and `ChatThread.shells` (a shell joins on
its running frame and leaves on its exited frame, never marking the thread
running); `thread.phase(now)` and `thread.runningShells`; `streamResumed` drops
shells so the subscribe replay re-syncs the ones still running.
- `ui/chat/ChatTranscript.kt`: `RunningIndicator`'s headline is the phase label
(was the bare `Working…`); a new `BackgroundProcessBar` names each running
shell.
- `ui/chat/ChatConversationPane.kt` shows the bar whenever a shell is running,
whether or not a turn is.
No percentage, ETA or progress bar is invented on either side.
## Shared documents this change makes stale
`docs/cli.md` and `android/README.md`. The note is written here rather than edited
in place; the `docs-fold` writer should update them.
- `docs/cli.md`, the `chat_subscribe` bullet ("`chat_subscribe` attaches a
connection to one session's shared live stream (body `session_id`) and replays
the session's still-pending approval requests…") is now incomplete: attaching
also replays the session's still-running shell commands as `chat_event` frames
of the new kind `shell`, so a device that attaches after a background process
started is shown it.
- `docs/cli.md`, the chat-protocol type list, should name the new `chat_event`
kind `shell`: its payload carries the shell's `id`, `status`
(`running`/`exited`), the `command` it is running and, once it has exited, its
`exit` code. It carries no message id, because a background process outlives the
turn that started it.
- `android/README.md:4719` — the **Running indicator** bullet reads "The
transcript's indicator shows the spinner, `Working…` and the live elapsed
time…". It should say the headline is the turn's actual state — `Thinking…`
while text/reasoning deltas are still arriving, `Running a tool…` while calls
are in flight, `Waiting…` otherwise — derived purely from the tool calls and the
time since the last delta, never an invented percentage/ETA (the one-second
tick, the elapsed living on the thread, and the tool lines below it are still
true).
- `android/README.md` should also record the new always-visible background-process
strip: whenever a shell the agent started is still running it names the
command, it is independent of the turn (a background process can outlive the
turn and is shown then), it survives a chat switch, and it clears the moment the
shell exits.
Dates, counts and capture names in the dated README records are past evidence and
stay as they are; only the behaviour statements above are now stale.
## Not stale
- No packaged OpenCode skill reference documents either surface. The chat
references in `internal/author/skill/references/` document the server's
brokered `chat_*` protocol at a level this change extends additively; nothing
there names the frame kinds or the app indicator.
- `android/AGENTS.md` and `internal/server/AGENTS.md` already list the files
touched, so they need no change.
## Not verified live
The end-to-end behaviour on the operator's phone against a **changed** server was
not captured: the deployed server (`0.0.0.0:8080`) predates the shell mapping, and
redeploying it is forbidden while runs are in flight. The shell mapping itself was
checked against the installed OpenCode 2.0.20 service's own event stream (a
`shell.created` carries `metadata.sessionID`, a `shell.exited` carries only
`id`/`exit`/`status`); the app path is covered by unit tests only.
+48
View File
@@ -0,0 +1,48 @@
# Chat transcript: one tool-call summary chip per agent turn
## What this item changed
`android/` only — the chat transcript's tool-call surface.
- **One chip per turn.** `ui/chat/ChatToolCalls.kt` no longer renders a chip per
call in a `FlowRow`; `ToolCalls` renders a single summary chip reading
`N tools called` (`1 tool called` for one), the transcript's only tool-call
surface. The individual calls are not chips any more.
- **Live summary.** The chip shows the existing spinner while any call is in
flight and a `· long` mark while a running call has passed
`TOOL_LONG_RUNNING_MILLIS`; both are gated on the turn still streaming
(`AgentTurnItem` passes `live = streaming`), so a settled turn never shows the
spinner or a long mark for a stored call whose status is stale.
- **Popup list.** Tapping the chip opens `ToolPanel` as a bounded
(`TOOL_PANEL_MAX_HEIGHT_DP`), scrollable list of one collapsible row per call in
the order the agent made them. A row shows the call's name, its one-line detail,
its `+N -M` stat for an edit and its duration, and expands in place to the
pretty-printed INPUT, the synthesised diff for an `edit`-family call, then the
ERROR block for a failed call or the OUTPUT (or `(no output)`). Rows expand and
collapse independently, and the popup still does not re-flow or scroll the
transcript.
- **Pure logic.** `ui/chat/ChatFormat.kt` adds `toolCallsLabel`,
`toolCallsAnnouncement` (the chip's accessibility line, e.g. "6 tool calls,
expand for details"), `toolCallCount`, `toolsRunning` and `toolCallRow` (the
per-row detail derivation), with cases added to `ChatFormatTest`.
- **Geometry.** `ui/theme/Dimens.kt` adds `TOOL_PANEL_MAX_HEIGHT_DP`; no raw
literal was introduced, so `DimensTest` is unchanged.
## Shared documents this change makes stale
`android/README.md` describes the surface this item changed. The note is written
here rather than edited in place; the `docs-fold` writer should update it.
- `android/README.md` — the section **"Tool-call chips and the expandable panel
(16 Oct 2026)"** and its **Grouped chips** bullet ("A run of consecutive `tool`
parts in one assistant turn is now one `FlowRow` of compact chips") describe the
per-call chips this item removed. It should say the turn renders one summary
chip (`N tools called`) as the transcript's only tool-call surface, and that
tapping it opens one popup listing every call of the turn as independently
collapsible rows, with the chip's spinner/`long` marks gated on the turn still
streaming. The **Overlay panel, scroll preserved** bullet stays true.
- `docs/chat-verification.md:140` — the "Conversation — tool chip expanding" row
names `ChatToolCalls.kt` and the per-chip panel; it should name the summary chip
and the per-turn popup list, and the pure tests now include the label, count,
announcement and per-row derivations in `ChatFormatTest` (the placement maths in
`ToolPanelPositionProviderTest` is unchanged).