Repository navigation
fix(mobile): gate native chat approval card on a paused agent (STA-3144) - #12206
Conversation
📝 WalkthroughWalkthroughUpdated 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
mobile/src/session/use-mobile-native-chat-prompts.ts (1)
22-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce this comment to one line.
The comment repeats the visible
blockedcondition across three lines. Keep only the non-obvious sticky-envelope rationale.As per coding guidelines, “Comments must be concise, limited to non-obvious information, and preferably one line.”
Proposed change
- // Both permission paths sit inside the paused gate: an approval envelope can - // outlive its answer (the host keeps it sticky), so only a waiting/blocked - // agent may surface it — never a working or done one (STA-3144). + // Approval envelopes are sticky, so surface them only while the agent is paused.Source: Coding guidelines
mobile/src/session/use-mobile-native-chat-prompts.test.ts (1)
2-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the deprecated test renderer.
React 19 deprecates
react-test-renderer. Use the project-supported React Testing Library renderer for this hook test.#!/usr/bin/env sh # Locate supported hook-test utilities and existing renderer usage. git grep -n -e 'react-test-renderer' -- mobile || true git grep -n -e '`@testing-library/`' -- mobile || true git grep -n -e 'renderHook' -- mobile || true
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 50acb949-4997-4ffc-be2c-b44cb294f8e2
📒 Files selected for processing (2)
mobile/src/session/use-mobile-native-chat-prompts.test.tsmobile/src/session/use-mobile-native-chat-prompts.ts


Summary
Fixes STA-3144 (#11928): on Orca Mobile's native chat, the tool-approval card (
Allow Bash?with Allow/Deny) was derived purely from the presence of an approval envelope inagentStatus.interactivePrompt, with no check that the agent is actually paused. Because the host deliberately keeps a real permission wait sticky, the card stayed pinned above the composer while the agent kept working and after the turn was done — on a phone there is no terminal to compare against, so a stale card was indistinguishable from a live one.The fix moves the envelope path (
parseApprovalFromStatus) inside the sameblocked && statusgate the heuristic path (detectAgentPermission) already honours, which is the documented contract inmobile-native-chat-permission.ts("only fire when the agent is actually paused"). The card now exists exactly while the agent iswaiting/blockedand dismisses on its own when the state clears. Heuristic detection still takes precedence over the envelope inside the gate, unchanged.Deliberately NOT included (per the adversarial review on the issue): client-side dismiss-on-answer. A content-keyed dismissal cannot distinguish "stale because answered" from "the same command is being asked again", and hiding a live prompt is strictly worse than showing a stale one. That needs a host-side request id and belongs in its own issue.
Screenshots
iOS Simulator (iPhone 17 Pro, dev client + mock native-chat host), driving
agentStatusthrough the states from the report:Before — card shown while the agent is working (note the working indicator + Stop button), and still shown after the turn is done:
After — a genuine approval (
waiting+ envelope) still shows the card, and flipping toworkingwith the envelope still sticky dismisses it:Testing
pnpm lintpnpm typecheckpnpm testpnpm buildRan inside
mobile/(the changed code is mobile-only; the root vitest config excludesmobile/**):pnpm typecheck,pnpm lint(oxlint),oxfmt --check src, and targeted vitest overuse-mobile-native-chat-prompts.test.ts,mobile-native-chat-permission.test.ts, anduse-mobile-native-chat-controller.test.ts— 36 tests pass. The newuse-mobile-native-chat-prompts.test.tslocks the gate down: no card forworking/done/missing status, card forwaiting/blocked, and heuristic-over-envelope precedence while paused. Both failing cases reproduce onmainbefore the fix.pnpm buildnot run: mobile has no build script (Expo dev client); desktop build is untouched.AI Review Report
Reviewed the gate change for: (1) suppressing legitimate approvals — the envelope now renders for exactly the
waiting/blockedstates, verified live on the simulator and by test; (2) precedence regressions —detectAgentPermissionstill wins over the envelope when both fire, covered by a new test; (3) the phantom-card path from the issue (child-driven payload re-emitting a cached envelope withstate: 'working') — now filtered by the gate; (4) the siblingquestion/askcards — untouched,askintentionally remains outside this gate because AskUserQuestion has its own dismissal protocol. Cross-platform: the change is pure TypeScript state derivation in the shared mobile app (iOS/Android identical); no shortcuts, labels, paths, shell, or Electron surfaces are touched, and desktop hosts on macOS/Linux/Windows only feed it the same serializedagentStatus.Security Audit
No new input handling, command execution, path handling, auth, secrets, dependencies, or IPC. The change narrows when an existing UI affordance renders; it strictly reduces the states in which a tap can write approval bytes (
1/Escape) into a pane — previously a stale card invited writes into a working agent's PTY, which is the riskier behavior. Parsing ofinteractivePrompt(untrusted host-provided JSON) is unchanged and already guarded.Notes
NativeChatInteractiveCardshares the missing state gate but has the pane's terminal as ground truth; if desired that is a separate, lower-severity ticket.