web: add chat model picker, agent badges and a preloaded brief

Show the current model under the chat title with an OpenCode-backed picker,
put an agent mark on the right of every chat row, simplify the tool summary to
'N tools', and give the reasoning and tool controls one symmetric hover box.
New chats preload an editable behavior brief, and the activity spinner remains
the turn's single live progress indicator.
This commit is contained in:
2026-10-20 14:58:26 +01:00
parent 6bfe4c8921
commit 4b20be6ea3
7 changed files with 397 additions and 49 deletions
+3
View File
@@ -172,6 +172,9 @@ to it, but the server never lists it and a reload drops it.
| B18 | Chat attachments in the message and paste | `chat_prompt.attachments` | done — composer files are read into base64 and sent with the prompt (1 MiB total, under the 2 MiB websocket frame), the server writes them to private temporary files and passes `file://` references to OpenCode's prompt `files`, and both the live user turn and reloaded history render a named file chip inside the message. Pasting an image/file into the textarea attaches it with the same picker path; a pasted image without a filename gets a generated name. The optimistic user bubble shows the file immediately, and OpenCode history maps the top-level user `files` envelope (never its base64 data) into the same part. |
| B19 | One live chat activity line and immediate Stop | — | done — every in-flight turn now has one square activity row carrying the spinner, `Thinking`/`Reasoning · N steps`, the tool-call chip with its current call, and the elapsed time; the separate reasoning, tool and bottom "thinking" lines are gone. The row stays in place when the turn settles (spinner off), and the elapsed ticks locally each second. The composer's Stop is refreshed on the step frame itself, so it appears for turns started by another client and stays through tool calls. A subscribe that joins a live turn replays a `step started` marker. Cancel now marks the run and its live step canceled immediately before interrupting the runner, so a context-unaware stage cannot leave a "running" row after Stop. |
| B20 | Cancel a running run immediately | `cancel_run` | done — `runner.cancel` persists `canceled` on the run and its live step before calling the runner's cancel function; late stage returns cannot overwrite it (`FinishRun` only updates queued/running, and a failed step persistence is reported as canceled, not a failure). This also covers orphaned running rows with no active goroutine and waiting runs. Verified by store tests and the run that had been stuck at run 13 is now interrupted/canceled rather than running. |
| B21 | Change a chat's model | `chat_models`, `chat_model` | done — the open conversation shows its current model under the title. Clicking it lists the OpenCode endpoint's enabled, non-deprecated models with provider/name, scrolls the current selection into view, and switches through `POST /api/session/{id}/model`; the row and header update immediately and the next turn uses it. The list is read-only until a model is chosen, and a failed switch leaves the dialog open with the server's reason. Verified live: 48 models listed and an ephemeral session switched to `opencode-go/beam-free`. |
| B22 | Agent badge on chat rows | — | done — every chat row shows the harness mark at its right edge (OpenCode terminal, Codex hex, Claude starburst, Pi), with the harness name as tooltip/aria-label. OpenCode is the default for legacy rows; Codex rows carry their backend from the adapter. The model switcher is hidden for harnesses that do not support it. |
| B23 | Preload a new chat's behavior | `chat_create.instructions` | done — the New chat pane now has an editable **How should it act?** brief, prefilled with a project-agnostic care/verification brief. `chat_create` carries it as `instructions`; OpenCode stores it as the durable `pipelines.behavior` session instruction entry before the first turn, so the agent starts with the brief. Other harnesses and older OpenCode builds still create the chat if the instruction surface is unavailable. Verified live with an ephemeral create: the instruction entry was present immediately after creation. |
| B13 | Codex chat backend | `chat_backends`, `chat_create.backend` | done — OpenCode stays the default. `chat_backends` lists `codex` when the Codex App Server control socket is present; New chat shows a harness choice, the selected backend is stored on the operator-session row and echoed on every session. The Codex adapter connects to the existing App Server over its Unix WebSocket, maps `thread/start`, `turn/start`, `thread/read`, item/tool events, `item/tool/requestUserInput` to the existing question card, and carries the native user-message id so optimistic and history turns reconcile. Verified live: created a Codex chat from the browser, sent a prompt, saw the streamed answer, read it back through `chat_messages`, and saw the Codex chip and title in the list. Claude is not advertised yet: its OAuth session is expired and the SDK/CLI sidecar is still to be built. |
| B12 | One detail header, optimistic sends, thinking above the bubble | — | done — every non-chat detail (pipeline, run, template) now extracts its own `#detailTitle` into a shared `.detail-head` with the same 44px chevron Back control; on phones the button and title are vertically centred, and on wide screens the back control is hidden while the title stays in the header. Chat/create already use the same control. Sending now appends the operator's optimistic user turn immediately (using the native message id OpenCode persists), so the running placeholder cannot appear before their message. While a turn runs, Send stays present beside Stop; a follow-up is queued. The reasoning/thinking block moved outside and above the answer bubble, like the tool summary below it. |
| B11 | Enter composes; live shell bars stay in place | — | done — Enter now inserts a newline (a real CDP Enter produced `first\n` and no prompt), while Ctrl/Cmd+Enter sends; a slash draft still runs its command on Enter. The chat star reserves a 26px corner in the row head, so it no longer covers Streaming/New/Idle. Background-shell frames patch the tasks bar in place instead of full-rendering the pane, keeping the composer mounted. The shell cache was bumped to v2 so an installed PWA picks up these client changes. |