Skip to content

feat(mobile): port the restructured native-chat turn status and live tool progress - #18761

Merged
brennanb2025 merged 11 commits into
mainfrom
brennanb2025/port-native-chat-ui
Sep 5, 2026
Merged

brennanb2025 merged 11 commits into
mainfrom
brennanb2025/port-native-chat-ui

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1035 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1031
Prod 20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1309 $\color{#cf222e}{\Huge{\mathbf{−}}}$​464 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​845

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.ts pattern: 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's lucide-react-native), Tailwind classNames and DOM elements, and desktop's useNow is window-visibility-gated and not RN-safe. Each platform keeps its own primitives and its own clock.

Desktop

Behavior-identical. NativeChatWorkingStatus, NativeChatToolRun and use-native-chat-turn-status now consume the shared modules; every existing string and i18n key is unchanged.

Mobile

  • Per-turn row: "Thinking" (pulsing) → "Working for 12s" (ticking, hairline border) → a tappable "Worked for 3m 4s" that discloses that turn's tool activity.
  • Live tool row: pulsing "Running npm test" with a terminal glyph for shell tools, "Running Read a/b.ts" with a wrench for named tools.
  • A completed turn's tool run hides behind the turn caret (desktop parity) — with the composer's global Tools toggle still able to override it.
  • Long-press selection on headings, quotes, code blocks, list items and table cells.
  • The bridge/PTY lane is untouched and keeps its three-dot indicator.

Three bugs found and fixed during the port

  1. Turn rows re-rendered the whole transcript — fresh status objects and toggle closures every render defeated the row memo while a turn streams (~20 renders/s).
  2. The turn clock restarted mid-turn. An accepted send renders as pending-N until 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.
  3. The global Tools toggle became a no-op on settled turns once their runs were hidden.

max-lines

Four files were at or over their cap (use-mobile-native-chat-controller.ts sat 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 tc clean; 1047 desktop/shared tests; 4099 mobile tests; changed-code quality gate green; both lockfiles untouched.
  • Desktop, Electron over CDP on an isolated dev instance: 7 of 8 scenarios pass with DOM evidence and screenshots — Thinking / ticking "Working for Ns" / live SquareTerminal + "Running …" / settled "Worked for 7s" with aria-label="Toggle turn details" / caret disclosure with children collapsed / bridge lane three-dot / duration formats. Provenance proven: the running renderer served these shared modules (/@fs 200 inside the worktree, 403 outside).
  • Not exercised: the live wrench row on a named tool — Codex never exposed a named file-read tool in that session. Not claimed as passing.

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 → settled Worked for 42s with the tool run hidden → tapped to disclose. The lane was verified as a real agent-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 gesture has 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 a config/oxlint-react-doctor.json override or a separate commit restructuring that line — repo-wide lint policy, so it is left out deliberately.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The 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 6d444

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 27 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: porting restructured native-chat turn status and live tool progress to mobile.
Description check ✅ Passed The description is detailed and on-topic. It explains the motivation, shared modules, mobile behavior, bug fixes, testing, visual verification, and known gaps. It omits some template headings and chec…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts lifts 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.ts centralizes command-tool classification, the running-tool descriptor/label, and running-call selection.
  • Desktop — NativeChatWorkingStatus, NativeChatToolRun, and use-native-chat-turn-status now 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

  • describeActiveToolCall returns isCommand, but both ToolRun implementations pick the glyph by re-calling isCommandToolName(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.ts deletes stale toggle handlers inside a useMemo (a render-phase ref mutation). Idempotent so safe, but it's a side effect in what is nominally a pure computation.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Root cause found while chasing the mobile screenshots — and it is bigger than this PR

Two 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 (6806bd4895c).

The bug

runtime.clientCapabilities.update stores what a phone advertises by assigning:

authenticatedSocket.clientCapabilities = clientCapabilities   // runtime-rpc-websocket-dispatch.ts:144

but 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:

TypeError: Cannot set property clientCapabilities of #<Object> which has only a getter

The RPC answered runtime_error and the capability set was never stored.

Why nobody noticed

  • AuthenticatedMobileSocket declares clientCapabilities as a plain mutable field, so TypeScript compiled it happily — pnpm tc green, build green.
  • Mobile swallows the failure by design: settleMobileRuntimeCapabilities treats any non-ok response as "capabilities unavailable, proceed" and only console.warns. A failed handshake is indistinguishable from an old client.

Blast radius — the whole feature, not just this UI

supportsStructuredAgentSessions requires that capability, so projectSessionTabAgentStatus stripped every agent-session tab. A paired phone on a worktree whose only tab was a structured Codex chat showed 0 tabs. Structured native chat was unreachable on mobile over this transport — the turn-status UI in this PR was merely the first thing to notice.

The single line that cracked it, in the Metro/JS console:

WARN  [net] mobile capability negotiation unavailable runtime_error

The fix

A set clientCapabilities that writes through to the channel, which already owns the set for the connection's lifetime so later requests on the same socket observe it. Regression test asserts the assignment does not throw and that a subsequent request sees the updated set. src/main/runtime/rpc suite: 2904 tests green; pnpm tc green.

Scope flag for the merge decision

This 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.clientCapabilities now exposes a setter that writes through to E2EEChannel.clientCapabilities, so runtime.clientCapabilities.update stops throwing a TypeError on the previously getter-only property and capable phones stop losing their structured agent-session tabs.
  • Regression test — a MobileSocketWiring test 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Merge Sim added 8 commits September 4, 2026 19:21
…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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/port-native-chat-ui branch from 6806bd4 to a273672 Compare September 5, 2026 02:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 0570ff60-ad6d-4675-aa8f-8c59daa75bf2

📥 Commits

Reviewing files that changed from the base of the PR and between 636544b and a273672.

📒 Files selected for processing (7)
  • mobile/src/session/MobileNativeChatView.test.ts
  • mobile/src/session/MobileNativeChatView.tsx
  • mobile/src/session/use-mobile-native-chat-turn-disclosure.test.tsx
  • mobile/src/session/use-mobile-native-chat-turn-disclosure.ts
  • mobile/src/session/use-mobile-native-chat-turn-status.ts
  • src/main/runtime/rpc/mobile-socket-wiring.test.ts
  • src/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(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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/src

Repository: 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.ts

Repository: 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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Mobile emulator screenshots — the new turn UI, on device

iPhone 17 Pro simulator (iOS 26.5), paired local-only to an isolated dev host built from this branch at 6806bd4895c. JS provenance: the Expo dev menu reads Connected to: http://127.0.0.1:8099 — this worktree's Metro. Structured lane confirmed: the tab is a real agent-session "Codex Chat", not the bridge/PTY fallback. Driven entirely through orca emulator (AX-tree tap/type); screenshots via xcrun simctl io … screenshot.

First — what the capability fix changed

Before, a phone paired to a worktree whose only tab was a structured Codex chat saw zero tabs:

00-before-fix-zero-tabs.png

After, the structured tabs are listed — and the phone can now create one itself, which previously fell back to a terminal tab:

00b-after-fix-codex-chat-tabs.png

1. "Thinking" — before the turn produces output

01-thinking.png

2–3. "Working for Ns" — the live clock

Sampled 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:

t= 1.8s  Thinking
t= 7.3s  Thinking
t=12.2s  Thinking
t=17.0s  Working for 15s   + Running /bin/zsh -lc 'sleep 25; echo QA1'
t=22.3s  Working for 20s
t=27.0s  Working for 25s
t=32.2s  Working for 30s
t=36.7s  Working for 34s
t=41.0s  Working for 39s
         -> settles to "Worked for 42s"

02-working-for-15s.png

03-working-for-30s.png

4. Live tool row — terminal glyph + the running command

Running /bin/zsh -lc 'sleep 25; echo QA1' under Working for 26s, with the Stop control in the composer chrome. Note the old static Agent is working ••• row is absent on this lane, as intended.

04-running-tool-row.png

5. Settled "Worked for 42s" — tool run hidden

Chevron points right; the grouped tool run is not rendered.

05-worked-for-collapsed.png

6. Tapped — turn details disclosed

Chevron rotates down and the run appears as 1× shell /bin/zsh -lc 'sleep 25; echo …' with its child tool line collapsed. The row is exposed to assistive tech as Toggle turn details (that is why it does not surface as "Worked for 42s" in the AX tree).

06-worked-for-disclosed.png

Not captured

Long-press text selection — orca emulator gesture has no long-press primitive, so it was not exercised rather than guessed at.

Rig hygiene

Own simulator created for this run; the peer serve-sim helper on port 3100 was verified alive before and after attaching mine on 3101, so no other agent's device was evicted. mobile/pnpm-lock.yaml md5 unchanged (b7cc319a0c4294355140dd3a62062096).

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 — useMobileNativeChatTurnStatus now captures previousActiveTurn.current into a local previousActiveTurnKey before setScopedTiming, 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 (the host\0worktree\0tab surface 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 — activeTurnIsWorking now only treats the unanchored branch as the live turn when activeTurnKey === 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.tsx drives the real hook through react-test-renderer (not just the pure reducer) and pins scope isolation, stable toggle handlers, and the 128-turn disclosure cap; MobileNativeChatView.test.ts pins the lane wiring at the view level.

Pullfrog  | View workflow run | Using 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Dropped the per-turn handler ref — use-mobile-native-chat-turn-disclosure no longer caches a () => void closure per turn in a ref. It now exposes one stable onToggleTurn(turnKey) and carries the turn id as a turnKey field on each settled row, eliminating the render-phase ref mutation flagged in the prior review.
  • Row invokes the shared handler with its own key — MobileNativeChatMessage wraps the stable onToggleTurn in () => 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 turnKey stability and onToggleTurn handler identity across re-renders, and drive taps via onToggleTurn(row.turnKey).

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Merge Sim added 2 commits September 4, 2026 19:57
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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Shipped the native-chat translations — fix: ship native chat status translations adds the five status keys (responding, thinking, toggleDetails, workedFor, workingFor) and six tool keys (countN, countOne, runningCommand, runningNamed, runningNamedPreview, runningPreview) that the restructured desktop components now reference. Each value matches the corresponding NATIVE_CHAT_TURN_STATUS_COPY / NATIVE_CHAT_TOOL_ACTIVITY_COPY fallback string exactly, so the English output is unchanged while the keys become localizable.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Pinned the shared copy to the English catalog — test(native-chat): pin the shared copy against the English catalog adds native-chat-shared-copy-matches-catalog.test.ts, which asserts every NATIVE_CHAT_TURN_STATUS_COPY / NATIVE_CHAT_TOOL_ACTIVITY_COPY entry is byte-identical to en.json and 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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: c56065b3-5224-4177-8c60-6e522efd39c4

📥 Commits

Reviewing files that changed from the base of the PR and between ff657e9 and 6d444f9.

📒 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.

Comment on lines +40 to +41
expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{toolName}}')
expect(NATIVE_CHAT_TOOL_ACTIVITY_COPY.runningNamedPreview).toContain('{{preview}}')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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}}')

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review complete: ✅ clean / ready at 6d444f96ada.

Review fixes and hardening:

  • Isolated mobile turn timing and disclosure state by host/worktree/tab scope, preserved pending-to-real turn rekeying, and stopped pre-first-user history from being treated as live activity.
  • Replaced the render-mutated callback ref cache with settled-row turnKey values plus one stable onToggleTurn(turnKey); expanded state is FIFO-capped at 128 and bridge sessions skip structured transcript work.
  • Fixed mobile capability propagation so the structured agent-session lane can actually be selected.
  • Added the missing runtime-required English catalog entries and a regression test that pins shared mobile/desktop copy and interpolation placeholders to the catalog.

Verification:

  • Same-model adversarial review/fix loop and final readiness audit: no remaining P0/P1/P2 findings.
  • Final-head CI is fully green: standalone React Doctor, changed-code quality, runtime localization/catalog checks, typecheck, all 8 test shards, Mobile Checks, Linux package, Windows package, and aggregate verify.
  • Focused catalog-parity test: 12/12 passed. Coordinator verification also covered the 4,104-test mobile suite and pnpm tc.
  • Desktop Electron/CDP smoke on the UI-equivalent a4c01503112 runtime revision (the later commits are catalog/test-only): literal agent-session, live Thinking/Working plus Running tool row, settled Worked-for state, Tools disclosure, and zero console errors.
  • Mobile emulator QA and structured-lane screenshots were already posted earlier in this thread.

Exact-head-equivalent desktop evidence:

Working for 5s with live tool activity

Settled Worked for 13s with disclosure open

No remaining in-scope blockers found.

@brennanb2025
brennanb2025 merged commit b0c67ea into main Sep 5, 2026
28 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant