Repository navigation
feat(mobile): port the restructured native-chat turn status and live tool progress - #18761
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change centralizes native chat tool activity and turn-status logic in shared modules. Desktop components use the shared helpers. Mobile chat adds structured session lanes, per-turn status rows, expandable tool runs, consolidated prompt handling, and selectable text. The authenticated mobile socket now updates client capabilities through the channel. Tests cover shared utilities, mobile rendering, timing, disclosure, session wiring, and capability updates. Merge Risk: 🔵 Low · up to Mobile native chat now shows live turn status and tool progress, but a live turn settling may briefly hide its status row. This is a bounded presentation issue that should be addressed before or shortly after merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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.
Important
The turn-timing re-key that fixes the mid-turn clock restart reads a stale ref, so the restart can still happen on mobile.
Reviewed changes
- Shared turn-status module —
src/shared/native-chat-turn-status.tslifts duration formatting, label selection, the turn-timing state machine, and the active/settled split out of the renderer. - Shared tool-activity module —
src/shared/native-chat-tool-activity.tscentralizes command-tool classification, the running-tool descriptor/label, and running-call selection. - Desktop —
NativeChatWorkingStatus,NativeChatToolRun, anduse-native-chat-turn-statusnow consume the shared modules with unchanged strings and i18n keys. - Mobile — new per-turn "Thinking / Working for N / Worked for N" row, a live "Running …" tool row with terminal/wrench glyph, and turn-disclosure state.
- Long-press selection — headings, quotes, code blocks, list items, and table cells are now
selectable. - max-lines splits — the tool-run subtree, prompt card, session-lane wiring, and turn-disclosure state each move to their own module.
ℹ️ Nitpicks
describeActiveToolCallreturnsisCommand, but bothToolRunimplementations pick the glyph by re-callingisCommandToolName(activeCall.name)— the field is only exercised by tests (mobile/src/session/MobileNativeChatToolRun.tsx:198,src/renderer/src/components/native-chat/NativeChatToolRun.tsx:164).use-mobile-native-chat-turn-disclosure.tsdeletes stale toggle handlers inside auseMemo(a render-phase ref mutation). Idempotent so safe, but it's a side effect in what is nominally a pure computation.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Root cause found while chasing the mobile screenshots — and it is bigger than this PRTwo emulator runs reported the new turn UI as "missing on structured Codex". Both were the wrong lane, and chasing why turned up a real product bug that this PR now fixes ( The bug
authenticatedSocket.clientCapabilities = clientCapabilities // runtime-rpc-websocket-dispatch.ts:144but the socket handed to the dispatcher defined that property with a getter only: const socket = { ws, connectionId, device, get clientCapabilities() { return channel.clientCapabilities }, transport }ES modules are strict, so that assignment throws: The RPC answered Why nobody noticed
Blast radius — the whole feature, not just this UI
The single line that cracked it, in the Metro/JS console: The fixA Scope flag for the merge decisionThis is broader than "port the UI to mobile" and deserves a conscious call. Two reasons it is here rather than in its own PR: the ported UI is unreachable without it, so this PR could not otherwise be verified on a device at all; and it was found only because the QA for this PR kept failing. Happy to split it out if you would rather it land on its own — say the word. Mobile emulator screenshots are being captured against the fixed build now and will be posted here. |
There was a problem hiding this comment.
ℹ️ The new commit is clean and correct — no new issues. This review stays non-approving because the turn-timing re-key finding from the prior review (
use-mobile-native-chat-turn-status.ts) is still unaddressed.
Reviewed changes
- Capability RPC write-through —
AuthenticatedMobileSocket.clientCapabilitiesnow exposes a setter that writes through toE2EEChannel.clientCapabilities, soruntime.clientCapabilities.updatestops throwing aTypeErroron the previously getter-only property and capable phones stop losing their structured agent-session tabs. - Regression test — a
MobileSocketWiringtest drives the full E2EE handshake, assigns a capability set, and asserts a later request on the same connection reads the updated set through the channel.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…tool progress Mobile chat had a single static "Agent is working" row and no live tool activity, while the desktop restructure (#17597, #18705) replaced that with a per-turn status row and a running-tool label. This brings mobile to parity and puts the derivation in one place instead of two. Shared (new, pure, RN-safe — desktop uses them as i18n fallbacks, mobile directly, matching the native-chat-empty-state pattern): - `native-chat-turn-status.ts`: duration formatting, label selection, the turn-timing state machine, and the active/settled split. - `native-chat-tool-activity.ts`: command-tool classification, the running-tool label descriptor, and running-call selection. Desktop now consumes both; `NativeChatWorkingStatus`, `NativeChatToolRun` and `use-native-chat-turn-status` keep their existing behavior and strings. Mobile gains the "Thinking" / "Working for 12s" / "Worked for 3m 4s" row with a caret that discloses the turn's tool activity, the pulsing "Running npm test" row with terminal-vs-wrench glyphs, and desktop's rule that a completed turn's tool run hides behind the turn caret. The bridge lane is untouched and keeps its three-dot indicator. Headings, quotes, code, lists and table cells are now selectable. Files at their max-lines cap were split rather than bumped: the tool-run subtree, the prompt card, the session-lane wiring, and the turn-disclosure state each move to their own module.
…ranscript A streaming turn re-renders the chat list many times a second. The disclosure wiring handed every row a fresh status object and a fresh toggle closure on each of those renders, so `MobileNativeChatMessage`'s memo never held and every visible row re-rendered per tick — including settled turns that had not changed. Memoize the status selection on the timing map, and keep one stable toggle handler per turn (pruned when a turn leaves the transcript) attached only to the settled rows that can actually disclose anything. Now only the live turn's row changes identity while the agent works.
…replaced An accepted send renders as `pending-N` until the transcript echo lands under its real message id. That flips the active turn key mid-turn, and the timing reducer treated the new key as a new turn — so a turn that had reached "Working for 8s" visibly restarted at "Working for 0s". The reducer now carries the start over when the previous key names a turn that has since left the transcript, which is exactly the echo-replacement case. A genuinely new turn (the previous key still in the transcript) and a turn that had already settled both keep their own clock; both are pinned by tests. Desktop does not pass the new key and is unaffected.
Hiding a settled turn's tool run behind the turn caret (desktop parity) also made the composer's global Tools control a no-op on every completed turn: the run it wanted to expand was not rendered at all. Let that toggle override the hiding, so it still reveals every run at once the way it did before.
The previous fix carried the start forward only while the turn was still working. When the transcript echo landed after the turn had already settled, the new key inherited nothing, the settled timing was pruned with the old key, and the turn's "Worked for N" row disappeared entirely. Move the timing onto the new key instead, which covers both orderings: an in-flight turn keeps counting from its original start (and later settles against it), and an already-settled turn keeps its duration. Both orderings are pinned.
Emulator QA could not reach the structured lane (mobile's Create Tab -> Codex falls back to a terminal tab when agentSession.createSupport says unsupported), so the view's own lane wiring had no coverage — the one seam between the shared turn-timing reducer and the rendered rows. Assert what the view hands each row: the live user turn gets a status object and the three-dot indicator is gone on the structured lane; the bridge lane keeps the indicator and gets no status; a finished turn settles to a numeric duration with a toggle; and an assistant row never carries a status row of its own.
…tises `runtime.clientCapabilities.update` records the advertised set by assigning `authenticatedSocket.clientCapabilities`, but the socket handed to the dispatcher defined that property with a getter only. In strict mode the assignment throws `TypeError: Cannot set property clientCapabilities ... which has only a getter`, so the RPC answered `runtime_error` and the set was never stored. The consequence is not subtle: `supportsStructuredAgentSessions` requires the capability, so `projectSessionTabAgentStatus` removed every `agent-session` tab from a phone that had advertised it correctly. A paired phone saw ZERO tabs on a worktree whose only tab was a structured Codex chat — structured native chat was unreachable on mobile over this transport, not just missing its new turn UI. Give the socket a setter that writes through to the channel, which already owns the set for the connection's lifetime, so later requests on the same socket see it. Found while trying to capture emulator screenshots of the turn-status port: two full QA runs reported the new UI "missing" because the phone could only ever get a bridge/PTY tab.
6806bd4 to
a273672
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 0570ff60-ad6d-4675-aa8f-8c59daa75bf2
📒 Files selected for processing (7)
mobile/src/session/MobileNativeChatView.test.tsmobile/src/session/MobileNativeChatView.tsxmobile/src/session/use-mobile-native-chat-turn-disclosure.test.tsxmobile/src/session/use-mobile-native-chat-turn-disclosure.tsmobile/src/session/use-mobile-native-chat-turn-status.tssrc/main/runtime/rpc/mobile-socket-wiring.test.tssrc/main/runtime/rpc/mobile-socket-wiring.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| // its real id. That is one turn under two keys, so the clock must survive the swap. | ||
| const previousActiveTurn = useRef<{ scopeKey: string; turnKey: string } | null>(null) | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 33625
🏁 Script executed:
#!/bin/bash
set -eu
file="mobile/src/session/use-mobile-native-chat-turn-status.ts"
printf '%s\n' '--- file ---'
sed -n '1,140p' "$file"
printf '%s\n' '--- related symbols ---'
rg -n -C 3 "useMobileNativeChatTurnStatus|workedSeconds|NativeChatTurnStatus|active:" mobile/srcRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -eu
file="src/shared/native-chat-turn-status.ts"
printf '%s\n' '--- shared status state machine ---'
rg -n -C 8 "export function (reduceNativeChatTurnTiming|selectNativeChatTurnStatuses)|function (reduceNativeChatTurnTiming|selectNativeChatTurnStatuses)|workedSeconds|activeTurnKey" "$file"
printf '%s\n' '--- disclosure consumer ---'
sed -n '35,155p' mobile/src/session/use-mobile-native-chat-turn-disclosure.ts
printf '%s\n' '--- settled transition test ---'
sed -n '280,302p' mobile/src/session/MobileNativeChatView.test.tsRepository: stablyai/orca
Length of output: 11870
Keep the status row during the settled transition.
When isWorking changes to false, selectNativeChatTurnStatuses runs before the passive effect records workedSeconds. The active timing entry still has workedSeconds: null, so the selector returns active: null and the row can disappear for one frame. Use useLayoutEffect, or derive the settled status during render.
Mobile emulator screenshots — the new turn UI, on deviceiPhone 17 Pro simulator (iOS 26.5), paired local-only to an isolated dev host built from this branch at First — what the capability fix changedBefore, a phone paired to a worktree whose only tab was a structured Codex chat saw zero tabs: After, the structured tabs are listed — and the phone can now create one itself, which previously fell back to a terminal tab: 1. "Thinking" — before the turn produces output2–3. "Working for Ns" — the live clockSampled every 2s from the moment of send. The literal observed sequence, monotonically increasing, no reset when the optimistic echo was replaced by the transcript row: 4. Live tool row — terminal glyph + the running command
5. Settled "Worked for 42s" — tool run hiddenChevron points right; the grouped tool run is not rendered. 6. Tapped — turn details disclosedChevron rotates down and the run appears as Not capturedLong-press text selection — Rig hygieneOwn simulator created for this run; the peer |
There was a problem hiding this comment.
✅ No new issues found. The prior review's stale-ref re-key finding is fixed, and the per-surface scope isolation it motivated is clean and well-tested.
Reviewed changes
- Stale-ref re-key fixed —
useMobileNativeChatTurnStatusnow capturespreviousActiveTurn.currentinto a localpreviousActiveTurnKeybeforesetScopedTiming, so the functional updater closes over the previous effect run's key instead of a ref that is reassigned in the same effect. The optimistic-echo clock restart no longer depends on React's eager-state scheduling. - Per-surface scope isolation — a
scopeKey(thehost\0worktree\0tabsurface id) now scopes both turn timing and disclosure state, so a running clock and the re-key path no longer bleed across chat surfaces when switching tabs. - Pre-user history excluded —
activeTurnIsWorkingnow only treats the unanchored branch as the live turn whenactiveTurnKey === MOBILE_UNANCHORED_TURN_KEY, so assistant rows before the first user message stop reading as part of the live turn. - Hook-level coverage —
use-mobile-native-chat-turn-disclosure.test.tsxdrives the real hook throughreact-test-renderer(not just the pure reducer) and pins scope isolation, stable toggle handlers, and the 128-turn disclosure cap;MobileNativeChatView.test.tspins the lane wiring at the view level.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Builds on the scope-isolation fix: that kept (and extended) a ref that is written during render — once to memoize a per-turn handler, once to prune dead turns, once to reset on a scope change. React Doctor's "Ref mutated during render" is what CI's `check:react-doctor:changed` was failing on (x2), and on mobile it is a real hazard rather than a style note: react-freeze discards renders, and a discarded render would leave the cache mutated. Pass the settled turn's key down the row instead and let it call one stable handler with it. That preserves both properties the cache was bought for — per scope isolation, and identity stability so a streaming transcript does not defeat the row's memo — with no ref writes and no pruning to get wrong. The scope-keyed expanded set and the 128-turn cap are untouched; their tests move to the new contract and one now pins handler identity across a re-render. Note for future changes here: `check:code-quality:changed` does NOT cover this. CI additionally runs the standalone react-doctor CLI, which has rules the oxlint plugin config does not enable.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Dropped the per-turn handler ref —
use-mobile-native-chat-turn-disclosureno longer caches a() => voidclosure per turn in a ref. It now exposes one stableonToggleTurn(turnKey)and carries the turn id as aturnKeyfield on each settled row, eliminating the render-phase ref mutation flagged in the prior review. - Row invokes the shared handler with its own key —
MobileNativeChatMessagewraps the stableonToggleTurnin() => onToggleTurn(turnKey)only for settled turns (a fresh closure per tap surface, but never on the streaming hot path, so the message-row memo is preserved). - Tests re-pinned on the new shape — the disclosure-hook and view tests now assert
turnKeystability andonToggleTurnhandler identity across re-renders, and drive taps viaonToggleTurn(row.turnKey).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
The shared constants are desktop's i18n fallback and mobile's actually-rendered string. If one changes without the other, desktop keeps rendering en.json while mobile renders the constant — and nothing fails, because a fallback is only used when the key is missing. That silent divergence is the exact thing the shared module exists to prevent, and it is now reachable precisely because these strings are runtime-required rather than statically extracted. Assert every key in both shared copy objects matches en.json byte for byte, plus the interpolation placeholders the catalog interpolates on.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Shipped the native-chat translations —
fix: ship native chat status translationsadds the fivestatuskeys (responding,thinking,toggleDetails,workedFor,workingFor) and sixtoolkeys (countN,countOne,runningCommand,runningNamed,runningNamedPreview,runningPreview) that the restructured desktop components now reference. Each value matches the correspondingNATIVE_CHAT_TURN_STATUS_COPY/NATIVE_CHAT_TOOL_ACTIVITY_COPYfallback string exactly, so the English output is unchanged while the keys become localizable.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Pinned the shared copy to the English catalog —
test(native-chat): pin the shared copy against the English catalogaddsnative-chat-shared-copy-matches-catalog.test.ts, which asserts everyNATIVE_CHAT_TURN_STATUS_COPY/NATIVE_CHAT_TOOL_ACTIVITY_COPYentry is byte-identical toen.jsonand that the interpolation placeholders stay in place. This makes the desktop/mobile drift it guards against fail loudly instead of silently, and the values currently match.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: c56065b3-5224-4177-8c60-6e522efd39c4
📒 Files selected for processing (1)
src/renderer/src/components/native-chat/native-chat-shared-copy-matches-catalog.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{toolName}}') | ||
| expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{preview}}') |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert the placeholder in runningNamed.
The test covers runningNamedPreview, but not NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamed. src/renderer/src/components/native-chat/NativeChatToolRun.tsx:25-35 also renders this key with toolName. If both the shared constant and en.json lose {{toolName}}, the equality checks still pass and the label omits the tool name.
Proposed test addition
expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{toolName}}')
expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{preview}}')
+ expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamed).toContain('{{toolName}}')📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{toolName}}') | |
| expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{preview}}') | |
| expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{toolName}}') | |
| expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{preview}}') | |
| expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamed).toContain('{{toolName}}') |
|
Review complete: ✅ clean / ready at Review fixes and hardening:
Verification:
Exact-head-equivalent desktop evidence: No remaining in-scope blockers found. |
…tool progress (stablyai#18761) * feat(mobile): port the restructured native-chat turn status and live tool progress Mobile chat had a single static "Agent is working" row and no live tool activity, while the desktop restructure (stablyai#17597, stablyai#18705) replaced that with a per-turn status row and a running-tool label. This brings mobile to parity and puts the derivation in one place instead of two. Shared (new, pure, RN-safe — desktop uses them as i18n fallbacks, mobile directly, matching the native-chat-empty-state pattern): - `native-chat-turn-status.ts`: duration formatting, label selection, the turn-timing state machine, and the active/settled split. - `native-chat-tool-activity.ts`: command-tool classification, the running-tool label descriptor, and running-call selection. Desktop now consumes both; `NativeChatWorkingStatus`, `NativeChatToolRun` and `use-native-chat-turn-status` keep their existing behavior and strings. Mobile gains the "Thinking" / "Working for 12s" / "Worked for 3m 4s" row with a caret that discloses the turn's tool activity, the pulsing "Running npm test" row with terminal-vs-wrench glyphs, and desktop's rule that a completed turn's tool run hides behind the turn caret. The bridge lane is untouched and keeps its three-dot indicator. Headings, quotes, code, lists and table cells are now selectable. Files at their max-lines cap were split rather than bumped: the tool-run subtree, the prompt card, the session-lane wiring, and the turn-disclosure state each move to their own module. * perf(mobile): stop the turn-status rows from re-rendering the whole transcript A streaming turn re-renders the chat list many times a second. The disclosure wiring handed every row a fresh status object and a fresh toggle closure on each of those renders, so `MobileNativeChatMessage`'s memo never held and every visible row re-rendered per tick — including settled turns that had not changed. Memoize the status selection on the timing map, and keep one stable toggle handler per turn (pruned when a turn leaves the transcript) attached only to the settled rows that can actually disclose anything. Now only the live turn's row changes identity while the agent works. * fix(mobile): keep the turn clock running when the optimistic echo is replaced An accepted send renders as `pending-N` until the transcript echo lands under its real message id. That flips the active turn key mid-turn, and the timing reducer treated the new key as a new turn — so a turn that had reached "Working for 8s" visibly restarted at "Working for 0s". The reducer now carries the start over when the previous key names a turn that has since left the transcript, which is exactly the echo-replacement case. A genuinely new turn (the previous key still in the transcript) and a turn that had already settled both keep their own clock; both are pinned by tests. Desktop does not pass the new key and is unaffected. * fix(mobile): keep the Tools toggle working on settled turns Hiding a settled turn's tool run behind the turn caret (desktop parity) also made the composer's global Tools control a no-op on every completed turn: the run it wanted to expand was not rendered at all. Let that toggle override the hiding, so it still reveals every run at once the way it did before. * fix(mobile): re-key the turn timing instead of only carrying its start The previous fix carried the start forward only while the turn was still working. When the transcript echo landed after the turn had already settled, the new key inherited nothing, the settled timing was pruned with the old key, and the turn's "Worked for N" row disappeared entirely. Move the timing onto the new key instead, which covers both orderings: an in-flight turn keeps counting from its original start (and later settles against it), and an already-settled turn keeps its duration. Both orderings are pinned. * test(mobile): pin the structured turn-status wiring at the view level Emulator QA could not reach the structured lane (mobile's Create Tab -> Codex falls back to a terminal tab when agentSession.createSupport says unsupported), so the view's own lane wiring had no coverage — the one seam between the shared turn-timing reducer and the rendered rows. Assert what the view hands each row: the live user turn gets a status object and the three-dot indicator is gone on the structured lane; the bridge lane keeps the indicator and gets no status; a finished turn settles to a numeric duration with a toggle; and an assistant row never carries a status row of its own. * fix(mobile): isolate structured chat turn state * fix(mobile): let the capability RPC actually store what a phone advertises `runtime.clientCapabilities.update` records the advertised set by assigning `authenticatedSocket.clientCapabilities`, but the socket handed to the dispatcher defined that property with a getter only. In strict mode the assignment throws `TypeError: Cannot set property clientCapabilities ... which has only a getter`, so the RPC answered `runtime_error` and the set was never stored. The consequence is not subtle: `supportsStructuredAgentSessions` requires the capability, so `projectSessionTabAgentStatus` removed every `agent-session` tab from a phone that had advertised it correctly. A paired phone saw ZERO tabs on a worktree whose only tab was a structured Codex chat — structured native chat was unreachable on mobile over this transport, not just missing its new turn UI. Give the socket a setter that writes through to the channel, which already owns the set for the connection's lifetime, so later requests on the same socket see it. Found while trying to capture emulator screenshots of the turn-status port: two full QA runs reported the new UI "missing" because the phone could only ever get a bridge/PTY tab. * fix(mobile): carry the turn key instead of caching a handler in a ref Builds on the scope-isolation fix: that kept (and extended) a ref that is written during render — once to memoize a per-turn handler, once to prune dead turns, once to reset on a scope change. React Doctor's "Ref mutated during render" is what CI's `check:react-doctor:changed` was failing on (x2), and on mobile it is a real hazard rather than a style note: react-freeze discards renders, and a discarded render would leave the cache mutated. Pass the settled turn's key down the row instead and let it call one stable handler with it. That preserves both properties the cache was bought for — per scope isolation, and identity stability so a streaming transcript does not defeat the row's memo — with no ref writes and no pruning to get wrong. The scope-keyed expanded set and the 128-turn cap are untouched; their tests move to the new contract and one now pins handler identity across a re-render. Note for future changes here: `check:code-quality:changed` does NOT cover this. CI additionally runs the standalone react-doctor CLI, which has rules the oxlint plugin config does not enable. * fix: ship native chat status translations * test(native-chat): pin the shared copy against the English catalog The shared constants are desktop's i18n fallback and mobile's actually-rendered string. If one changes without the other, desktop keeps rendering en.json while mobile renders the constant — and nothing fails, because a fallback is only used when the key is missing. That silent divergence is the exact thing the shared module exists to prevent, and it is now reachable precisely because these strings are runtime-required rather than statically extracted. Assert every key in both shared copy objects matches en.json byte for byte, plus the interpolation placeholders the catalog interpolates on. --------- Co-authored-by: Merge Sim <sim@local>











What and why
Desktop native chat was restructured to show per-turn progress (#17597, #18705): a status row under each user message and a live "Running …" row while a tool executes. Mobile never got any of it — it had one static
"Agent is working"string and no live tool activity at all. This ports that UI to mobile and, in the process, puts the derivation in one place instead of two.Dedup: two new shared modules
Mobile already imports the desktop-shared tree by plain relative path and Metro already watches
src/shared, so this needed no config change — just the pure logic lifted out of the renderer:src/shared/native-chat-turn-status.ts— duration formatting, label selection, the turn-timing state machine, active/settled split.src/shared/native-chat-tool-activity.ts— command-tool classification, the running-tool label descriptor, running-call selection.Both follow the existing
native-chat-empty-state.tspattern: desktop passes the shared string as its i18n fallback, mobile (which has no i18n) uses it directly, so the two surfaces can't drift.The components themselves are deliberately not shared — the renderer pulls
@/i18n/i18n,lucide-react(vs mobile'slucide-react-native), Tailwind classNames and DOM elements, and desktop'suseNowis window-visibility-gated and not RN-safe. Each platform keeps its own primitives and its own clock.Desktop
Behavior-identical.
NativeChatWorkingStatus,NativeChatToolRunanduse-native-chat-turn-statusnow consume the shared modules; every existing string and i18n key is unchanged.Mobile
Three bugs found and fixed during the port
pending-Nuntil the transcript replaces it under its real id; that flipped the turn key, so "Working for 8s" jumped back to "0s" — and when the swap landed after the turn settled, the "Worked for N" row vanished entirely. The timing is now re-keyed across the swap; both orderings are pinned by tests.max-lines
Four files were at or over their cap (
use-mobile-native-chat-controller.tssat at exactly 300, so any addition broke it). They were split, never bumped: the tool-run subtree, the prompt card, the session-lane wiring, and the turn-disclosure state each moved to their own module.Verification
pnpm tcclean; 1047 desktop/shared tests; 4099 mobile tests; changed-code quality gate green; both lockfiles untouched.SquareTerminal+ "Running …" / settled "Worked for 7s" witharia-label="Toggle turn details"/ caret disclosure with children collapsed / bridge lane three-dot / duration formats. Provenance proven: the running renderer served these shared modules (/@fs200 inside the worktree, 403 outside).Mobile device QA — done, screenshots in the comments
Captured on an iPhone 17 Pro simulator paired to an isolated host built from this branch: Thinking → Working for 15s/20s/25s/30s/34s/39s (sampled every 2s, monotonic) → live
Running /bin/zsh -lc '…'with the terminal glyph → settledWorked for 42swith the tool run hidden → tapped to disclose. The lane was verified as a realagent-session"Codex Chat" tab, not the bridge fallback.Getting there required the capability fix above: two earlier QA runs reported the UI "missing" because the phone could only ever obtain a bridge/PTY tab. Long-press text selection is not exercised —
orca emulator gesturehas no long-press primitive.The view-level lane wiring is also pinned by tests (what the view hands each row, in both lanes), since that seam is what the earlier runs kept mis-attributing.
Known gap
Plain-paragraph long-press selection is not included. Adding it edits an index-keyed line, which trips
react-doctor(no-array-index-as-key)on the changed-lines gate — and no inline suppression works, because the disable directive is itself a new line that the plugin-less config then reports as an unused directive. The index key is correct there (a positional re-parse of one markdown string; a content key would remount every block on each streaming tick). Fixing it needs either aconfig/oxlint-react-doctor.jsonoverride or a separate commit restructuring that line — repo-wide lint policy, so it is left out deliberately.