fix: keep cached chat layout stable through attach
A capped cached transcript could first show raw activity, then replace it with the folded completed turn when attach supplied its missing prompt. Preserve that prompt when capping a visited chat and prepare it during read-ahead so equal-data attach keeps the first rows and their layout.
Code cards keep visible text until the worker draws, with matching fallback font, header label and final-newline geometry. Authentication preflight keeps sending disabled and its tooltip, but no longer inserts then removes a 20px “Checking…” row above the composer. Actual sign-in failures retain their notice. The temporary row originated in #26643.
Static transcript previews now mount their complete supplied snapshot, with the host theme and font applied before React renders. Previously the gallery painted an empty shell and delivered its already-known rows in a later task. Delayed-host, New Tab and mock-daemon scenes retain their asynchronous startup. This corrects the gallery mount path; it does not establish native cold-open performance.
Current head 877032d08e0d4cee4c3a10681dcfdafa4ffb0fc6 merges base cd679bd6f02bd8984a855c1aefe5a8ecbc7a2d00. The sole conflict carries base's configureMessageLineLook call into applyPaneTheme, preserving message-row styling at initial mount and subsequent bridge updates. All other PR changes are retained. Independent Claude Opus 5.5 medium review passed at this exact head. The resolved theme configuration matches base's calls in order; the rest of the reviewed patch is unchanged. Host-safe lint and exact-range static checks passed. Focused fleet verification and the official webview verdict are pending.
Prior integration head 1400922180b7adaca6a5ca09b481bf4148da3599 passed independent Opus 5.5 medium review and focused fleet verification: 28 tests, 324 assertions, no skips, typecheck across 4,241 files, and scoped lint. Its three-round transcript metrics were Chromium 0.4 ms / WebKit 1 ms settle after paint, with CLS 0 in both. Those results are historical after this base merge.
The three apparent gallery shift regressions at 071a377 reproduce identically on its exact base when both use the same browser. Scoped attribution records completed renders, both matching named guard failures, and the experiment's final metadata failure; it is not a full-run pass. Browser setup is fixed separately by #33836.
Prior head 7049de3f0b623fd40fbc4c023792481bc46e05b8 had independent Claude Opus 5.5 medium SHIP. Paired first-mount verification at 7049de3f passed: 14 tests, 251 assertions, and typecheck across 4,212 files. Both baseline first-frame tests fail on the empty shell. The eight completed-turn/switch rows below were measured at 1339cad9; the preview rows were measured at 7049de3f before this base merge.
Leo's request:
"man me clicking into some of these workspaces and tabs / sometimes i see like / the text shows up right on click but the actual thing loads a second later / ... / you should be able to simply see the text rendered instantly wherever it is"
"even for remote things it should be fast"
Performance
| metric | before | after | delta | harness or run link |
|---|---|---|---|---|
| Cold-prefetched completed turn: swap frames | 65 | 0 | −65 | same-harness red/green, chat-switch-prefetch.test.ts |
| Warm capped completed turn: swap frames | 71 | 0 | −71 | same run, full first visit then capped revisit |
| Post-first-text shift score, cold/warm | 0.021789 / 0.021789 | 0 / 0 | −0.021789 / −0.021789 | same run, includes recent-input shifts and composer geometry |
| Code handoff: blank frames | 8 | 0 | −8 | same run, code-block-highlight-height.test.ts, held worker |
| Standard switch: unread first paint | 272.9 ms | 247.9 ms | −25.0 ms | benchmark, LATENCY=150 bun bench/chat-switch.bench.ts 3 300 |
| Standard switch: read-ahead first paint | 94.9 ms | 85.5 ms | −9.4 ms | same benchmark |
| Standard switch: unread/read-ahead shift | 0 / 0 | 0 / 0 | 0 | same benchmark |
| Standard switch: idle wakeups | 0 | 0 | 0 | same benchmark |
| Static preview: Chromium settle after paint | 139.7 ms | 0.5 ms | −139.2 ms | paired ui-stability at 7049de3f, 3 rounds |
| Static preview: WebKit settle after paint | 305 ms | 1 ms | −304 ms | same run, unchanged harness |
| Static preview: Chromium/WebKit CLS | 0 / 0 | 0 / 0 | 0 / 0 | same run |
| Static preview: Chromium navigation→settled | 793.4 ms | 766.2 ms | −27.2 ms | same run |
| Static preview: WebKit navigation→settled | 1269 ms | 1290 ms | +21 ms | same run |
| Static preview: idle wakeups/5 s, each engine | 1 | 1 | 0 | existing relative-time clock |
Same-worker production-path pair at 1339cad9 (historical, same seed/harness on cmux10s; HQ receipt):
| metric | base | head | delta | harness or artifact |
|---|---|---|---|---|
| Sidebar first content | 673.2 ms | 640.3 ms | −32.9 ms (−4.9%) | same-worker chat-open, n=3; base/head artifacts |
| Reopen first content | 638.7 ms | 640.2 ms | +1.5 ms | same harness |
| Restore first content | 2846 ms | 2759 ms | −87 ms | same harness; CEF startup dominated |
| Flashes | 0 | 0 | 0 | same harness; distinct from native swap/CLS |
These are historical production-path latency measurements, not native frame-strip swap or CLS evidence. The warm frame strip did not capture the CEF transcript, so native 0/0 remains unclaimed.
The standard benchmark has short turns and does not reproduce the capped-turn defect; the dedicated regression above does. Numbers compare the same source and harness with only this production patch reversed/restored. These are completed-turn browser results, not a claim that every fresh native or offline remote chat is one-render. Syntax-color changes remain #33523; unfinished cached turns remain #33529. #33580 owns persisted remote opener metadata and its peerCopy.ts adapter; this PR preserves #33155's peer-copy provenance and does not change storage.
Earlier production-path validation at 1339cad9: 48 targeted tests passed (202 assertions), with six expected baseline regressions. Typecheck hit seven existing errors in the unchanged streaming-no-flicker test from #33526; the correction is already on base (#33545), and verification with only that unchanged base test corrected found no type errors in 4,161 files. Independent Claude Opus 5.5 medium review: SHIP at 1339cad928dbefe2a0563fd6a68fe6de7dff562e. Host-safe web lint passed. The frame sampler records row text/rectangles, composer rectangle, width, scrollTop and scrollHeight through attach; its observer, frame callback and deadline are cleaned up. Production adds no timer or animation loop.
Scenes: agent-pane.transcript#conversation (static first mount); capped completed Codex turn in test/chat-switch-prefetch.test.ts; agent-pane.transcript#copy-last-code-block; test/browser/code-handoff-height.html. 2x light/dark scene captures were opened by the independent reviewer: readable cards without blank/clipped text; syntax colors are a later paint tracked separately. Reference: private codex/live/transcript-worked-for-collapsed-summary. Specs: leo-workspace/design/chat-transcript.md and design/composer.md (routine state belongs in controls, not added narration rows).
Risk: cached turn preparation and asynchronous code rendering. InitialChat is preview-only; production still calls mountAcpmux() without a seed. A future production initial-state caller must initialize the full receive/trust/harness/persistence path. The new first-frame tests use bounded frame samplers with cleanup and assert actual fixture text, row/line geometry, width and scroll across equal snapshot delivery. Send/auth behavior has explicit pending and settled regression coverage, including click, Enter, and the resend handle. One extra bounded opener read may run in background for a page that begins mid-turn; nothing new waits on the click.
Agent session: agent session
Webview health run 41667274334 finished its render steps. Two health shards reported only base-red attribution failures in Judge the red states against the base; logs name agent-pane.claude-desktop-tool-summary#failed-open and agent-pane.subagent-split-pair#default as red the same way on base cd679bd6f02b. No setup or render failure is attributed to this PR. The official webview verdict is complete; its only failures are the base-red states named above.