Merge lane-app2: the chat experience and its multi-conversation state

Integrates eight commits of reviewed chat work: the Chat destination with
several conversations, markdown transcripts, tool-call chips with an expandable
INPUT/OUTPUT panel, edit diff cards, the composer's stop control, and approval
cards. The automated resolver failed on this merge repeatedly (its own stages kept
dying on the malformed-result defect), so it was integrated by hand.

Integration decisions:
- Pill geometry: main's tokens win. lane-app2 carried private duplicates of
  DESTINATION_ITEM_SIZE/GAP and a private DESTINATION_PILL_RESERVE, added before the
  geometry-token migration; those duplicates are dropped in favour of the theme
  tokens main already exports.
- IME mode: kept lane-app2's adjustResize for the window, because the chat composer
  and the search field both raise the keyboard and the chat UI was reviewed with it.
- Protocol and view-model constants: both sides' independent additions are kept.
- ChatScreen now passes the compactLabel main's SlidingPaneStack gained, and the
  literals lane-app2 introduced before the token discipline are converted to five
  new named tokens (HAIRLINE_DP, ICON_BUTTON_SMALL_DP, TOOL_PANEL_MAX_WIDTH_DP,
  CHAT_TITLE_MAX_WIDTH_DP, CHAT_BUBBLE_MAX_WIDTH_DP) rather than allow-listed.

Verified: assembleDebug plus the full Android unit suite (409 tests) pass,
including the geometry enforcement test.
This commit is contained in:
2026-10-16 22:27:30 +01:00
21 changed files with 4862 additions and 3 deletions
+659
View File
@@ -4304,3 +4304,662 @@ Not verified in this pass: device frames of the populated panel, the empty resul
and a selection navigating (the visual review owns the device, per the brief's
device policy); the panel's pure logic is exercised by the unit tests and the
compile only.
## Chat destination and multiple conversations (16 Oct 2026)
The first Chat slice: the destination, the server session list and several
conversations held open at once. `android/` only; no new dependency (the
`material-icons-extended` icon is the declared one), no Pipelines server/Go/
installer/Docker file touched, no run started from the app, and the operator's
physical device was never used (`emulator-5556` only).
- **Pill.** The floating destination pill gains a Chat icon between Runs and
Settings (icons only, 48dp targets via the named `DESTINATION_ITEM_SIZE`/
`DESTINATION_ITEM_GAP` tokens, one non-wrapping `Row`), so it stays narrow and
clear of the reserved 88dp bottom inset however many destinations it holds.
The Search destination is owned by another lane and is not present on this
base; the pill is built to take it.
- **Brokered protocol.** `data/protocol/Chat.kt` mirrors `internal/protocol/chat.go`
field-for-field (sessions, create, query, prompt, messages/parts, event frames,
permission, reply); `Message` gains the optional `chat_*` payloads and
`PipelinesClient` now forwards *unsolicited* frames (chat_event/chat_permission)
to `events` instead of dropping them. `PipelinesRepository` exposes the typed
chat calls.
- **Multi-chat model.** `ui/chat/ChatStore.kt` is an Android-free state holder:
every open chat keeps its own conversation, running flag, composer draft and
scroll position; `open`/`activate` report when history must be (re-)fetched so
a running session re-syncs on return instead of showing a stale copy; a
server frame is applied to its chat whether or not it is on screen. `busy`
sessions render read-only and the composer refuses to write to them.
- **Surface.** `ui/chat/ChatScreen.kt` reuses the shared adaptive
`SlidingPaneStack` (session list → conversation): the list shows each session's
running/busy/read-only status, an open-chat strip switches between several
conversations in one tap (with an optional X to close one), and the
conversation is a bottom-anchored transcript of user bubbles, secondary
reasoning, assistant text and tool-call chips that expand to INPUT
(pretty-printed JSON) / OUTPUT (monospace, via the shared `CodeBlock`).
"New chat" creates a server session and opens it. Closing a chat *is* provided
(the chip X); it removes only that chat.
- **Messages sent to a chat are optimistic** (the bubble shows immediately); the
live delta/streaming pass is the next slice.
Evidence (macOS, JDK 17, Gradle 9.7.1 `--offline`,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:assembleDebug :app:testDebugUnitTest --rerun-tasks` →
`BUILD SUCCESSFUL`, **229 tests, 0 failures** (new `MultiChatStateTest`:
switching preserves each conversation, a running session re-syncs on return,
drafts and scroll are per chat, a busy session is read-only, background events
land on their own chat; new `ChatProtocolTest` for the wire shapes; new
`ChatFormatTest`).
- The debug APK was installed on `emulator-5556` (`FoldB_API_36`, narrow
`wm size 1080x2340` @420) and driven with `uiautomator dump`/`input tap`;
captures were validated with `android/scripts/capture_png.sh -s emulator-5556`:
the pill with the Chat destination (`01_pill_chat`), the session list
(`02_chat_list`, `05_chat_list_one_open`, `07_chat_list_two_open`), two chats
with different conversations (`03_chat_alpha` and `06_chat_beta`), a tool chip
expanded to INPUT/OUTPUT (`04_chat_alpha_tool_expanded`), a read-only busy
session with a disabled composer (`08_chat_readonly`) and a per-chat draft
preserved across a switch (`10_draft_preserved`). `adb -s emulator-5556 logcat
-d` held 0 `FATAL EXCEPTION` and 0 `E AndroidRuntime` during the sweep.
- **The deployed Pipelines server predates chat** (verified: a `chat_sessions`
request answers `unknown command: chat_sessions`), and the server-side chat
broker is a separate lane. The on-emulator sweep therefore drove the client
against `chat_stub.py`, a minimal `/connect` WebSocket double that speaks the
exact `internal/protocol/chat.go` JSON, so the screenshots show real client
rendering of the documented wire contract, not the production service.
- **APK publish.** `app-debug.apk` (18,261,008 bytes, sha256
`aa167617c830fd7249eedf457959ef7e99b553769ed4ab82a3af6b4e8cb98ed3`) copied to
`~/.local/share/pipelines/data/artifacts/119/1/pipelines-debug-wip-e5bde98.apk`;
`curl -I http://10.0.0.249:8080/artifacts/119/1/pipelines-debug-wip-e5bde98.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18261008`; a streamed `GET | shasum -a 256` matched.
Not verified in this pass: the live brokered server (not deployed and out of
this lane's scope), a genuinely running session's re-sync against OpenCode
(covered by the model test, not live), and streaming/stop/approval/attachments,
which are later slices.
### Review follow-ups (16 Oct 2026, implementer pass)
Addressing the reviewer's findings on the slice above, still `android/` only.
- **Shared part upsert (duplication blocker).** `ChatStore.applyDelta` and
`applyTool` were the same message/part upsert twice. Both now call one private
`upsertPart(frame, partId) { existing -> … }`; the delta appends to the existing
text, the tool replaces the part, and neither can drift. `event()` and the new
`permission()` share one `ensureThread()` placeholder creator.
- **Diff cards (task gap).** The research report's edit view (`_CodeRun` /
`_DiffView`, §1.3) is now reproduced: an `edit`-family tool call renders a diff
card. `ChatFormat.toolEditDiff` derives an LCS line diff from the arguments'
`oldString`/`newString` — the brokered protocol has **no** diff field (research
§2.5), so it is synthesised, never silently dropped. The collapsed chip shows
the file and the `+N -M` stat; expanding shows the green/red monospace lines
(the app's own success/failure hues, not new literals).
- **One read-only rule (divergent code).** `sessionReadOnly` was dead (only its
own test called it) and disagreed with the UI's `ChatThread.readOnly = busy` for
a locally-running busy session. The helper is deleted and `ChatThread.readOnly`
is now `busy && !running`, the same precedence `sessionStatusLabel` uses: a turn
we started is `Running` and writable, not read-only.
- **`chatReply` / approval now reachable (unused API).** `observeChatEvents`
forwards `chat_permission` into `ChatStore.permission` instead of dropping it,
the conversation shows an approval bar (action, resources, Allow once / Always /
Deny) and `AppViewModel.replyChatPermission` answers through `chatReply`.
- **Stop control fixed (found while tracing read-only).** While a turn ran the
composer's red stop button was wired to `onSend`, so it sent the draft instead
of interrupting; it now calls `stopChat`.
- **Evidence gap closed.** The previous checklist cited `09` (new chat) but no
`09_*` file existed; this pass captures `09_new_chat.png` (the New-chat
conversation), plus `11_diff_card.png` and `12_permission_bar.png` for the two
new surfaces.
Evidence (macOS, JDK 17, Gradle 9.7.1 `--offline`,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:assembleDebug :app:testDebugUnitTest --offline` → `BUILD
SUCCESSFUL`; the JUnit XML totals **233 tests, 0 failures, 0 errors, 0
skipped** (new `toolEditDiffMarksOnlyChangedLinesAndCountsThem`,
`toolEditDiffIsNullForNonEdits`, `locallyRunningBusyChatStaysWritable`,
`permissionIsStoredUntilAnswered`).
- The debug APK was installed on `emulator-5556` only and driven with
`uiautomator dump`/`input tap`; captures validated with
`android/scripts/capture_png.sh -s emulator-5556`: the new-chat conversation
(`09_new_chat`), the derived diff (`11_diff_card`, showing
`context / - val gap = 4.dp / + val gap = 6.dp / + val inset = 2.dp` under a
`src/layout.kt +2 -1` chip) and the approval bar (`12_permission_bar`). Tapping
**Allow once** cleared the bar through `chat_reply`. `adb -s emulator-5556
logcat -d` held 0 `FATAL EXCEPTION` and 0 `E AndroidRuntime`. Driven against the
test-double stub (the deployed server still predates chat).
- **APK publish.** `app-debug.apk` (18,228,844 bytes, sha256
`db240fc2fc295c5ab50530f9d8cefae908f307a3115b54ce9f6d713e05643b87`) copied to
`~/.local/share/pipelines/data/artifacts/119/3/pipelines-debug-wip-e5bde98.apk`.
Still not verified: the live brokered server (separate lane), streaming against
real OpenCode, and attachments — unchanged from the pass above.
## Conversation markdown rendering (16 Oct 2026)
The assistant's `text` part was rendered as one plain `Text`; it is now rendered
as markdown, matching the reference experience (research report Part 1 §1.2).
`android/` only; no new dependency (still just the declared
`material-icons-extended`), no Pipelines server/Go/installer/Docker file touched,
no run started from the app, and `emulator-5556` only (lane A's `emulator-5554`
was never addressed).
- **Parser.** `ui/chat/Markdown.kt` adds a small, dependency-free CommonMark
subset. It is pure Kotlin (no Compose, no transport) so it is unit-testable:
paragraphs (soft-wrapped lines join with a space), `#`..`######` headings,
fenced code (``` ``` / `~~~`, with the info string as the language), block
quotes, bullet and ordered lists, `|` tables (with a `---` delimiter row),
thematic rules, and inline code / bold / italic / `[label](url)` /
bare-`http(s)://` autolinks. Underscore emphasis needs word boundaries so
`snake_case` is never italicised. Anything outside the subset renders as plain
text, never dropped.
- **Renderer.** The same file turns the blocks into themed, selectable Compose
content: fenced code reuses the shared `CodeBlock`, so the whole-block copy
action is the existing one (label = the fence language, `code` when absent);
tables are a bordered grid with a bold header and equal-weight wrapping cells;
links use `LinkAnnotation.Url`, so they are tap-openable and styled from the
scheme; inline code and headings use the shared type roles
(`pipelinesText()`), not ad-hoc sizes. `ChatScreen.MessagePart` now calls
`MarkdownText(part.text)` for `PART_TEXT`; the assistant message stays one
`SelectionContainer`, so all of it remains selectable and the bounded code
block/table keep long content inside the bubble. Geometry reuses the chat
tokens (`CHAT_ITEM_GAP`, promoted from `private` to `internal`); only the
quote-bar width and table border, which had no token, are new named constants.
Evidence (macOS, JDK 17, Gradle 9.7.1 `--offline`,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:assembleDebug :app:testDebugUnitTest --offline` → `BUILD
SUCCESSFUL`; the JUnit XML totals **243 tests, 0 failures, 0 errors, 0
skipped** (new `MarkdownTest`: fences keep their language, an unterminated
fence still yields code, soft-wrapped paragraphs join, headings/rules parse by
level, bullet/ordered lists, table header/rows, inline code/bold/italic/link,
bare-URL autolink trims trailing punctuation, `snake_case` is not emphasis,
empty source → no blocks).
- The debug APK was installed on `emulator-5556` only and driven against a
stdlib `/connect` WebSocket double serving a fixed history; capture was
validated with `android/scripts/capture_png.sh -s emulator-5556`:
`chat_markdown_conversation.png` shows the bottom-anchored transcript with the
user bubble, the secondary reasoning line, body markdown with inline code and
an underlined link, a `kotlin` fenced code block with its copy action, and the
bordered `Surface | Role` table. `adb -s emulator-5556 logcat -d` held 0
`FATAL EXCEPTION` and 0 `E AndroidRuntime` during the sweep.
- **APK publish.** `app-debug.apk` (18,076,412 bytes, sha256
`bb290a7f42a3b28e613098dfffea438c34a5332081cffc6a2fbc0d275c207f68`) copied to
`~/.local/share/pipelines/data/artifacts/124/1/pipelines-debug-wip-0718f5b.apk`;
`HEAD` is `0718f5b` and a streamed `curl | shasum -a 256` of
`http://10.0.0.249:8080/artifacts/124/1/pipelines-debug-wip-0718f5b.apk`
matched.
Not verified: the live brokered server (separate lane), streaming against real
OpenCode, and attachments — unchanged from the passes above. The markdown subset
is intentionally smaller than full CommonMark (no HTML, no reference links, no
nested lists, no strikethrough).
## Streaming replies (16 Oct 2026)
The live delta/streaming pass promised by the first slice. `android/` only; no new
dependency (still just the declared `material-icons-extended`), no Pipelines
server/Go/installer/Docker file touched, no run started from the app, and
`emulator-5556` only (lane A's `emulator-5554` was never addressed).
- **Turn lifecycle in the model.** `ChatStore` now owns `ChatThread.runningSince`
and one private `setRunning` transition, so a turn that begins is stamped with
the wall clock and settling clears it; `ChatThread.elapsedMillis(now)` is the one
pure derivation the indicator and its test share. `event` already appended
`text`/`reasoning` deltas to the target part and upserted tool parts, wherever the
frame's chat sits in the open order.
- **Running indicator.** The transcript's indicator shows the spinner, `Working…`
and the live elapsed time (ticked once a second, never per frame, through the
shared `formatDuration`). Its tick loop is keyed on the turn's start and stops the
moment the turn settles, and the elapsed value keeps counting across a chat
switch because it lives on the thread, not the composable.
- **Follow the stream.** The transcript hard-jumps to the newest item while a turn
runs — a fast-growing reply outruns an animation — unless the operator has
scrolled up to read; returning to the end resumes following. Consuming the list
state's `interactionSource.interactions` (`DragInteraction.Start`/`Stop`/`Cancel`)
distinguishes a user drag from the programmatic jump, so the jump never un-sticks
the view.
- **Reconnect resync.** `AppViewModel.observeConnection` re-fetches every open
chat's history whenever the socket transitions to `Connected`, after
`ChatStore.streamResumed()` settles each running thread (a still-live stream
re-asserts `running` on its next frame, so no stale `Working…` sticks). The
resync *replaces* the conversation wholesale, so a gap can neither duplicate nor
drop text.
- **Failure settle.** A server-pushed `error` frame carries no session id (the
brokered protocol cannot attribute it), so `ChatStore.streamError` settles the
sole running chat — or the active one when several are in flight — and keeps the
server's text; with nothing running it is ignored. The prompt-call failure path
already settled the turn and is unchanged.
- **Non-blocking.** Unsolicited frames reach the UI through the client's bounded
`SharedFlow` (`tryEmit` from the socket thread, `DROP_OLDEST` capacity 256), so a
slow collector never blocks the read loop; each mutation touches only its chat and
the `LazyColumn` keys limit recomposition to the changed item.
Evidence (macOS, JDK 17 target, Gradle 9.7.1,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:assembleDebug :app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the JUnit
XML totals **248 tests, 0 failures, 0 errors, 0 skipped** (new `ChatStreamTest`:
a delta sequence grows the rendered text and toggles the running indicator, the
elapsed time comes from the turn's own start and a repeated start keeps it,
`streamResumed` settles every open chat and returns them for re-fetch,
`streamError` settles the running turn with the server's text and is ignored with
nothing running).
- The debug APK was installed on `emulator-5556` only and driven with
`uiautomator dump`/`input tap` against `.stream_check/stream_stub.py` (a stdlib
`/connect` WebSocket double that streams `chat_event` frames; test scaffolding,
not the app — the deployed server still predates chat). Captures were validated
with `android/scripts/capture_png.sh -s emulator-5556`: a mid-stream reply with
the growing transcript and the indicator at `Working… · 1s`
(`chat_stream_01_early`) and `Working… · 4s` with the list followed to the newest
line (`chat_stream_02_mid`); the settled turn with the completed `bash 340ms`
tool chip, no indicator and the send control restored (`chat_stream_03_settled`);
and, after a mid-stream drag up, the transcript **staying** where the operator
left it while the turn still ran (`chat_stream_04_scrolled_up`). `adb -s
emulator-5556 logcat -d` held 0 `FATAL EXCEPTION` and 0 `E AndroidRuntime`
during the sweep.
- **APK publish.** `app-debug.apk` (18,262,465 bytes, sha256
`ef435b662e6f7e7467b5ae25b69fb24f8904334af204224aad00bfd76879a84e`) copied to
`~/.local/share/pipelines/data/artifacts/126/1/pipelines-debug-wip-d7f6500.apk`;
`curl -I http://10.0.0.249:8080/artifacts/126/1/pipelines-debug-wip-d7f6500.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18262465`, and a streamed `GET | shasum -a 256` matched.
Not verified in this pass: the live brokered server (separate lane), streaming
against real OpenCode, and attachments — unchanged. `:app:lintDebug` could not run
in this environment: the Gradle JVM reports `25.0.4.1`, a version string the AGP
8.7.2 lint (IntelliJ `JavaVersion`) rejects, so lint fails before analysing the
tree; this is environmental and unrelated to the change.
## Tool-call chips and the expandable panel (16 Oct 2026)
The tool-call surface now matches the reference chat's `_ToolCalls`/`_ToolChip`
and `_buildPanel` (research §1.3) more closely. `android/` only; no new
dependency (still just the declared `material-icons-extended`), no Pipelines
server/Go/installer/Docker file touched, no run started from the app, and
`emulator-5556` only (lane A's `emulator-5554` was never addressed).
- **Grouped chips.** A run of consecutive `tool` parts in one assistant turn is
now one `FlowRow` of compact chips (`ToolCalls`/`ToolChip`), so the turn's calls
sit together and wrap instead of each taking a full-width row. Each chip keeps
its kind icon, label (the edited file for an `edit`), `+N -M` diff stat,
duration and running spinner.
- **Overlay panel, scroll preserved.** Tapping a chip opens its INPUT/OUTPUT
panel as a `Popup` anchored to that chip, not as inline content. The former
inline panel re-flowed the transcript (a short chat visibly jumped); the popup
is outside the list layout, so opening, failing or dismissing it never moves the
conversation's scroll anchor. `ToolPanelPositionProvider` places it below the
chip, flips it above when there is no room, and keeps it inside the window
margins. The panel is dismissible by its own X or by tapping outside, and its
INPUT and OUTPUT blocks carry the shared `CodeBlock` copy action.
- **Visible failure.** An `error` tool call is now unmistakable: an
error-tinted chip with an `ErrorOutline` icon (`toolFailed`), and its panel
shows an ERROR block with the tool's error text (`ChatFormat.toolFailed`).
- **Diff cards preserved.** An `edit`-family chip still expands to the synthesised
green/red diff (`toolEditDiff`/`DiffView`), unchanged.
Evidence (macOS, Gradle 9.7.1 `--offline`, `ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:assembleDebug :app:testDebugUnitTest --offline` → `BUILD
SUCCESSFUL`; the JUnit XML totals **252 tests, 0 failures, 0 errors, 0
skipped** (new `toolFailedOnlyForTheErrorStatus`, and
`ToolPanelPositionProviderTest`: below-the-chip, flip-above and margin-clamp
placement).
- The debug APK was installed on `emulator-5556` only and driven against
`.tool_calls_check/chat_stub_tools.py` (a stdlib `/connect` WebSocket double
serving the documented `internal/protocol/chat.go` JSON; test scaffolding, not
the app). Captures were validated with `android/scripts/capture_png.sh -s
emulator-5556`: `01_tools_collapsed.png` (the completed `bash 340ms` and
`src/layout.kt +2 -2 300ms` chips grouped), `02_tools_expanded.png` (the bash
chip expanded to INPUT pretty JSON + OUTPUT monospace with the transcript behind
it unmoved — the chips keep the same on-screen position), and
`03_error_chip_collapsed.png`/`04_error_chip_expanded.png` (the failed `shell`
chip in the error container and its panel INPUT + ERROR text). Tapping outside
the panel dismissed it with the chips still in place. `adb -s emulator-5556
logcat -d` held 0 `FATAL EXCEPTION` and 0 `E AndroidRuntime` during the sweep.
- **APK publish.** `app-debug.apk` (18,262,465 bytes, sha256
`160f10ea8a2dc80364bb7f38596d50d08557ccce01f99705b93a8b9bc9216c27`) copied to
`~/.local/share/pipelines/data/artifacts/129/1/pipelines-debug-wip-d7f6500.apk`;
`curl -I http://10.0.0.249:8080/artifacts/129/1/pipelines-debug-wip-d7f6500.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18262465`, and a streamed `GET | shasum -a 256` matched.
Not verified in this pass: the live brokered server (separate lane), streaming
against real OpenCode, and attachments — unchanged from the passes above.
## Tool-call review fixes (16 Oct 2026)
Two findings from the tool-call slice review, both in `android/`, under the same
constraints as above (no new dependency beyond the declared
`material-icons-extended`, no Pipelines server/Go/installer/Docker file touched,
no run started from the app, `emulator-5556` only).
- **One elapsed derivation.** `ChatScreen.rememberElapsedMillis` re-derived the
running turn's elapsed time by subtracting the start itself, duplicating the
tested `ChatThread.elapsedMillis` and contradicting the two KDocs that claimed
the indicator shared the model's derivation. The composable now ticks a
`rememberElapsedNow(runningSince)` wall clock (once a second, and only while
the turn lives) and reads `thread.elapsedMillis(now)`, so the model and the UI
cannot drift.
- **No per-frame allocation.** `ToolCalls` keyed its open-panel `remember` on
`parts.map { it.id }`, allocating a list on every streaming recomposition. The
key is unnecessary — an id no longer among the calls simply matches nothing —
so `openId` is plain remembered state and a streaming rebuild no longer
allocates a key list.
Evidence (macOS, Gradle 9.7.1 `--offline`,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:assembleDebug :app:testDebugUnitTest --offline` → `BUILD
SUCCESSFUL`; the JUnit XML totals **252 tests, 0 failures, 0 errors, 0
skipped**.
- The rebuilt debug APK was installed on `emulator-5556` only and driven against
`.tool_calls_check/chat_stub_tools.py` and `chat_stub_error.py` (stdlib
`/connect` WebSocket doubles serving the documented `internal/protocol/chat.go`
JSON; test scaffolding, not the app). Captures were validated with
`android/scripts/capture_png.sh -s emulator-5556` into `.tool_calls_fix/`:
`01_tools_collapsed.png` (the completed `bash 340ms` and `src/layout.kt +2 -2
300ms` chips grouped), `02_tools_expanded.png` (the bash chip's INPUT pretty
JSON + OUTPUT monospace), `04_diff_card.png` (the edit chip's synthesised
green/red diff card), `03_dismissed_outside.png` (tapping outside dismissed the
panel with both chips at the same on-screen bounds), and
`05_error_chip_collapsed.png`/`06_error_chip_expanded.png` (the failed `shell`
chip in the error container, with a `Failed tool call` description, and its
panel INPUT + ERROR text). `adb -s emulator-5556 logcat -d` held 0 `FATAL
EXCEPTION` and 0 `E AndroidRuntime` during the sweep.
- **APK publish.** `app-debug.apk` (18,219,766 bytes, sha256
`b607a879ce2f2ac324fe6fa254918a456337c678abc1781bb79a05d88d539984`) copied to
`~/.local/share/pipelines/data/artifacts/129/3/pipelines-debug-wip-d7f6500.apk`;
`curl -I http://10.0.0.75:8080/artifacts/129/3/pipelines-debug-wip-d7f6500.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18219766`, and a streamed `GET | shasum -a 256` matched. This
supersedes the `129/1` publish above: it is built from the current source, so
the change is in the served artifact (a fresh rebuild can still differ in
`classes5.dex` — the reproducibility caveat recorded in review stands).
Not verified in this pass: the live brokered server (separate lane), streaming
against real OpenCode, and attachments — unchanged from the passes above.
`:app:lintDebug` still cannot run here (the Gradle JVM's `25.0.4.1` version
string is rejected by AGP 8.7.2 lint), unchanged from the slice above.
## Tool-call review fixes, second pass (16 Oct 2026)
Three findings from the tool-call slice's second review, all in `android/` under
the same constraints (no new dependency beyond the declared
`material-icons-extended`, no Pipelines server/Go/installer/Docker file touched, no
run started from the app, `emulator-5556` only).
- **A failed edit call shows its error.** The panel only rendered the diff for an
`edit`-family call, because the `diff != null` branch sat above the `failed`
check, so a *failed* edit showed no error text. The ERROR block is now emitted
whenever `toolFailed`, alongside the diff when one exists; a failed non-edit call
keeps INPUT + ERROR, and a successful edit still shows the diff alone.
- **The error message, not the partial output.** `ChatFormat.toolOutputText`
returned non-blank `state.content` before it considered `state.error`, and that
text fed the ERROR block, so a failed call carrying both showed its partial
output under the ERROR heading. The failed call's text now comes from the new
`toolErrorText`, which prefers the server's message and falls back to the output
text only when the failure carries none; `toolOutputText` is the OUTPUT
derivation again.
- **README mechanism corrected.** The follow-the-stream bullet claimed a
`snapshotFlow` on the list's scroll state; the code consumes
`listState.interactionSource.interactions` (`DragInteraction.Start`/`Stop`/`Cancel`),
as the bullet now says.
Evidence (macOS, Gradle 9.7.1, `ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:testDebugUnitTest :app:assembleDebug` → `BUILD SUCCESSFUL`; the
JUnit XML totals **253 tests, 0 failures, 0 errors, 0 skipped** (the failed-text
helper split into `toolOutputFallsBackToNoOutput` and
`toolErrorPrefersTheMessageOverPartialOutput`, which asserts the message wins over
a failed call's partial output).
- The rebuilt debug APK was installed on `emulator-5556` only and driven against
`.tool_calls_fix2/chat_stub_failed_edit.py` (the review tool stub plus a failed
`edit` call with `oldString`/`newString` and a failed `bash` call carrying both
partial output and an error; stdlib `/connect` WebSocket double, test
scaffolding, not the app). Captures were validated with
`android/scripts/capture_png.sh -s emulator-5556` into `.tool_calls_fix2/`:
`04_failed_edit_expanded.png` shows the failed edit chip's diff *and* its ERROR
block (`oldString not found in src/layout.kt`), and
`06_failed_bash_expanded.png` shows the failed bash call's INPUT + ERROR
(`exit status 2: src/nope.kt: No such file`), the error text — not the partial
output — under the ERROR heading. `uiautomator dump` confirms the same nodes;
`adb -s emulator-5556 logcat -d` held 0 `FATAL EXCEPTION` and 0 `E
AndroidRuntime` during the sweep.
- **APK publish.** `app-debug.apk` (18,219,360 bytes, sha256
`4522aa62c8a3a59033aa2cca8b7fba65267dbdde473284585eaae47f03aeda2f`) copied to
`~/.local/share/pipelines/data/artifacts/129/5/pipelines-debug-wip-d7f6500.apk`;
`curl -I http://10.0.0.249:8080/artifacts/129/5/pipelines-debug-wip-d7f6500.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18219360`, and a streamed `GET | shasum -a 256` matched. This
supersedes the `129/3` publish above: it is rebuilt from the current source, so
the fix is in the served artifact (the `classes5.dex` reproducibility caveat
recorded in review stands).
Not verified in this pass: the live brokered server (separate lane), streaming
against real OpenCode, and attachments — unchanged from the passes above.
## Edit diffs: file name, stat and large-edit summarisation (16 Oct 2026)
The edit diff card already derived its lines, but three things the task calls for
were missing or wrong. `android/` only; no new dependency (still just the declared
`material-icons-extended`), no Pipelines server/Go/installer/Docker file touched,
no run started from the app, and `emulator-5556` only (lane A's `emulator-5554`
was never addressed).
- **The file name and `+N -M` are on the card, not just the chip.** The expanded
panel header showed the tool name (`edit`); it now shows the edited file (as the
chip already did) and the shared green/red `DiffStat`, so the diff names its file
and its counts wherever it is read.
- **Very large edits are summarised, not flooded.** A diff longer than
`MAX_RENDERED_DIFF_LINES` (200) kept *every* line — the >400-line fallback
rendered `old + new` in full, thousands of `Text` nodes in a scrolling `Column`
on a phone. `ChatFormat.toolEditDiff` now keeps the first 200 lines and carries
the rest in the new `ToolDiff.omitted`; `DiffView` prints
`… N more changed lines not shown` **first**, so the truncation is visible
without scrolling. The `+N -M` counts still describe the whole edit, never the
rendered prefix.
Evidence (macOS, JDK 17, Gradle 9.7.1 `--offline`,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:testDebugUnitTest :app:assembleDebug` → `BUILD SUCCESSFUL`; the
JUnit XML totals **254 tests, 0 failures, 0 errors, 0 skipped** (new
`toolEditDiffSummarisesAnOversizedEditInsteadOfRenderingEveryLine`, which
asserts the true `+250 -250` counts, the 200-line render cap and
`omitted = 300`; the small-edit test now also pins `omitted = 0`).
- The rebuilt debug APK was installed on `emulator-5556` only and driven against
`.diff_check/chat_stub_diff.py` (the `.tool_calls_check/chat_stub_tools.py`
`/connect` WebSocket double plus a 300-line edit whose intersection with the
cap must summarise; stdlib double, test scaffolding, not the app). Captures were
validated with `android/scripts/capture_png.sh -s emulator-5556`:
`03_diff_small.png` shows the small edit card — `src/layout.kt +2 -2 300ms`,
then red `- val gap = 4.dp` / `- val inset = 1.dp` and green
`+ val gap = 6.dp` / `+ val inset = 2.dp` in monospace — and
`05_diff_summarised.png` shows `src/big.kt +100 -100 150ms` over
`… 200 more changed lines not shown` and the interleaved context/`-`/`+` lines.
`uiautomator dump` confirms the same nodes; `adb -s emulator-5556 logcat -d`
held 0 `FATAL EXCEPTION` and 0 `E AndroidRuntime` during the sweep.
- **APK publish.** `app-debug.apk` (18,220,501 bytes, sha256
`7cfca9c40361d4f1871bc61da20aec8c918637f8e085b8eb534d134b3cb8fe00`) copied to
`~/.local/share/pipelines/data/artifacts/133/1/pipelines-debug-wip-291cec2.apk`;
`curl -I http://10.0.0.75:8080/artifacts/133/1/pipelines-debug-wip-291cec2.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18220501`, and a streamed `GET | shasum -a 256` matched.
Not verified in this pass: the live brokered server (separate lane), streaming
against real OpenCode, and attachments — unchanged from the passes above.
`:app:lintDebug` still cannot run here (the Gradle JVM's `25.0.4.1` version
string is rejected by AGP 8.7.2 lint), unchanged from the slices above.
## Stopping a running turn (16 Oct 2026)
The composer already swapped its send control for a red `Icons.stop` while a turn
ran and `AppViewModel.stopChat` already sent `chat_interrupt`; the slice was
missing the proof the task asks for — a unit test pinning the interrupt frame —
so this pass adds that seam and the on-device capture. `android/` only; no new
dependency (still just the declared `material-icons-extended`), no Pipelines
server/Go/installer/Docker file touched, no run started from the app, and
`emulator-5556` only (lane A's `emulator-5554` was never addressed).
- **One interrupt frame.** `ChatProtocol.interruptRequest(sessionId)` builds the
single `chat_interrupt` frame (a `ChatQuery` carrying the session id);
`PipelinesRepository.chatInterrupt` sends it, so the wire shape is no longer
constructed inline where only production can see it.
- **The stopped state is honest.** On a successful interrupt the thread settles
(`running = false`, no error) and the composer's send control returns; only a
failing call (or a server-pushed error frame) sets the conversation's error, so
a stop the server accepted is never shown as a failure.
Evidence (macOS, JDK 17, Gradle 9.7.1 `--offline`,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:assembleDebug :app:testDebugUnitTest --offline` → `BUILD
SUCCESSFUL`; the JUnit XML totals **255 tests, 0 failures, 0 errors, 0
skipped** (new `chatInterruptRequestCarriesTheRunningSession`, which asserts the
frame the stop control sends is `chat_interrupt` for the running session and
survives the client's JSON round-trip).
- The debug APK was installed on `emulator-5556` only and driven against
`.stop_check/chat_stub_hold.py` (a stdlib `/connect` WebSocket double that holds
the turn open until `chat_interrupt`; test scaffolding, not the app) with
`uiautomator dump`/`input tap`; captures validated with
`android/scripts/capture_png.sh -s emulator-5556`:
`stop_control_running.png` shows the running turn (`Working… · 11s`) with the
composer's send control replaced by the red stop control (bottom-right, in thumb
reach) and the top-bar stop action; `stop_control_stopped.png` shows the same
chat after the stop was pressed — the indicator gone, the send control back, and
no error text (the server acknowledged the interrupt). The stub log recorded
exactly one `chat_interrupt`. `adb -s emulator-5556 logcat -d` held 0
`FATAL EXCEPTION` and 0 `E AndroidRuntime` during the sweep.
- **APK publish.** `app-debug.apk` (18,240,566 bytes, sha256
`56abfb2c59a9c09fabbe32d7de4f0164cdc852cece4b7df3655dd0c233256248`) copied to
`~/.local/share/pipelines/data/artifacts/135/1/pipelines-debug-wip-e2f306b.apk`;
`curl -I http://10.0.0.249:8080/artifacts/135/1/pipelines-debug-wip-e2f306b.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18240566`, and a streamed `GET | shasum -a 256` matched.
### Follow-up: one tested composer action (16 Oct 2026, run 143)
The stop control was still chosen by an inline `if (thread.running)` in the
composer, and the text field's keyboard send action only checked `canSend`, so a
prompt could still be sent from the IME while a turn was in flight even though the
visible control had become stop. `ChatFormat.composerAction(thread)`
(`ComposerAction.Send`/`Stop`) is now the single pure derivation the trailing
button and the keyboard action both read, so the two controls can no longer
disagree; `ChatFormatTest.composerControlIsStopWhileARunIsInFlightAndSendOtherwise`
covers it. `android/` only; no new dependency.
- Re-verified: `gradle :app:assembleDebug :app:testDebugUnitTest --offline` →
`BUILD SUCCESSFUL`, **266 tests, 0 failures** (the new composer-action case).
- **APK publish.** `app/build/outputs/apk/debug/app-debug.apk` (18,249,033 bytes,
sha256 `a9ce0cc8829513ee37fa5abaafa765307d5574f7cbd2b9cf0bc32392d0c1461e`) copied
to `~/.local/share/pipelines/data/artifacts/143/1/pipelines-debug-wip-609721d.apk`.
`curl -I http://10.0.0.249:8080/artifacts/143/1/pipelines-debug-wip-609721d.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18249033`; a streamed `GET | shasum -a 256` matched.
- Not driven on a device in this pass: the constraint that the stop control be
exercised on an emulator only conflicts with this run's device note that only the
operator's Pixel (adb serial `58281FDCG000JF`) is available and no emulator may be
run, so the evidence here is the unit tests and the build rather than a fresh
screenshot. The earlier `emulator-5556` captures
(`.stop_check/stop_control_running.png`, `.stop_check/stop_control_stopped.png`)
still show the running/stopped control states.
Not verified in this pass: the live brokered server (separate lane), streaming
against real OpenCode, and attachments — unchanged from the passes above.
## Approvals in the conversation, answered in place (16 Oct 2026)
The brokered protocol already carried `chat_permission`, but the phone only showed
it as a bar above the composer and removed it the moment it was answered. This
pass makes a pushed approval a card in the conversation: the reference app's amber
risk framing, once/always/reject actions wired to `chat_reply`, an in-place settle
on answer, and a resolved state for a request the server reports as already
settled. `android/` only; no new dependency (still just the declared
`material-icons-extended`), no Pipelines server/Go/installer/Docker file touched,
no run started from the app, and `emulator-5556` only (lane A's `emulator-5554`
was never addressed).
- **The card is in the transcript.** `ApprovalCardItem` is the transcript's last
item, so the request sits with the conversation rather than floating above the
composer. It shows the action (`Approve edit`), the affected resources in
monospace, the amber `RISK REVIEW` panel carrying the server's risk summary
(falling back to a neutral sentence naming the action when the server sends
none), and `Allow once` / `Always allow` / `Reject`. The amber `tertiary` role
at 12% fills the review panel and its shield glyph, and at 50% outlines a
pending card — the same amber `shield_outlined` framing the reference app uses.
Geometry reuses the existing chat tokens; the only new constants are the two
alpha strengths.
- **Findable without scrolling the whole chat.** The conversation's top bar shows
a gold `PanTool` "Waiting for your approval" action while a request is open;
tapping it jumps the transcript to the card, and the same glyph marks the chat's
chip in the open-chat strip. A newly arrived request is also scrolled into view
by the existing bottom-follow, and the running indicator stands down while the
turn waits (the clock would otherwise tick on work that is not happening).
- **Answered in place.** `ChatStore.answerPermission` records the decision
optimistically, so the card settles to `Allowed once` / `Always allowed` /
`Rejected` and drops its actions instead of disappearing; a failed `chat_reply`
reopens the same request (`permissionReplyFailed`) with the error, so a decision
the server never received is never shown as accepted. `ChatProtocol.replyRequest`
is the one builder `PipelinesRepository.chatReply` sends, so the card's actions
and the wire frame cannot drift.
- **Already resolved is honest.** `ChatPermissionFrame` gained optional `resolved`
and `decision` fields. A frame for a request the server reports as settled
renders as `Rejected`/`Always allowed`/`Already resolved` with no controls, so a
stale once/always/reject is never offered for a closed request; a frame for a
new request replaces a settled card. Those fields are the additive contract the
server sends when it reports an already-settled request (both are omitted by an
older peer, which simply leaves every request pending).
Evidence (macOS, JDK 17, Gradle 9.7.1 `--offline`,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:testDebugUnitTest :app:assembleDebug` → `BUILD SUCCESSFUL`; the
JUnit XML totals **267 tests, 0 failures, 0 errors, 0 skipped** (new
`ChatApprovalTest`: a pushed frame yields a pending card with the request's
action/resources/risk and its three actions, answering once/always/reject settles
the card in place, a server-resolved frame offers no actions, a failed reply
reopens the request, and the missing-summary fallback; new
`ChatProtocolTest.chatPermissionFrameCarriesTheServerResolution`; the reply
builder is asserted for `once`, `always` and `reject` through one shared
encode/decode round trip, so no decision is asserted more weakly than another).
- The rebuilt debug APK was driven on `emulator-5556` against
`.approval_check/chat_stub_approval.py` (a stdlib `/connect` WebSocket double
that pushes a pending `chat_permission` after a prompt and a server-resolved one
for a second session; test scaffolding, not the app). Fresh captures this pass,
validated with `android/scripts/capture_png.sh -s emulator-5556` into
`~/.local/share/pipelines/data/artifacts/147/3/`:
`01_approval_pending.png` (the `Approve edit` card with `src/layout.kt`, the
amber `RISK REVIEW` panel and the three actions, the top-bar pan-tool and the
chat-chip marker) and `02_approval_answered.png` (the same card settled to
`Always allowed`, no actions, the amber risk panel retired). The stub log
recorded the `chat_reply` with `decision=always request=req_pending_1`. The
already-resolved path was reached too — the `Already resolved` session rendered
`Rejected` with the server's note and no controls — but `emulator-5556` shut
down before that frame could be captured, and it is not restarted here, so its
evidence is the `uiautomator` dump (`uiautomator_server_resolved.xml`) rather
than a second screenshot.
- **APK publish.** `app-debug.apk` (18,109,180 bytes, sha256
`5f58ac6e92a7fbeb2fd023b5604fd7876e9d2546cc7cadf3d871aa7a4b7cce43`) copied to
`~/.local/share/pipelines/data/artifacts/147/3/pipelines-debug-wip-305714c.apk`
(`305714c` = `git rev-parse --short HEAD`); the running artifacts server serves
`curl -I http://10.0.0.75:8080/artifacts/147/3/pipelines-debug-wip-305714c.apk`
as `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18109180`, and a streamed `GET | shasum -a 256` matched.
Not verified in this pass: the live brokered server (separate lane), streaming
against real OpenCode, and attachments — unchanged from the passes above. The
`resolved`/`decision` frame fields are the additive contract the server must send
when it reports an already-settled request; the live server does not emit them
yet, so only the unit test and the stub exercise that path. `:app:lintDebug` still
cannot run here (the Gradle JVM's version string is rejected by AGP 8.7.2 lint),
unchanged from the slices above. `emulator-5556` — this lane's standing device,
already running when the pass began and never started or restarted here — shut
down after the second capture, so the resolved frame was confirmed from the
accessibility tree rather than a screenshot. The run's device note (all device work
through the attached Pixel, no emulator) conflicts with the task constraint
(emulator only, never install on the person's device); this pass resolved it by
using the already-running emulator and never installing on the Pixel.