Repository navigation
fix(ui): speed up warm chat reloads in Firefox - #196311
Conversation
Reuse validated, scoped snapshot cursors before the chat pane mounts. Admit early history from the live hello and include authorized approval replay in that same subscription. Preserve ordinary startup for missing, mismatched, retired, or late snapshots.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR requests warm chat history earlier using the validated saved cursor and authenticated early Gateway connection. Example: Reload a previously visited 400-message chat in Firefox on desktop.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a focused warm-reload improvement using existing owners; no definite introduced code defect was found, but current-head browser CI remains unresolved. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherControl UI startup passes a validated, account-scoped snapshot cursor to the existing early transport; the Gateway authorizes the subscription, and the foreground pane applies history and ordered events. flowchart LR
A[Saved chat snapshot] --> B[Startup admission]
B --> C[Early Gateway transport]
D[Authenticated hello] --> C
C --> E[Gateway subscription owner]
E --> F[Foreground chat pane]
Technical reviewBest possible solution: Keep the existing startup, transport, subscription, and pane owners while carrying the validated cursor forward and removing the redundant approval request. Do we have a high-confidence way to reproduce the issue? Source confirms that the base suppresses early history when a saved recovery scope exists, leaving the pane to initiate it; the supplied browser comparison reports the resulting delay, but no target code was executed during this review. Is this the best way to solve the issue? The change follows the smallest complete fix: reuse validated snapshot facts and the existing transport, preserve foreground ownership and fallbacks, and delete the second approval acquisition and duplicate hello state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bd63497962a1. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +11, Tests +130, Docs +2, Other +2. Total +145 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 9, 2026, 6:35 PM ET / 23:35 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* perf(ui): prefetch warm history after Gateway admission Reuse validated, scoped snapshot cursors before the chat pane mounts. Admit early history from the live hello and include authorized approval replay in that same subscription. Preserve ordinary startup for missing, mismatched, retired, or late snapshots. * refactor(ui): keep early history admission with one owner
What Problem This Solves
Warm chat reloads waited for the chat pane to start before requesting fresh history, even when the persisted snapshot and authenticated connection were already available. This delay was larger in Firefox.
User Impact
Previously visited chats become ready sooner while preserving the saved conversation, approval replay, and ordinary loading/retry paths.
Why This Change Was Made
Carry the validated snapshot cursor and history state to the existing early transport. Admit its initial subscription from the live hello after checking the recovery scope; the pane still owns applying the result. Missing, mismatched, retired, or late snapshots keep the normal foreground path. If the pane discovers different history parameters, it discards the early snapshot while retaining live delivery and fetches the correct history.
This removes the obsolete approval-upgrade request and the duplicate retained hello. The transport owns the hello; deferred adoption captures it and verifies its identity before delivery. The existing bootstrap owner gates cache preparation. Production code grows from 388 to 399 lines across the two affected modules; tests grow from 577 to 707 lines. No new cache, dependency, schema, or rendering state.
Evidence
Warm acceptance: pass, 20 rotated triplets in every cell (240 observations). All observations retained the cached admission, all 400 messages, a visible transcript and enabled composer, and exactly one history subscription.
Times are median / p95 milliseconds. Paired gain compares head with the midpoint of its two baseline controls.
Firefox improved in all 20 desktop pairs (all ≥20 ms) and 18/20 mobile pairs (17 ≥20 ms). Both Chromium cells improved in all 20 pairs. Head p95 is below both controls in every cell. One Firefox desktop control spike of 1,343 ms is retained; A/A exposes that host noise, while the desktop paired gain is at least 54.5 ms in every pair.
The desktop median excess over 1.3× contemporaneous Chromium falls from 184.4 to 133.7 ms: 72.5% of that median excess remains. Head's paired engine ratio is 1.89×; all 20 pairs remain above 1.3×.
The mobile median excess over 1.3× contemporaneous Chromium falls from 158.4 to 143.0 ms: 90.3% of that median excess remains. Head's paired engine ratio is 1.94×; all 20 pairs remain above 1.3×.
Earlier history dispatch leaves Firefox’s longer pre-connect interval and the rest of the startup/rendering critical path. The residual pre-history interval includes snapshot readiness and queued work; this run does not isolate their shares. This is not an engine floor. Chromium also gets faster, so the relative 1.3× target moves.
Cold guard: 20 triplets per cell across two ten-pair cohorts; all 240 observations pass. Median differences stay within 3%. Every cold load uses one history subscription at head versus two on base. This is a regression guard, not a claimed cold-start speedup.
Cold Chromium desktop p95 is 0.8% above its faster control (3.5 ms), below the other control and within A/A noise. No samples were dropped.
Chromium CPU counters resolve the cold wall-time tail noise. The mobile cold wall p95 is 410.2 ms versus 404.2/400.3 ms, while renderer TaskDuration is 449.45 ms median and 477.97 ms p95 versus 455.72/480.83 and 449.47/487.19 ms on the controls. CPU tails improve despite the wall-time variation. Firefox mobile cold p95 is 504 ms versus 501/515 ms; its 0.6% movement against the faster control is below the campaign's 1% noise threshold.
The untraced benchmark also records Chromium main-thread CPU with
Performancethread ticks. Paired median changes (head versus the midpoint of its controls):No CPU win is claimed; these stay within the 5% band. Firefox CPU counters are unavailable in this harness. The acceptance claim is the measured warm latency gain, with unchanged request counts and bounded handoff behavior.
The acceptance rule is a repeatable Firefox warm-boot gain of at least 20 ms, with Chromium no worse than the 5% median band and no worse p95. The 20-pair warm comparison uses the committed engines benchmark, a synthetic 400-message conversation, an admitted persisted snapshot, fresh headless browser processes, and rotated base/head/base arms in Chromium and Firefox at desktop and mobile viewports. Readiness requires the visible transcript and enabled composer. All observations are retained; A/A measures host noise.
pnpm ui:buildand the strict base/head performance comparison pass without changing any limit. The base has existing total-CSS and New-route overages; unchanged CSS and the 44 B New-route delta fit the existing 64 B comparison variance. Chat stays below its absolute cap. Source-map contents were checked against both changed production files.Focused proof: 17 application tests and 15 transport tests pass; the warm early-request regression fails on the original production source. UI typecheck, targeted lint/format, production Knip, and independent P0–P3 review pass. The tests cover cursor admission before/after hello, wrong cache, retired scope, late foreground handoff, single hello delivery, approval replay, buffer limits, FIFO, reconnects, and failed authentication.
WebKit remains an explicit gap: the initial and closeout headless launch attempts both timed out after 15 seconds. No Testbox/Crabbox lease was used.
Phase diagnosis and reproducible timing workload
The diagnostic bundle showed snapshot validation finishing before runtime/history admission in both engines and both viewports. These instrumented single observations identify ordering only; they are excluded from acceptance timings.
All times are milliseconds from navigation. A busy host makes these unsuitable as an absolute engine floor.
Intervals are median / p95 milliseconds, computed within each observation before summarizing. Interval medians do not add to the total.
Time after the history response increases because the response now arrives while the application is still loading. Overall readiness, not that shifted interval, is the outcome metric. This is a synthetic transport/UI workload; it does not measure real server approval-preparation cost or model-provider latency.
Build base
a8d7470fbdcc8c9558dda60a9571697d3976f3f9and head126ea40c075with the same installed toolchain, then run:CI attribution (run 42719661858, attempt 1)
The full UI run exposed four failing cases across three shards. The reviewed head remains unchanged.
The new-session baseline reproduction retains the original case and assertion and changes only network ordering. Source maps for all six relevant owners match base
a8d7470; its recovery owners and test are unchanged through CI's main parent93f9678. The likely cause is the existing reload-authority check: the hello handler replaces the connection object while an initial-render recovery awaits its document probe. CI's screenshot has the same persistent error panel and one navigation, but CI did not capture probe timing or connection identity; that exact causal link remains inferred. No failure-rate claim is made.These failures remain recorded as failed CI and are qualified for the native inherited-failure route. No checks, guards, or timeouts were weakened. The layout assertions and render-recovery race remain separate follow-up defects. Local focused E2E used the owning fixture build; an earlier performance-bundle reuse was unsuitable for that fixture and is excluded from proof.