Merge main into chat-close: combine the shared chat room with the server-side close

The item adds chat_close/chat_reopen to the brokered chat protocol and the
operator-session registry's closed state. main replaced the per-session claim
model with shared chat rooms (chat_subscribe, a prompt queue, one broker stream
fanned out to every watcher). This merges the two.

Resolved conflicts:
- internal/protocol/chat.go, internal/protocol/message.go: kept both additions -
  ChatClose/ChatReopen and main's ChatSubscribe/ChatQueued.
- internal/server/chat_sessions.go: kept the closed fields on a listed session;
  dropped the `Busy` assignment, because main no longer marks a session Busy (any
  number of clients may watch and write one).
- internal/server/chat_claims.go: main deleted the claim model, so the file goes;
  close's "is a turn running" check is now `chatHub.turnInFlight` in
  internal/server/chat_room.go, reading the room's `running` flag. That is the
  same question the old claim answered, against main's model.
- internal/server/chat_close.go: calls turnInFlight instead of the removed
  `active`.
- android AppViewModel.kt, ChatFormat.kt, ChatListPane.kt, Message.kt: kept both
  sides - main's search state, queued-prompt handling, `Busy`-free status label
  and row/menu shape, plus the item's close/reopen actions, closed chip and
  section, close confirmation and "Hide on this device" rename.

Also in this merge: main's new convention (AGENTS.md) that an item does not edit
a shared document; the item's stale-document record for this change lives in
docs/notes/chat-close.md, and docs/cli.md, android/README.md and
internal/author/skill/references/operations.md are left to the docs-fold writer.

Checks after resolving: gofmt clean, go build ./... and go vet ./... clean, the
Go module passes, and the app's :app:assembleDebug and :app:testDebugUnitTest
pass (--offline --no-daemon).
This commit is contained in:
2026-10-18 00:19:23 +01:00
75 changed files with 4520 additions and 769 deletions
+27 -5
View File
@@ -304,12 +304,31 @@ The brokered OpenCode chat exposes the operator's own sessions, separate from th
sessions pipeline runs create. The protocol types are:
- `chat_sessions` lists the operator's own sessions only, ordered
most-recently-used first. Each carries its `directory`, its `tag`, its `busy`
state (another connection currently holds it) and its recency. A session with
most-recently-used first. Each carries its `directory`, its `tag` and its
recency. A session with
no recorded tag is never listed, and no pipeline stage session is ever listed:
stage sessions are still recorded in `run_steps`/`run_session_owners`
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.
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.
- `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
other devices' prompts and the turn's streaming output — and can answer a shared
approval. Attaching is idempotent per connection; the subscription is released
when the connection ends.
- `chat_prompt` may come from any client. A prompt whose session already has a turn
in flight is accepted into that session's bounded queue (currently 8) and
acknowledged with `chat_queued: true`; the agent never receives two interleaved
turns. The prompt is echoed to the other watching clients as a `chat_event` of
kind `user`, carried with the sender's `client` label (a device name), while the
sender's own transcript keeps its local copy.
- `chat_reply` is exactly-once: the first answer to a pending request wins, is
recorded with the answering client's label and is pushed back to every watching
client as the same `chat_permission` frame with `resolved: true`, `decision` and
`resolved_by`, so each card clears and shows the outcome. A later answer is
refused as already answered (naming the client that won), never silently ignored
and never delivered to the agent twice.
- `chat_create` takes a `title` (default "New chat") and a `directory`
(default `~`, the operator's home; `~`, an omitted or empty value and a `~/...`
value all resolve to the home directory). A relative or missing directory is
@@ -357,8 +376,11 @@ password file as a reference).
The stored tag is exactly `operator`; the display label `Operator` is derived from
it, so there is no second tag vocabulary. Chat uses the server's one OpenCode
transport, and every existing chat guarantee (retained-state bounds, the
permission/approval flow, interruption, one broker call per list) is unchanged.
transport. A session's stream is fanned out to every client watching it, prompts
are serialised per session (queued behind the in-flight turn rather than
rejected), and approvals are shared and exactly-once; the retained-state bounds,
the resync-on-reconnect path, the exclusion of a run's own session and
per-connection write serialisation are unchanged.
The operator-session registry, filter, directory defaulting and the list bound are
covered by the `pipeline`, `opencode` and `server` unit tests. The live end-to-end
+65
View File
@@ -0,0 +1,65 @@
# Chat in-flight tool work
## What this item changed
`android/` only, the chat's two "working" surfaces.
- `ui/chat/ChatFormat.kt` adds `runningToolCalls` (the tool parts still
`running`, in transcript order), `toolDetail` (the command/description the
part's own input carries, from description/command/filePath/file_path/path/
pattern/query/url, one line, elided at 72 chars, `null` when absent),
`runningToolElapsedMillis` (the protocol's `time.ran`/`created` when present,
else the local per-part stamp), `runningToolStamps` (a stable start per part
across frames), `TOOL_LONG_RUNNING_MILLIS` = 60s with `toolLongRunning`, and
`sessionWorkLabel`.
- `ui/chat/ChatStore.kt`: `ChatThread.toolStartedAt` plus `runningTools` and
`toolElapsedMillis`; `history()`, the frame fold and `setRunning` maintain it.
- `ui/chat/ChatTranscript.kt`: `RunningIndicator` now also lists one line per
running call (name, detail where present, live elapsed), keyed by part id so
concurrent calls render together; a call past 60s is tinted and marked
`· long`.
- `ui/chat/ChatListPane.kt`: the session row renders
`sessionWorkLabel(session.busy, thread)`.
- `ui/chat/ChatRunningWorkTest.kt` covers it (name/detail/elapsed, clear on
completion, error state, concurrent calls, no-detail stream).
No percentage, ETA or progress bar is invented; only the reported fields (tool
name, `state.status`, `state.input`) are used.
## Shared documents this change makes stale
`android/README.md` documents the two surfaces this item changed, in the
`## Streaming replies (16 Oct 2026)` record. The note is written here rather
than edited in place; the `docs-fold` writer should update it.
- `android/README.md:4633` — the **Running indicator** bullet reads "The
transcript's indicator shows the spinner, `Working…` and the live elapsed
time (ticked once a second, never per frame, through the shared
`formatDuration`)." It should add that the indicator also lists, one line per
tool call still in flight, the call's name, the command/description the part
carries when it carries one, and that call's own live elapsed time; that a
call running 60 seconds or more is tinted and marked `· long`; that a call's
line drops out the moment it completes or errors, which is what clears the
indicator; and that no percentage, ETA or progress bar is shown. The rest of
the bullet (one-second tick, the tick loop keyed on the turn's start, the
elapsed count surviving a chat switch) is still true.
- `android/README.md:4454` — the session-list sentence "the list shows each
session's running/busy/read-only status" is now incomplete: a working session
row names what it is doing (`Running <tool>`, or `Running <n> tools` when
several run at once) instead of only `Running`, while a turn that is only
generating text still reads plain `Running`, so the two stay distinguishable;
a busy session with nothing running still reads `Busy · read-only`, and an
idle one `Idle`.
Dates, counts and capture names in those dated records are past evidence and
stay as they are; only the two behaviour statements above are now stale.
## Not stale
- No packaged OpenCode skill reference documents this app surface. The chat
references in `internal/author/skill/references/operations.md` document the
server's brokered `chat_*` protocol, which this change does not touch, and no
packaged template or `internal/author/` managed file names the app's chat
indicator or session label.
- `android/AGENTS.md` already lists `ui/chat/` and its files, so it needs no
change.
+40
View File
@@ -0,0 +1,40 @@
# docs-fold single documentation writer
## What this item changed
Per-item workflows no longer edit shared documentation themselves. The convention now
lives in `internal/author/skill/references/orchestration.md` (brief item 5, the
hard-constraint bullet, "Single documentation writer", and the "Pipeline choice"
committer bullet), the canonical committer checklist in
`internal/author/skill/references/format.md` (step 6), the bundled committer prompts in
`examples/task.md` and `examples/three-stage.md`, and the repository guideline
`AGENTS.md`.
The chosen mechanism is a **per-item note file** at `docs/notes/<slug>.md`: when a
change makes a shared document stale, the item records what changed and what should
change there, commits that note with its own change, and never edits a shared document.
The chosen **single writer** is the manual-only `docs-fold` pipeline, added as a fifth
bundled starter at `examples/docs-fold.md` and listed in `examples/catalog.go` and
`examples/README.md`. Its `fold` stage reads every note under `docs/notes/`, folds each
into the shared document it names, and deletes the consumed notes in its own commit.
## Shared documents this change makes stale
Adding the fifth starter (`docs-fold`) makes the following documents' starter counts
wrong. They were deliberately **not** edited by this item; the `docs-fold` writer should
correct them when it next folds notes.
- `README.md:191` — "To skip authoring, use **:templates**, choose one of the four
generic starters," should read "five generic starters".
- `docs/cli.md:170` — "Use `:templates` for four simple, manual-only starters: task,
review, research, and plan/implement/review." should say five starters and name
`docs-fold` (fold accumulated documentation notes, then commit locally).
- `internal/author/skill/references/operations.md:13` — "Four optional generic starters
are task, review, research and three-stage;" should read "Five optional generic
starters are task, review, research, three-stage and docs-fold;".
## Do not change
- `docs/first-version-testing.md:148` and the dated records in
`docs/installation-verification.md` describe a past fixture run at the time it ran;
they are dated evidence, not current counts, and stay as they are.