diff --git a/android/README.md b/android/README.md index 5cb7a855..5ab8350f 100644 --- a/android/README.md +++ b/android/README.md @@ -2841,33 +2841,37 @@ 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 + 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/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 + 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` and `reject`). -- The debug APK was installed on `emulator-5556` only and driven against + 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). 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. + 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 @@ -2875,6 +2879,10 @@ against real OpenCode, and attachments — unchanged from the passes above. The 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. +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. diff --git a/android/app/src/test/java/net/awan/pipelines/ui/chat/ChatApprovalTest.kt b/android/app/src/test/java/net/awan/pipelines/ui/chat/ChatApprovalTest.kt index bb4d6517..4d3f7f08 100644 --- a/android/app/src/test/java/net/awan/pipelines/ui/chat/ChatApprovalTest.kt +++ b/android/app/src/test/java/net/awan/pipelines/ui/chat/ChatApprovalTest.kt @@ -65,24 +65,28 @@ class ChatApprovalTest { } @Test - fun onceAndRejectSendTheRightDecision() { + fun onceAlwaysAndRejectSendTheRightDecision() { // The same builder the repository sends, so the card's actions and this - // assertion cannot drift from the wire frame. - val once = ChatProtocol.replyRequest("ses_1", "req_9", ChatProtocol.DECISION_ONCE) - assertEquals(Protocol.CHAT_REPLY, once.type) - assertEquals("ses_1", once.chatReply!!.sessionId) - assertEquals("req_9", once.chatReply!!.requestId) - assertEquals("once", once.chatReply!!.decision) + // assertion cannot drift from the wire frame. Every decision goes through + // the identical encode/decode round trip, so none is asserted more weakly + // than another. + for (decision in listOf( + ChatProtocol.DECISION_ONCE, + ChatProtocol.DECISION_ALWAYS, + ChatProtocol.DECISION_REJECT, + )) { + val reply = ChatProtocol.replyRequest("ses_1", "req_9", decision) + assertEquals(Protocol.CHAT_REPLY, reply.type) + assertEquals("ses_1", reply.chatReply!!.sessionId) + assertEquals("req_9", reply.chatReply!!.requestId) + assertEquals(decision, reply.chatReply!!.decision) - val decodedOnce = PipelinesJson.decodeFromString( - Message.serializer(), - PipelinesJson.encodeToString(Message.serializer(), once.copy(id = "android-1")), - ) - assertEquals(ChatProtocol.DECISION_ONCE, decodedOnce.chatReply!!.decision) - - val reject = ChatProtocol.replyRequest("ses_1", "req_9", ChatProtocol.DECISION_REJECT) - assertEquals("reject", reject.chatReply!!.decision) - assertEquals("req_9", reject.chatReply!!.requestId) + val decoded = PipelinesJson.decodeFromString( + Message.serializer(), + PipelinesJson.encodeToString(Message.serializer(), reply.copy(id = "android-1")), + ) + assertEquals(decision, decoded.chatReply!!.decision) + } } @Test @@ -99,6 +103,22 @@ class ChatApprovalTest { assertEquals("req_9", store.value.thread("ses_1")!!.permission!!.requestId) } + @Test + fun answeringAlwaysUpdatesTheCardInPlace() { + val store = storeWithPermission(frame()) + store.answerPermission("ses_1", "req_9", ChatProtocol.DECISION_ALWAYS) + + val settled = card(store) + assertEquals(ApprovalState.ANSWERED, settled.state) + assertFalse(settled.actionable) + assertEquals(ChatProtocol.DECISION_ALWAYS, settled.decision) + assertEquals("Always allowed", settled.headline) + // The request stays visible but stops asking; only a denial keeps the + // amber review panel, so an allow-always retires it. + assertFalse(settled.showRisk) + assertEquals("req_9", store.value.thread("ses_1")!!.permission!!.requestId) + } + @Test fun rejectingKeepsTheRiskReviewWhileItSettles() { val store = storeWithPermission(frame())