Skip to content

refactor(mobile): send the rest of the session domain through typed RpcOperations (step 4) - #20891

Merged
Jinwoo-H merged 14 commits into
mainfrom
step4-session-2
Sep 15, 2026
Merged

Jinwoo-H merged 14 commits into
mainfrom
step4-session-2

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3
Prod 680 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41958 $\color{#cf222e}{\Huge{\mathbf{−}}}$​810 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41148

Step 4, session domain second half: 62 of the remaining 76 mobile/src/session/ references migrated onto typed RpcOperations with a no-behaviour-change contract proven by recorded goldens. Runtime-affecting refactor, wire bytes proven identical.

Diff composition (head f6833113e1, vs merge-base 2fccacadbe)

The line count is almost entirely recorded golden JSON, not code. Product source is the small row.

Part Files Added Deleted What it is
Goldens, newly recorded 121 +35,301 0 87 pilot + 34 reply-matrix goldens for the migrated call sites; recorded against the baseline before the refactor, unchanged by it (46 gained only #20884's sent ordinal on the re-record at main's new pin)
Goldens, header re-digest 520 +520 -520 Every existing golden, recorderSha256 only (this branch adds adapters to main's recorder tree); zero body lines, lead-reproduced through the value pool
pilot-scenarios.json 1 +3,870 0 87 scenario entries
Test and recorder infra 17 +1,426 -18 10 adapter modules in adapters/, substitutes additions (haptics, clipboard pasteboard, RN members the hooks read), parity hashes
Product source 37 +970 -307 The migration: 38 operations across 5 new *-operations.ts modules plus one added to mobile-review-terminal-operations.ts; 0 new acceptance policies
Total 696 +42,087 -845

Commit order (the contract)

  1. ded9186468 scenarios + goldens recorded at main's pin c6a72169843e through a detached worktree, before any product edit. 2. 5d0c85fca5 types the mount fixtures against the product model (checked fixtures exposed wrong shapes in 11 recordings; corrected and re-recorded at the pin, still before the refactor; per-golden reasons in the section below). 3. 87c63b2905 format. 4. c4cd7c253c the refactor: product only, 0 goldens touched. 5. 43c8df5f26 keeps main's exact malformed-reply message in mobile-clipboard-image.ts (the reply matrix caught a V8 message that would have changed) and re-anchors two mutants. 6. 085a5e0433 34 reply-matrix goldens. 7. eedb153202 the cast fence rejected four readers that asserted their result type; back to rpcUnchecked*, shapes named at call sites. 8. 8dcfac7253 three assertions given SAFETY rationale; 13 goldens header-only.

Inventory

src/session/: 39 files / 76 refs → 10 files / 14 refs. Holdouts by reason: 7 refs whose request lives in the same effect as a subscribe (subscriptions are step 6; the request-only runner refuses to open one); 6 refs that read pasteboard, PTY mode or image-manipulator state before the send (unrecorded site, record-first rule); 1 ref where the method is a parameter (callAgentSession, 7 callers across 5 files, needs a typed step model).

Evidence

  • Refactor commit touches 0 files under mobile/rpc-foundation/goldens/.
  • Mutation census, applied/run/reverted, all killed: wrong method 3 failures; acceptance swapped on terminal.list 4, worktree.set 2, repo.list 2; interpret inside the chain instead of at the barrier 3; dropped delivery-unknown mark on terminal.send 3.
  • Lead-reproduced at f6833113e1 vs main: 520 M, all header-only with recorderSha256 the only moved key (decoded through the value pool), 121 A, 0 D; one recorderSha256 / baseline (e7206f62a8) / lockfileSha256 across all 641; the four recorder refusal texts absent; recording suite + parity 744 passed; mobile typecheck 0.
  • The AI Vault resume launch and the review send sheet now share the create/send terminal pair with the PR triage launch instead of re-deriving it.

Why 11 goldens changed body between commit 1 and commit 2

Two fixture defects the checked types exposed, plus one fixture that swallowed a TypeError. Commits 1 and 2 touch zero files outside rpc-recording/ and rpc-foundation/, so no product edit existed when either recording ran; the agent replayed commit 2's recorder against the fenced baseline worktree and got 0 differences against the committed goldens.

  • Defect 1: the diff-review action fixture's comment was an untyped literal missing side (required by DiffComment), and its status carried three invented arrays absent from the ready-state type. review-stage-file, review-open-in-session, review-send-notes-heals-stale-input, review-create-terminal-refused, review-stage-refused: one projected state value re-keyed each, wire byte-identical. review-mark-reviewed-persists, review-mark-reviewed-rolls-back: the comment is echoed on the wire, so worktree.set params now carry side; the change comes from the fixture, not the product.
  • Defect 2: the session-tab fixture's local tab/terminal aliases lacked title and isActive, both required by the product types. session-tab-rename, session-tab-close-terminal, session-tab-close-refused-keeps-tab: projected state only, wire byte-identical.
  • Swallowed TypeError: session-tab-close-session-tab's closedTabTombstonesRef fixture was { remember() {} } where the product calls .set() on a Map; the throw was caught by that path's own catch, so commit 1 froze a half-executed close. With a real Map the close completes (activeHandle: null, tombstone written). Wire unchanged.

The other 25 goldens in that commit moved adapterSha256 only.

What the oracle caught that reading would not

Three divergences in the refactor, all found by the goldens:

  1. Send order. The new-tab agent loader computed its detection request inside the Promise.all array instead of before it, so settings.get went first; 7 goldens failed on the first sender's args. Fixed by hoisting.
  2. A user-visible message. The clipboard upload destructures uploadId off the result; a success carrying no result throws a TypeError whose message (V8 includes the destructured expression's source text) the composer shows. Reading the slot off the interpreted payload rewrote that sentence on three families' result-absent/result-null partitions. The read stays on the raw result for that reason alone, with a SAFETY line (43c8df5f26).
  3. Two dead mutant anchors (race, new-tab-refusal-order) matched zero sites after the rewrite; re-anchored, and probe-hole-witness.test.ts still shows the probe killing the reorder.
  4. New domain mutant native-chat-send-delivery-unknown: dropping the delivery-unknown arm makes an ack lost after the frame was written read as a definite rejection, which invites a double send; the goldens kill it.

Correction to the message of 43c8df5f26: it says a candidate mutant "survives every golden". Swapping terminal.list from skip to throw survives only pilot-mutants.test.ts (last-checkpoint state compare; the inventory hook wraps its read in catch { return false }), and the full golden compare kills it on 4 tests. It is unregistered for that reason and counted in the census above.

Readers and policies

3 methods carry more than one reader, each argued where declared: files.resolveTerminalPath, files.open, session.tabs.list. git.stage and repo.list carry two acceptances over one reader (single-file raises its refusal, bulk sweep counts it; new-tab has nothing to show, readability answers "not readable"). 0 new acceptance policies.

Substitutes added, with the site that needs each: expo-haptics (diff-review and session action hooks via platform/haptics.ts, iOS members only since Platform.OS is pinned), expo-clipboard as a per-recording pasteboard cell (review send sheet, session notes, markdown copy read back what they wrote), react-native BackHandler and Keyboard (markdown actions hook).

Ticket owed, not fixed here

mobile-session-tab-activation.ts decides whether to replay an activation with error instanceof LogicalClientCutoverError rather than the message-matching isLogicalClientCutoverError that exists because instanceof can miss across bundle copies; under a second copy of the module the retry silently does not happen. Preserved. No golden scripts a cutover for that family, so none records it.

Not done, deliberately

use-mobile-terminal-paste.ts and four other native-state hooks stay unmigrated rather than getting expo-file-system/expo-image-manipulator substitutes: a recording of a fabricated clipboard image pins device state, not the wire. callAgentSession's 7 callers are not restructured to take an operation each: it deletes one inventory line and rewrites five files whose behaviour no golden holds.

Measurements

Wall clock start to green about 1h35m. Golden weight 12M / 509 files → 13M / 630 files.

Gates

ORCA_BACKGROUND_LAUNCH=1: mobile typecheck 0; mobile test 587 files / 5472 passed / 6 skipped; pnpm tc 0; check:code-quality:changed 0 new findings across 53 files; check:react-doctor:changed 0; oxfmt --check . from mobile/ 2468 files correct; oxlint on 53 changed files 0.

Review round 1 (2026-09-15)

Ship after three small edits, applied as 441fa57f98 + 8b5a49d827 (zero golden movement, no parity hash moved): the two file-tap sites reuse RpcOperationSender instead of an inline Parameters<typeof …request>[0]; sessionWorktreeNotesWrite and the preflight readers now state why they do not share the existing worktree.set / detect-agents operations (disjoint partial-update members and a rollback path that must not inherit the link save's policy; advisory skip vs. gating throw); the callAgentSession holdout count corrected to five call sites in two hooks plus one internal use; the native-chat holdout reason now says what actually gates the paging read. Reviewer confirmed all seven verification items: refactor commit touches zero goldens; 509 pre-existing goldens differ on recorderSha256 alone; the fixture-correction commit contains no session product change; reader census (nine methods with a later reader, seven justified, now nine); no migrated site changed params, options or timeout; holdout partition accurate; the raw cast preserves a V8 message reproduced both ways; subscribe sites untouched. Note: check:react-doctor:changed reports three non-blocking warnings on rewritten lines (await-in-loop ×2, state update after await ×1) that main already has at those sites.

Review round 2 (2026-09-15, fresh reviewer)

Ship after comment corrections and one reuse deletion; no behaviour bug. Reviewer independently reproduced: inert proof (every pre-existing golden differs on recorderSha256 alone), the send-order claim (un-hoisting loadDetectedAgents fails 11 recordings on sender[0]), delivery-unknown identity on every migrated mutation (the new mutant dies non-vacuously), both re-anchored mutants, two holdouts spot-checked.

Applied as 681d9a3592 + 39d83bb356 (zero goldens):

  • fileTapPathResolve is now a re-export of terminalArtifactPathResolve (same method, acceptance, barrier and reader; precedent fileOwnershipRuntimeStatusRead), replacing a justification that stated the opposite of the code.
  • worktree.show reader count corrected to four; the real distinction from fileOwnershipWorktreeRead is acceptance alone (skip vs throw).
  • interpretOrThrowRefusalMessage made generic and 12 longhand copies of its try/catch replaced (net −20 source lines; 19 call sites, 7 pre-existing). Longhand survivors named in the commit body: 3 request-inside-try blocks, 2 catches that set state, 4 shape-eligible sites in files this PR does not touch. The route-parity callback-body and nested-function hashes move for that reason alone; all counts and every other hash unchanged.
  • Stray mutant comment removed; three operations moved to the module matching their direction; duplicate RepoSummary type dropped in favour of the exported one.

Then merged main (b57cbd3583, #20874 / #20895 / #20873 / #20884: substitutes rebuilt on main's structure with this branch's entries re-applied, pilot-scenarios.json merged by scenario id, 509 golden conflicts classified base/ours/theirs: 0 body-changed by this side) and re-recorded once at main's pin (f6833113e1).

… migrating them

Freezes main's behaviour for what is left of `mobile/src/session/`: the AI Vault resume pair, the
clipboard image upload and its two attachment surfaces, the native-chat terminal writes, session
tab activation and reconciliation, the terminal-path tap, the structured agent launch, and the
session screen's own reads, tab creates/closes, review actions, notes, markdown save and quick
commands. 87 scenarios over 22 new families, recorded from the pinned baseline
`c6a72169843ececf3a21da370ac50c5c5a4e6462` through a detached worktree, before any product edit.

Ten new modules under `adapters/`, so each domain's goldens are pinned by `adapterSha256` and no
existing family re-digests. `native-mounting-substitutes.ts` gains `expo-haptics` (inert: every
caller is already fire-and-forget), `expo-clipboard` (a per-recording pasteboard cell, because
these screens read back what they wrote) and `BackHandler`/`Keyboard`. That is an engine file, so
all 509 pre-existing goldens move on `recorderSha256` and on nothing else.

Two families cannot be matrixed at their first request: the clipboard upload chain puts the start
reply's `uploadId` into the params of every later call, so a partition that answers the start
differently changes a downstream assertion rather than a recorded observation. Their base scenarios
stop at that first reply instead, and the fallback arm carries the upload family's second site.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… model

The ten adapter modules added with the session recordings typed several fixtures structurally —
loose maps, a local `Terminal`/`Tab` shape, `unknown` for the review screen state — which
`pnpm --dir mobile typecheck` rejects: `tsconfig` covers `src/test-support`, so an adapter is
checked like product code even though no test file is. Each one now names the product type it
stands in for (`MarkdownDocState`, `TerminalRecord`, `MobileSessionTab`, `ReviewScreenState`,
`MobileDiffReviewQueueItem`, `DiffComment`) and supplies its members through `mountFixture`.

Only one of those changed a recording: a `DiffComment` requires `side`, so the review actions now
put it on the wire and the two `review-mark-reviewed-*` goldens carry it. That is the fixture
becoming a real subset of the type it claimed, not a behaviour change — no product source moves in
this commit, and the parity claim the next one makes is against these bytes.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ifest

`pnpm exec oxfmt --check .` from `mobile/` flagged both after the previous commit's type fixes.
The adapter is pinned by `adapterSha256`, so the eight goldens recorded through it are re-recorded
from the same baseline; the manifest is not pinned by its bytes — `scenarioSha256` canonicalises
the parsed scenarios — so no golden moves for it. Header-only either way: no observation changes.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…pcOperations

Thirty files and 58 references leave the raw request port. Every send now names a declared
operation with a fixed method, one acceptance policy and one reader, and no call site casts a
reply payload: the AI Vault resume pair, the clipboard image upload with both its attachment
surfaces, the native-chat terminal writes, session tab activation and reconciliation, the
terminal-path tap, the structured agent launch, and the session screen's reads, tab
creates/closes, review actions, notes, markdown save, quick commands and file search.

Five new operation modules, plus two readers added to existing ones. Three methods get a second
reader, each argued where it is declared: `files.resolveTerminalPath` (the tap branches on five
members the grant refresh hands back whole), `files.open` (the tap's miss is silent, the Changes
screen raises the host's message) and `session.tabs.list` (the send sheet keeps only terminal
tabs, which the reveal poller and the reconciliation controller both drop). `git.stage` carries
two acceptances for the same reason `repo.list` does: a tapped file raises its refusal, a bulk
sweep counts it. No new acceptance policy.

The AI Vault resume launch and the review send sheet now share
`mobile-review-terminal-operations.ts` with the PR triage launch instead of re-deriving the same
create/send pair, and the file-search hook's `extractPaths` moves into the reader it belongs to.

One latent behaviour is preserved rather than fixed and wants a ticket:
`mobile-session-tab-activation.ts` decides whether to replay an activation with
`error instanceof LogicalClientCutoverError`, not with the message-matching
`isLogicalClientCutoverError` that exists because "instanceof can miss across bundle copies". Under
a second copy of the module the retry silently does not happen, which the recorder reproduces. No
golden scripts a cutover for this family, so none records the wrong behaviour.

The offender floor in the port ratchet comes down from 50 to 20: it is an anti-vacuity guard on a
list this migration is driving to zero, and 39 files still reach the port.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…tants

Three findings the reply matrices surfaced that the pilot scenarios could not.

The clipboard upload's `uploadId` read goes back to the raw result. A success carrying no result
throws a destructuring TypeError there, and V8 puts the destructured expression's source text in
the message — which the composer shows. Reading the slot off the interpreted payload rewrote that
sentence for every user who hits a malformed reply, on three families' `result-absent` and
`result-null` partitions. The cast is the one main made, kept for the message alone.

`race` and `new-tab-refusal-order` both anchored in text the migration rewrote, so each matched
zero sites. Re-anchored at their new homes; the defect each injects is unchanged, and
`probe-hole-witness.test.ts` still shows the probe killing the reorder while every pre-probe
scenario survives it.

`native-chat-send-delivery-unknown` is added as this domain's own mutant: dropping the
delivery-unknown arm of a chat send makes an ack lost after the frame was written read as a
definite rejection, which invites the user to send the same message twice. A second candidate —
swapping `terminal.list` from skip to throw — survives every golden and is not registered: the
inventory hook wraps its whole read in `catch { return false }`, so a refusal and a throw leave
the same strip.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Thirty-four reply-matrix goldens, one per scripted reply across the twenty-two families the session
migration added, each running the eleven partitions in `reply-matrix.ts`. Recorded from the same
pinned baseline as the pilot goldens through the detached worktree, so they freeze main's answer to
a result-less success, a null result, an inner refusal envelope, a message-less outer refusal and a
transport drop — not the migrated code's.

They are laid down after the refactor because they are what found its three remaining divergences,
each fixed in the previous commit rather than recorded around: the clipboard upload's destructuring
message, and two mutation anchors the rewrite left matching zero sites.

Two families matrix only their first request. The clipboard upload chain puts the start reply's
`uploadId` into every later call's params, so a partition that answers the start differently moves
a downstream assertion instead of a recorded observation; their base scenarios stop there, and the
upload family's fallback arm carries its second site.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ast fence

`rpc-operation-cast-fence.test.ts` refuses a type assertion anywhere in the region reachable from
`rpc-operation-contract.ts`, and four of the new operation modules asserted their own result type.
Each of those reads goes back to `rpcUncheckedPayloadReader`/`rpcUncheckedMemberReader`, and the
shape the call site expects is named at the call site, which is where every migrated domain already
puts it. `extractPaths` and `readQuickCommands` return to their hooks for the same reason — both
were only movable by carrying a cast with them.

No golden moves: the readers hand back the same values, and all 705 recordings still compare clean.

The two frozen source-parity suites over the session route family are refreshed for the migrated
text: three hashes, one runtime-string count, and the inventory hook's acceptance check, which now
reads `!isCurrent() || !response.accepted`.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`pnpm run check:code-quality:changed` reports `consistent-type-assertions` separately from oxlint's
own pass, and three sites had no rationale: the resume preparation's payload read, which gets the
standard SAFETY line, and two adapter refs whose `null as string | null` is just an annotation
written the wrong way round. The adapter is pinned by `adapterSha256`, so its thirteen goldens are
re-recorded from the baseline — header-only, no observation moves.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown

Too many files changed for review (684 files, 100 file limit).

@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 critical issues — one placement nit inline.

Reviewed changes

  • Typed session operations — 38 operations added across mobile-session-{read,write,launch}-operations.ts, mobile-clipboard-image-operations.ts, mobile-diff-review-git-operations.ts, and mobile-review-terminal-operations.ts, with no new acceptance policies.
  • Call-site migration — 36 product files (62 of the 76 session refs) now send through operations; every migrated site was checked against base for identical return value, thrown message/type, skip-vs-throw, and wire params.
  • Recording evidence — ~121 newly recorded goldens plus 509 recorderSha256-only re-digests, with zero golden body changes; 10 new mount adapters and 4 native substitutes (expo-haptics, expo-clipboard, BackHandler, Keyboard) support them.
  • Pin updates — the route-parity hashes and runtime-string count, the startup-source !response.accepted assertion, and the inventory scan floor all track code that moved out of the pinned families.

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

@@ -1,10 +1,12 @@
import { useEffect, useState } from 'react'
import type { RpcClient } from '../transport/rpc-client'
import { nativeChatRepoListRead } from './mobile-session-read-operations'

type RepoSummary = { id: string; connectionId?: string | null }

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.

This new type RepoSummary landed between two import statements, splitting the import block. Move it below the imports, next to type ReadabilityState at line 10, so the imports stay contiguous.

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.

Addressed in 681d9a3: the local RepoSummary is gone and the import now pulls MobileRuntimeRepoSummary, so the import block is contiguous.

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

Reuses `RpcOperationSender` for the file-tap client instead of respelling it as
`Parameters<typeof fileTapPathResolve.request>[0]` at two sites; the type is the same by
construction, and the handlers file no longer imports an operation only to name its first parameter.

Names why `worktree.set-review-notes` stays separate from source-control's identical
`worktree.set-review-link`, and why the new-tab loader's two preflight reads do not share the task
drawer's readers on the same methods.

Corrects the `callAgentSession` holdout count: five call sites across two hooks plus one inside the
module's own mutation wrapper, not seven callers across five files.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The `nativeChat.readSession` send sits in the paging callback, not in the mount effect. What blocks
recording it is that the mount effect's `nativeChat.subscribe` is what arms the offset and
generation the callback pages against, and the request-only runner refuses to open a subscription.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The tapped-path resolve is now a re-export of the preview screen's `terminalArtifactPathResolve`
rather than a second definition: same method, same skip, same whole-payload read, so the only thing
the old comment could claim was a difference that was not there. `fileOwnershipRuntimeStatusRead`
already re-exports for this reason.

`worktree.show` has four readers, not three. The one the notes read is closest to is
`fileOwnershipWorktreeRead`, which reads the same member whole, and acceptance is all that separates
them: a file mutation throws rather than write to the wrong host, a session screen without its notes
shows none and keeps working.

`interpretOrThrowRefusalMessage` is generic, so a caller keeps the interpretation's own type, and
eight longhand copies of its try/catch across five files now call it. Three more copies wait on a
frozen source hash; see the report.

Three operations sit in the module matching their direction: the quick-command save with the writes,
the review-notes read and the markdown read with the reads. The quick-command reader is shared
across that line, which is what keeps the save from adopting `[]` on a payload the parser rejects.

The native-chat readability probe imports `MobileRuntimeRepoSummary` instead of redeclaring it, and
a stray mutant comment that described the race entry is gone.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… session hooks

Twelve try/catch blocks across the session hooks now call the generic
interpretOrThrowRefusalMessage instead of rethrowing
refusedRpcMessageOrFallback by hand. Each one throws the same message on the
same inputs, and the request stays outside the catch, so a transport rejection
keeps its delivery-unknown identity.

Two frozen parity hashes move for that reason alone:

- HEAD_CALLBACK_BODY_SHA256, for the one converted block that sits in a
  useCallback (use-mobile-session-diff-comments.ts)
- HEAD_NESTED_FUNCTION_SHA256, for the three that sit in plain nested functions
  (use-mobile-session-content-create-actions.ts)

Every other parity hash and every count is unchanged: hooks 269, callbacks 77,
effects 24, nested functions 12, plus the callback identity, effect, main-hook,
hook-binding, content-hook, native registration/removal and timer hashes.

Copies that stay longhand, by design:

- the action-level try blocks that wrap the request as well as the interpret and
  surface the failure to the UI, in the diff-review comment, git and send hooks
- the two catches that call setActionError or setError and return instead of
  throwing, in use-mobile-diff-review-interactions.ts and use-quick-commands.ts
- the call sites in files this branch does not touch (pr-ai-triage-launch.ts,
  mobile-diff-review-loaders.ts, github-pr-rpc.ts,
  github-pr-mutation-outcome.ts)

No golden moves: this touches no golden, adapter or recorder engine file.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Brings in #20884 (2fccaca), which reworked the recorder engine: the trap
helpers moved to native-module-traps.ts, the view packages a mounted screen
needs to screen-native-substitutes.ts, and the scenario-declared device store
and notification tray to declared-device-state.ts. recorderSha256 moves for
every golden as a result, and effects now carry a `sent` ordinal.

Conflict resolutions:

- 509 goldens. All 509 conflicted on header fields only from this side, checked
  by comparing each file's base, ours and theirs bodies with the five header
  keys removed: 260 were header-only on both sides and 249 had a body change
  from main alone. None had a body change from this side, so taking main's side
  loses nothing of ours. The re-record at the new pin follows separately.
- pilot-scenarios.json. Merged by scenario id rather than by text side: baseline
  takes main's e7206f6, main's 6 new scenarios and this branch's 87 both
  survive, base order is preserved on both sides and no id was modified by both.
  328 scenarios total, and the file is a pure addition over main's copy.
- mounted-operation-modules.ts. Both sides added an adapter at the same
  alphabetical slot; kept both, clipboard-image before codex-reset-credit.
- native-mounting-substitutes.ts. Rebuilt on main's structure, which deletes the
  local trap helpers in favour of the extracted modules, then re-applied this
  branch's three additions: the expo-clipboard pasteboard fixture (main's
  declared device store is async storage, so it has no equivalent there), the
  expo-haptics entry, and BackHandler plus Keyboard.dismiss alongside main's
  reactNativeScreenMembers spread. The clipboard doc paragraph now says
  "pasteboard" rather than "device store", because main made that term mean the
  declared async-storage backing.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
One re-record of all 641 goldens against pin e7206f6 from a detached
worktree at that commit, with this branch's rpc-recording/ tree,
pilot-scenarios.json and scripts/rpc-recording.mts overlaid and only the
differing files copied in. The recorder's own fence passed: product sources
under mobile/src outside the recorder, src/shared and the lockfile were
byte-identical to the pin, with nothing untracked under the guarded trees.

Every golden now carries one baseline, one lockfileSha256 and one
recorderSha256. recorderSha256 moves on all 641 because this branch's recorder
tree adds adapters to main's, so main's own value could not survive the merge.
baseline moves on exactly the 121 goldens this branch adds, from c6a7216
to e7206f6.

595 goldens are header-only. The 46 bodies that move are all among this
branch's 121 and all gain the `sent` ordinal that #20884 added to effects,
verified field by field: each effect is byte-identical apart from the new key,
and no effect was added or dropped. None of main's 509 bodies move, and the
six-golden agentSession.structured-launch family does not move either.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@Jinwoo-H
Jinwoo-H merged commit 0869d99 into main Sep 15, 2026
21 of 22 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…pcOperations (step 4) (stablyai#20891)

* test(mobile): record the session domain's remaining call sites before migrating them

Freezes main's behaviour for what is left of `mobile/src/session/`: the AI Vault resume pair, the
clipboard image upload and its two attachment surfaces, the native-chat terminal writes, session
tab activation and reconciliation, the terminal-path tap, the structured agent launch, and the
session screen's own reads, tab creates/closes, review actions, notes, markdown save and quick
commands. 87 scenarios over 22 new families, recorded from the pinned baseline
`c6a72169843ececf3a21da370ac50c5c5a4e6462` through a detached worktree, before any product edit.

Ten new modules under `adapters/`, so each domain's goldens are pinned by `adapterSha256` and no
existing family re-digests. `native-mounting-substitutes.ts` gains `expo-haptics` (inert: every
caller is already fire-and-forget), `expo-clipboard` (a per-recording pasteboard cell, because
these screens read back what they wrote) and `BackHandler`/`Keyboard`. That is an engine file, so
all 509 pre-existing goldens move on `recorderSha256` and on nothing else.

Two families cannot be matrixed at their first request: the clipboard upload chain puts the start
reply's `uploadId` into the params of every later call, so a partition that answers the start
differently changes a downstream assertion rather than a recorded observation. Their base scenarios
stop at that first reply instead, and the fallback arm carries the upload family's second site.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile): type the new session mount fixtures against the product model

The ten adapter modules added with the session recordings typed several fixtures structurally —
loose maps, a local `Terminal`/`Tab` shape, `unknown` for the review screen state — which
`pnpm --dir mobile typecheck` rejects: `tsconfig` covers `src/test-support`, so an adapter is
checked like product code even though no test file is. Each one now names the product type it
stands in for (`MarkdownDocState`, `TerminalRecord`, `MobileSessionTab`, `ReviewScreenState`,
`MobileDiffReviewQueueItem`, `DiffComment`) and supplies its members through `mountFixture`.

Only one of those changed a recording: a `DiffComment` requires `side`, so the review actions now
put it on the wire and the two `review-mark-reviewed-*` goldens carry it. That is the fixture
becoming a real subset of the type it claimed, not a behaviour change — no product source moves in
this commit, and the parity claim the next one makes is against these bytes.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* style(mobile): format the session mount adapter and the recording manifest

`pnpm exec oxfmt --check .` from `mobile/` flagged both after the previous commit's type fixes.
The adapter is pinned by `adapterSha256`, so the eight goldens recorded through it are re-recorded
from the same baseline; the manifest is not pinned by its bytes — `scenarioSha256` canonicalises
the parsed scenarios — so no golden moves for it. Header-only either way: no observation changes.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* refactor(mobile): send the rest of the session domain through typed RpcOperations

Thirty files and 58 references leave the raw request port. Every send now names a declared
operation with a fixed method, one acceptance policy and one reader, and no call site casts a
reply payload: the AI Vault resume pair, the clipboard image upload with both its attachment
surfaces, the native-chat terminal writes, session tab activation and reconciliation, the
terminal-path tap, the structured agent launch, and the session screen's reads, tab
creates/closes, review actions, notes, markdown save, quick commands and file search.

Five new operation modules, plus two readers added to existing ones. Three methods get a second
reader, each argued where it is declared: `files.resolveTerminalPath` (the tap branches on five
members the grant refresh hands back whole), `files.open` (the tap's miss is silent, the Changes
screen raises the host's message) and `session.tabs.list` (the send sheet keeps only terminal
tabs, which the reveal poller and the reconciliation controller both drop). `git.stage` carries
two acceptances for the same reason `repo.list` does: a tapped file raises its refusal, a bulk
sweep counts it. No new acceptance policy.

The AI Vault resume launch and the review send sheet now share
`mobile-review-terminal-operations.ts` with the PR triage launch instead of re-deriving the same
create/send pair, and the file-search hook's `extractPaths` moves into the reader it belongs to.

One latent behaviour is preserved rather than fixed and wants a ticket:
`mobile-session-tab-activation.ts` decides whether to replay an activation with
`error instanceof LogicalClientCutoverError`, not with the message-matching
`isLogicalClientCutoverError` that exists because "instanceof can miss across bundle copies". Under
a second copy of the module the retry silently does not happen, which the recorder reproduces. No
golden scripts a cutover for this family, so none records the wrong behaviour.

The offender floor in the port ratchet comes down from 50 to 20: it is an anti-vacuity guard on a
list this migration is driving to zero, and 39 files still reach the port.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* fix(mobile): keep main's malformed-reply message and re-anchor two mutants

Three findings the reply matrices surfaced that the pilot scenarios could not.

The clipboard upload's `uploadId` read goes back to the raw result. A success carrying no result
throws a destructuring TypeError there, and V8 puts the destructured expression's source text in
the message — which the composer shows. Reading the slot off the interpreted payload rewrote that
sentence for every user who hits a malformed reply, on three families' `result-absent` and
`result-null` partitions. The cast is the one main made, kept for the message alone.

`race` and `new-tab-refusal-order` both anchored in text the migration rewrote, so each matched
zero sites. Re-anchored at their new homes; the defect each injects is unchanged, and
`probe-hole-witness.test.ts` still shows the probe killing the reorder while every pre-probe
scenario survives it.

`native-chat-send-delivery-unknown` is added as this domain's own mutant: dropping the
delivery-unknown arm of a chat send makes an ack lost after the frame was written read as a
definite rejection, which invites the user to send the same message twice. A second candidate —
swapping `terminal.list` from skip to throw — survives every golden and is not registered: the
inventory hook wraps its whole read in `catch { return false }`, so a refusal and a throw leave
the same strip.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile): matrix every reply the new session families script

Thirty-four reply-matrix goldens, one per scripted reply across the twenty-two families the session
migration added, each running the eleven partitions in `reply-matrix.ts`. Recorded from the same
pinned baseline as the pilot goldens through the detached worktree, so they freeze main's answer to
a result-less success, a null result, an inner refusal envelope, a message-less outer refusal and a
transport drop — not the migrated code's.

They are laid down after the refactor because they are what found its three remaining divergences,
each fixed in the previous commit rather than recorded around: the clipboard upload's destructuring
message, and two mutation anchors the rewrite left matching zero sites.

Two families matrix only their first request. The clipboard upload chain puts the start reply's
`uploadId` into every later call's params, so a partition that answers the start differently moves
a downstream assertion instead of a recorded observation; their base scenarios stop there, and the
upload family's fallback arm carries its second site.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* refactor(mobile): keep the new session readers inside the operation cast fence

`rpc-operation-cast-fence.test.ts` refuses a type assertion anywhere in the region reachable from
`rpc-operation-contract.ts`, and four of the new operation modules asserted their own result type.
Each of those reads goes back to `rpcUncheckedPayloadReader`/`rpcUncheckedMemberReader`, and the
shape the call site expects is named at the call site, which is where every migrated domain already
puts it. `extractPaths` and `readQuickCommands` return to their hooks for the same reason — both
were only movable by carrying a cast with them.

No golden moves: the readers hand back the same values, and all 705 recordings still compare clean.

The two frozen source-parity suites over the session route family are refreshed for the migrated
text: three hashes, one runtime-string count, and the inventory hook's acceptance check, which now
reads `!isCurrent() || !response.accepted`.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* fix(mobile): drop three assertions the changed-code casting gate rejects

`pnpm run check:code-quality:changed` reports `consistent-type-assertions` separately from oxlint's
own pass, and three sites had no rationale: the resume preparation's payload read, which gets the
standard SAFETY line, and two adapter refs whose `null as string | null` is just an annotation
written the wrong way round. The adapter is pinned by `adapterSha256`, so its thirteen goldens are
re-recorded from the baseline — header-only, no observation moves.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* refactor(mobile): answer round 1 on the session migration

Reuses `RpcOperationSender` for the file-tap client instead of respelling it as
`Parameters<typeof fileTapPathResolve.request>[0]` at two sites; the type is the same by
construction, and the handlers file no longer imports an operation only to name its first parameter.

Names why `worktree.set-review-notes` stays separate from source-control's identical
`worktree.set-review-link`, and why the new-tab loader's two preflight reads do not share the task
drawer's readers on the same methods.

Corrects the `callAgentSession` holdout count: five call sites across two hooks plus one inside the
module's own mutation wrapper, not seven callers across five files.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* docs(mobile): state what actually gates the native chat paging read

The `nativeChat.readSession` send sits in the paging callback, not in the mount effect. What blocks
recording it is that the mount effect's `nativeChat.subscribe` is what arms the offset and
generation the callback pages against, and the request-only runner refuses to open a subscription.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* refactor(mobile): answer round 2 on the session migration

The tapped-path resolve is now a re-export of the preview screen's `terminalArtifactPathResolve`
rather than a second definition: same method, same skip, same whole-payload read, so the only thing
the old comment could claim was a difference that was not there. `fileOwnershipRuntimeStatusRead`
already re-exports for this reason.

`worktree.show` has four readers, not three. The one the notes read is closest to is
`fileOwnershipWorktreeRead`, which reads the same member whole, and acceptance is all that separates
them: a file mutation throws rather than write to the wrong host, a session screen without its notes
shows none and keeps working.

`interpretOrThrowRefusalMessage` is generic, so a caller keeps the interpretation's own type, and
eight longhand copies of its try/catch across five files now call it. Three more copies wait on a
frozen source hash; see the report.

Three operations sit in the module matching their direction: the quick-command save with the writes,
the review-notes read and the markdown read with the reads. The quick-command reader is shared
across that line, which is what keeps the save from adopting `[]` on a payload the parser rejects.

The native-chat readability probe imports `MobileRuntimeRepoSummary` instead of redeclaring it, and
a stray mutant comment that described the race entry is gone.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* refactor(mobile): finish the refusal-interpretation helper across the session hooks

Twelve try/catch blocks across the session hooks now call the generic
interpretOrThrowRefusalMessage instead of rethrowing
refusedRpcMessageOrFallback by hand. Each one throws the same message on the
same inputs, and the request stays outside the catch, so a transport rejection
keeps its delivery-unknown identity.

Two frozen parity hashes move for that reason alone:

- HEAD_CALLBACK_BODY_SHA256, for the one converted block that sits in a
  useCallback (use-mobile-session-diff-comments.ts)
- HEAD_NESTED_FUNCTION_SHA256, for the three that sit in plain nested functions
  (use-mobile-session-content-create-actions.ts)

Every other parity hash and every count is unchanged: hooks 269, callbacks 77,
effects 24, nested functions 12, plus the callback identity, effect, main-hook,
hook-binding, content-hook, native registration/removal and timer hashes.

Copies that stay longhand, by design:

- the action-level try blocks that wrap the request as well as the interpret and
  surface the failure to the UI, in the diff-review comment, git and send hooks
- the two catches that call setActionError or setError and return instead of
  throwing, in use-mobile-diff-review-interactions.ts and use-quick-commands.ts
- the call sites in files this branch does not touch (pr-ai-triage-launch.ts,
  mobile-diff-review-loaders.ts, github-pr-rpc.ts,
  github-pr-mutation-outcome.ts)

No golden moves: this touches no golden, adapter or recorder engine file.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile): re-record the goldens at the new baseline pin

One re-record of all 641 goldens against pin e7206f6 from a detached
worktree at that commit, with this branch's rpc-recording/ tree,
pilot-scenarios.json and scripts/rpc-recording.mts overlaid and only the
differing files copied in. The recorder's own fence passed: product sources
under mobile/src outside the recorder, src/shared and the lockfile were
byte-identical to the pin, with nothing untracked under the guarded trees.

Every golden now carries one baseline, one lockfileSha256 and one
recorderSha256. recorderSha256 moves on all 641 because this branch's recorder
tree adds adapters to main's, so main's own value could not survive the merge.
baseline moves on exactly the 121 goldens this branch adds, from c6a7216
to e7206f6.

595 goldens are header-only. The 46 bodies that move are all among this
branch's 121 and all gain the `sent` ordinal that stablyai#20884 added to effects,
verified field by field: each effect is byte-identical apart from the new key,
and no effect was added or dropped. None of main's 509 bodies move, and the
six-golden agentSession.structured-launch family does not move either.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
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