Skip to content

fix(ui): speed up warm chat reloads in Firefox - #196311

Merged
steipete merged 2 commits into
mainfrom
solid2/w-perf-firefox-warm-1109
Nov 9, 2026
Merged

steipete merged 2 commits into
mainfrom
solid2/w-perf-firefox-warm-1109

Conversation

@steipete

@steipete steipete commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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.

Engine / viewport Base R Head Base C Paired gain Absolute A/A
Chromium desktop 255.8 / 271.4 227.3 / 245.4 248.3 / 277.9 24.6 ms (9.8%) 9.1 / 30.6
Firefox desktop 514.5 / 545.0 431.5 / 453.0 500.0 / 569.0 82.0 ms (16.2%) 22.5 / 70.0
Chromium mobile 253.4 / 269.3 218.7 / 246.1 251.4 / 271.0 31.2 ms (12.7%) 7.2 / 24.6
Firefox mobile 492.5 / 559.0 424.5 / 490.0 477.5 / 501.0 64.5 ms (13.2%) 18.0 / 88.0

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.

Engine / viewport Base R Head Base C Paired head change Absolute A/A
Chromium desktop 407.1 / 581.1 392.8 / 432.3 394.6 / 428.8 -2.0% 15.6 / 193.2
Firefox desktop 467.5 / 551.0 470.0 / 512.0 489.0 / 525.0 -2.8% 17.5 / 80.0
Chromium mobile 382.0 / 404.2 375.1 / 410.2 371.1 / 400.3 0.5% 13.0 / 25.8
Firefox mobile 472.5 / 501.0 473.0 / 504.0 469.0 / 515.0 -1.8% 32.0 / 62.0

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 Performance thread ticks. Paired median changes (head versus the midpoint of its controls):

Workload / viewport Script CPU Renderer task CPU
Warm desktop +2.6% +0.6%
Warm mobile +2.4% +0.5%
Cold desktop −0.7% −0.6%
Cold mobile −0.1% −0.4%

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.

Size / requests Base Head Change
Startup JS gzip 91,766 B 91,810 B +44 B
Chat boot JS gzip 1,298,479 B 1,298,523 B +44 B
New boot JS gzip 803,731 B 803,775 B +44 B
Startup CSS requests 1 1 0

pnpm ui:build and 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.

Engine / viewport Snapshot ready Runtime start Pane history admission History requested Ready
Chromium desktop 76.6 160.7 162.4 205.2 285.7
Firefox desktop 490 603 605 660 816
Chromium mobile 64.4 135.7 137.2 178.3 257.3
Firefox mobile 218 298 300 352 508

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.

Engine / viewport / arm Start → connect response Connect response → history request Request → response Response → ready
Chromium desktop base 48.8 / 61.9 131.0 / 138.9 45.6 / 49.5 28.5 / 31.6
Chromium desktop head 49.6 / 62.8 15.6 / 53.1 40.5 / 44.7 118.5 / 125.9
Firefox desktop base 128.0 / 132.0 230.5 / 260.0 113.0 / 123.0 41.0 / 60.0
Firefox desktop head 124.0 / 129.0 68.0 / 80.0 55.0 / 61.0 182.0 / 197.0
Chromium mobile base 56.3 / 64.2 123.7 / 133.1 47.9 / 51.8 27.8 / 29.7
Chromium mobile head 55.3 / 63.6 14.2 / 55.4 41.8 / 48.4 109.6 / 123.3
Firefox mobile base 128.0 / 154.0 214.0 / 254.0 105.5 / 122.0 40.0 / 51.0
Firefox mobile head 124.0 / 140.0 69.0 / 98.0 53.5 / 85.0 181.5 / 190.0

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 a8d7470fbdcc8c9558dda60a9571697d3976f3f9 and head 126ea40c075 with the same installed toolchain, then run:

node --import ./scripts/tsx.mjs scripts/bench-control-ui-engines.ts \
  --bundle-dir /path/to/base --compare-bundle-dir /path/to/head \
  --control-bundle-dir /path/to/base --engines chromium,firefox \
  --viewport both --steps warm-boot --pairs 20 --fresh-browser \
  --output .artifacts/firefox-warm/acceptance

Before desktop warm reload (synthetic)

After desktop warm reload (synthetic)

Before mobile warm reload (synthetic)

After mobile warm reload (synthetic)

CI attribution (run 42719661858, attempt 1)

The full UI run exposed four failing cases across three shards. The reviewed head remains unchanged.

Case Baseline evidence
Native conversation: keeps a single web conversation with in-page native navigation and Dashboard handoff Same case and line 241 assertion fail in scheduled main run 42711813458, job 129483629458: header height 56 px rather than 64 px. Main uses shard 3; this PR uses shard 5.
Session ownership: aligns Person left status at 1200 px Same case and line 370 assertion fail in main job 129483629440: spacing 14 px rather than 13 px.
Session ownership: aligns Person left status at 390 px Same case and assertion fail in that main job.
New Session revisit: restores the composer after a render failure (persistent: false) The original base bundle reproduces the same composer timeout when a 2 s connect response and 2.5 s document-probe delay make the probe cross hello. Both delays finish before the 10 s assertion. Boot count stays 1 with a connected Gateway and the error panel remains. Normal local runs pass once on both base and head.

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 parent 93f9678. 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.

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.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: M labels Nov 9, 2026
@steipete
steipete enabled auto-merge (squash) November 9, 2026 23:27
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

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

  • Before: The reported synthetic benchmark measured 514.5 ms median readiness while history waited for pane startup.
  • After: The reported candidate measured 431.5 ms median readiness with one history subscription.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-consistent patch with useful browser measurements, limited by the synthetic server boundary and unresolved current-head CI attribution.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Previously visited chats wait unnecessarily for pane startup before requesting fresh history, especially in Firefox.
Reason: The maintainer-authored direction has measured user value and preserves existing product contracts without introducing configuration or another state owner.

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
Reviewed head: 126ea40c075d03f0a91e2f50dfa1479da7799a10

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply the scoped performance guide's isolated real-Gateway warm-reload comparison, including approval replay, with redacted timing and subscription output; the supplied benchmark uses a synthetic Gateway.
Agent review details

How this fits together

Control 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]
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4420648 adds ui/src/api/gateway-boot.ts:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4420648c4046; files: ui/src/api/gateway-boot.ts)

PR surface

Source +11, Tests +130, Docs +2, Other +2. Total +145 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 67 56 +11
Tests 2 154 24 +130
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 6 225 80 +145

Preflight source

Source 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

Metric Value Why it matters
Production versus regression coverage Production +11 lines; tests +130 lines The production growth carries existing snapshot facts; the tests distinguish pre/post-hello admission, wrong cache, retired scope, late handoff, and duplicate hello delivery.

Labels

Label changes:

  • add P2: A measured warm-reload latency improvement with ordinary fallback paths and limited user impact.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A measured warm-reload latency improvement with ordinary fallback paths and limited user impact.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Classify the failed browser scenarios using matching base evidence before assigning any repair to this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 9, 2026, 6:35 PM ET / 23:35 UTC.

@steipete
steipete disabled auto-merge November 9, 2026 23:41
@steipete
steipete merged commit 8861d63 into main Nov 9, 2026
116 of 124 checks passed
@steipete
steipete deleted the solid2/w-perf-firefox-warm-1109 branch November 9, 2026 23:47
@steipete

steipete commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui ci:full Keep ordinary native-locale CI selection on the next PR run. docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant