Show pushed approvals as in-place chat cards

Render a server-pushed chat_permission as an approval card in the
transcript instead of a transient bar above the composer, matching the
reference opencode/Jarvis chat: the requested action, its resources, the
amber RISK REVIEW panel, and once/always/reject actions wired to the
server's chat_reply.

- ChatFormat: a pure approvalCard()/ApprovalCard model and one
  ChatProtocol.replyRequest() builder shared by the card's actions and
  the repository, so the wire frame and the controls cannot drift.
- ChatStore/AppViewModel: answerPermission() settles the card in place
  optimistically and survives a chat switch; a failed reply reopens the
  same request rather than showing an unacknowledged decision.
- ChatPermissionFrame gains optional resolved/decision fields so a
  request the server reports as already settled shows its verdict with
  no stale actions; a new request replaces a settled card.
- Findability: a gold PanTool top-bar action and chat-chip marker jump
  to the pending card; the running indicator stands down while waiting.
- Tests: ChatApprovalTest covers pending/answered/resolved, the reply
  builder's once/reject decisions and the missing-summary fallback;
  ChatProtocolTest covers the server-resolution frame. README records
  the 265-test/assembleDebug evidence and the emulator-5556 captures,
  and .approval_check/chat_stub_approval.py is the test double used.

android/ only; no new dependency beyond material-icons-extended; no
Pipelines server, Go, installer or Docker file touched; no run started
from the app. The live brokered server is not verified (the resolved
frame fields are an additive contract it does not emit yet).
This commit is contained in:
2026-10-16 16:12:22 +01:00
parent 78d5bd38fc
commit 609721d53b
11 changed files with 849 additions and 59 deletions
+85
View File
@@ -2766,3 +2766,88 @@ Evidence (macOS, JDK 17, Gradle 9.7.1 `--offline`,
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 **265 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/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` and `reject`).
- The debug APK was installed on `emulator-5556` only and driven 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). Captures validated with
`android/scripts/capture_png.sh -s emulator-5556`: `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),
`02_approval_answered.png` (the same card settled to `Allowed once`, no actions),
`03_approval_server_resolved.png` (a server-reported `Rejected` card with no
actions), `04_approval_findable.png` (scrolled up: the card at/below the fold,
the gold "Waiting for your approval" top-bar action present) and
`05_approval_jump.png` (tapping that action brought the card back). The stub log
recorded the `chat_reply` with `decision=once`. `adb -s emulator-5556 logcat -d`
held 0 `FATAL EXCEPTION` and 0 `E AndroidRuntime` during the sweep.
- **APK publish.** `app-debug.apk` (18,427,840 bytes, sha256
`f39a1ed7f71759f6840a9e69a117e49a9884731a94133d2902ef7ebf096c0891`) copied to
`~/.local/share/pipelines/data/artifacts/136/1/pipelines-debug-wip-78d5bd3.apk`;
`curl -I http://10.0.0.249:8080/artifacts/136/1/pipelines-debug-wip-78d5bd3.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18427840`, 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. The emulator was restarted mid-pass after it shut
down; it was `emulator-5556` throughout and the attached physical device was never
driven.