Add the Chat destination and hold several conversations at once
Entry point: the floating destination pill gains a Chat icon between Runs and Settings; it stays a single non-wrapping Row of 48dp targets using the named DESTINATION_ITEM_SIZE/DESTINATION_ITEM_GAP tokens, clear of the existing 88dp reserve, so it stays narrow however many destinations it holds. Protocol/transport: new data/protocol/Chat.kt mirrors the brokered chat wire shapes; Message gains the optional chat_* payloads, PipelinesClient forwards unsolicited frames (chat_event/chat_permission) to a new events flow instead of dropping them, and PipelinesRepository exposes the typed chat calls (sessions, create, messages, prompt, interrupt, reply). State: ui/chat/ChatStore.kt is an Android-free multi-chat holder; every open chat keeps its own conversation, running flag, composer draft and scroll position, open/activate report when history must be re-synced so a running session refreshes on return instead of showing a stale copy, and busy/read-only sessions refuse writes. Surface: ui/chat/ChatScreen.kt lists the server's sessions with running/busy/ read-only status and an open-chat strip to switch between conversations (chip X closes only that chat); the conversation is a bottom-anchored transcript of user bubbles, reasoning, assistant text and tool-call chips that expand to INPUT (pretty JSON)/OUTPUT (monospace), edit-family calls render a diff card derived from oldString/newString, and pending chat_permission frames surface an approval bar answered via chat_reply. New chat creates and opens a session. The manifest sets windowSoftInputMode=adjustResize for the composer. Tests: ChatProtocolTest, ChatFormatTest and MultiChatStateTest cover the wire shapes, formatting and the multi-chat model (switching preserves each conversation, a running session re-syncs on return, per-chat drafts/scroll, busy read-only, background events land on their chat). README documents the slice and its evidence.
This commit is contained in:
@@ -2227,3 +2227,135 @@ native 2208x1840 @420 at the end.
|
||||
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 17928873`.
|
||||
|
||||
|
||||
## 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.
|
||||
|
||||
Reference in New Issue
Block a user