# Native sidebar render measurement

This is a real iOS development-client comparison, driven through the real server RPC and the native Hermes inspector. The replay provider is selected for synthetic threads. No database rows are inserted and no real provider turns are needed for the phone case.

The scenario runner's own documentation excludes timing regressions, so this comparison uses a manual native driver.

## Reproduce

1. Create separate worktrees for the two SHAs in the result and run `vp i` in each.
2. Run `python3 instrument-counter.py "$CHECKOUT"` on each. This leaves `HomeScreen.tsx` and `useSidebarRowThreadKey.ts` identical to that commit. It extends the existing development-only render counter, outside React render paths. Copy `sidebar-proof.mts` into `apps/mobile/scripts/` in each checkout.
3. Start the isolated server in each checkout with `T3CODE_DEV_SEED=0 T3CODE_ENVIRONMENT_LABEL=Proof vp run dev --host 0.0.0.0 --port <server-port>`.
4. Prepare and install the native client through `vp run mobile:install ios --prepare` and `vp run mobile:install ios --session <leased-session>`. Both commits have native fingerprint `c394983c2c31769beb0a79ffcb68d7cfae216b82`.
5. Start one Metro at a time: from `apps/mobile`, `EXPO_PUBLIC_T3_RENDER_COUNTER=1 vp run dev:client --port <metro-port>`. Open its Expo development-client URL on the leased device, then pair the server. Keep just the server under measurement connected; `__sidebarProofForget` calls the app's normal remove-environment command for disposable connections.
6. Mint a token with the server CLI (`auth session issue --base-dir .t3 --token-only`) into `<output-dir>/<side>-token`; never upload it. From `apps/mobile`, run `run-side.sh <side> <server-port> <metro-port> <output-dir> seed`. Run this once per side, on that side's fresh server. The driver creates Parent and Other through project and orchestration commands. The app also creates its normal empty New thread.
7. Run `run-side.sh ... open`, or open Parent from the home list. In portrait the thread covers HomeScreen. Confirm the source marker matches the commit, `visible` is false and `selection` is null. Wait for navigation to settle before recording.
8. Record the native screen with `agent-device record start ... --session <leased-session>`. Run `PROOF_RESULT=<new-run-directory>/<side>-phone.json run-side.sh ... measure > <new-run-directory>/<side>-phone-transcript.jsonl`. Stop the recording. Use the same physical simulator lease and the same instrumentation on both sides.
9. `python3 analyze.py <new-run-directory>` produces the measurement cards and summary JSON from the raw results.

## What is measured

Each side runs three batches of fifteen unrelated thread renames. Every action is `thread.metadata.update` on Other. Each observation window starts immediately before the command and lasts 2.5 seconds after the command returns. The driver reads the mobile client's actual quiet shell list after every window and aborts if its title has not changed to the requested value. It also checks the loaded source marker and reads back the persisted title from the server.

The existing counter's React commit hook uses `PerformedWork` to identify fibers React actually rendered. We count HomeScreen renders/commits and collect its fiber `actualDuration` for those renders. This includes the subtree work in that render. There is no profiler wrapper or mutation inside the measured component or hook. Unrelated background bursts are retained in the raw samples.

The result reports each batch's median, the median of those three medians, and the range of batch medians (max minus min). These are development React render-work timings, not end-to-end rename latency, release-build frame rates, or CPU savings. The screen recording documents the real native screen while the script drives updates; the JSON/transcript and measurement card contain the measured difference.

The initial wrapper-based exploratory measurements are excluded: putting render bookkeeping into HomeScreen could change the React Compiler's input. Only the counter-based runs are evidence.

## Tablet reproduction

The same iPad Pro 13-inch (M5) simulator, iOS 27.2, landscape 1376x1032, is used on both commits. After the phone runs, `delegate` dispatches a parent Replay message and a real `delegated_task.request` while its run is active. This creates a local delegated child through the orchestrator; both initial turns finish. `hold-child` then sends the Replay `question` fixture to that child and waits for its pending runtime request. This holds the child in the real shell list: idle local subagents are normally omitted by the server, so a completed local child cannot exercise the parent-row resolution. No mocked shell rows are injected.

Open the child with `PROOF_TARGET=child run-side.sh ... open`. Confirm the parent row is selected and the source marker is correct, then repeat the identical three batches of fifteen unrelated renames with `PROOF_PLATFORM` naming the tablet and `PROOF_RESULT` pointing to a new tablet result file. `__sidebarProofInspect` reads the mounted fibers outside React's render paths: it records the actual selected row props and the primitive hook snapshots. On the head, the sidebar row atom's useSyncExternalStore snapshot is the resolved parent key.

Stop the child first with `transition stop-child`: the server rejects archiving a parent with a running delegated task. The client keeps the already observed child shell, and its parent remains the selected row. Then run `transition archive` and `transition unarchive` to change the parent shell. Capture the UI and `__sidebarProofInspect()` after each action. The child remains open. Archive removes the parent highlight and changes the head's resolved-key snapshot to the child key; unarchive restores the parent key and row selection. Await each action and each native sidebar animation before starting the next capture; the stable transition captures keep HomeScreen hidden throughout. These controls are genuine RPC commands, not atom writes.

## Isolating an unchanged selected row

Visible split view must redraw when Other's title changes, independently of this hook. A second tablet run uses the app's existing **Maximize content** control. It hides the primary column and freezes its list props, while the mounted HomeScreen retains the selected child key and the same resolved parent row. This exercises the non-null, unchanged-row subscription without the necessary visible-list redraw. Repeat the same three batches and fifteen renames in this mode, with a separate `tablet-hidden` result and recording. The source marker, non-null selection, hidden HomeScreen flag, shell receipt, and resolved parent key are captured; no component or hook behavior is modified.

The `transition archive` and `transition unarchive` modes collect the before/after mounted-fiber snapshots, HomeScreen renders and render time, and the persisted parent archive state over the same 2.5-second observation window. Show the sidebar after archive to capture the actual visible result.

## Controls and limits

The visible split-view measurements are a control. Both sides have one median HomeScreen render per rename because the row title visibly changes. They do not demonstrate a timing improvement in that visible-list workload. The two performance comparisons are the hidden phone list with null selection and the hidden tablet list with an unchanged non-null selection.

The exact loaded SHA is checked on every measured action. `provenance.json` records hashes showing that both HomeScreen and useSidebarRowThreadKey match the commit under test. The instrumentation patches and scripts are included for audit. Raw samples retain every observation, including background commits; none are trimmed as outliers.

No release-build CPU, GPU or frame-rate claim is made, and Android is not measured. All published data and captures use synthetic projects and threads.
