Repository navigation
perf(ui): reduce New Session payload and repeated settings reads - #136362
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 12:34 PM ET / 16:34 UTC. ClawSweeper reviewWhat this changesThis PR reduces New Session startup assets, splits Chat-only presentation into lazy modules, and replaces render-time settings reads with a token-free preference snapshot bound to the connected Gateway. Merge readinessKeep this PR open: the reviewed branch has a coherent Control UI ownership refactor with no supported blocking code finding, but it changes persisted-preference scoping and is maintainer-labeled; exact-head CI is still queued and an owner should confirm the documented upgrade semantic before landing. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI loads browser preferences while connecting to a Gateway, then supplies them to New Session and Chat composers. This change makes the theme runtime the mounted preference owner so rendering consumes a live snapshot instead of repeatedly reading browser storage. flowchart LR
A[Browser storage] --> B[Gateway-scoped preferences]
C[Connected Gateway] --> B
B --> D[Theme runtime]
D --> E[New Session composer]
D --> F[Chat composer]
G[Cross-tab preference edit] --> B
Decision needed
Why: This is an intentional compatibility-sensitive change to persisted browser preference resolution, and the PR carries the maintainer label. Before merge
Agent review detailsSecurityNone. PR surfaceSource +63, Tests +656, Docs +4. Total +723 across 78 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one token-free, Gateway-scoped preference owner and land only after its documented scope behavior is accepted and the queued exact-head validation completes. Do we have a high-confidence way to reproduce the issue? Not applicable as a defect report: this PR is a performance and ownership refactor, and its stated storage-read and cross-tab scenarios have focused branch coverage. Is this the best way to solve the issue? Yes, subject to the owner confirming the persisted-preference scope: a single mounted, token-free snapshot removes repeated consumer reads more cleanly than adding caches at each composer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1623683f478b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
b3a6fb2 to
04be37f
Compare
|
Addressed the review and rank-up items in head Pending titlebar inset: I checked the exact reviewed build
The browser CSSOM puts the shared I therefore did not reorder production CSS speculatively. I did add the requested coverage: the existing 16-case pending matrix now compares the scroll container's padding before submission and while the pending Chat classes are applied. This protects the titlebar drag band and side inset across viewport/theme/motion/content variants. The containing browser file passes all 21 tests; the targeted changed gate and fresh P0-scoped review also pass. Attached before/after desktop and pending mobile captures were inspected and contain only synthetic data. Main conflict: rebased onto The original head's |
|
Verification and scope confirmation for current head Maintainer scope decision: the connected Gateway is intentionally authoritative for a mounted tab's display preferences. This is the accepted live Gateway-scoped owner refactor requested for this work, not a new unresolved product option. The persisted selector still chooses the initial connection before an owner binds; same-Gateway edits propagate across tabs, another Gateway's selector does not retarget an already connected view, and explicit scope reads stay explicit. Existing preference keys and serialized values are unchanged; no storage migration or new configuration is introduced. The refreshed 48-navigation comparison is recorded in the updated PR body, with all earlier series retained: New cold 532.40 → 522.85 ms, New warm 165.95 → 169.90 ms, Chat cold 664.55 → 669.30 ms, Chat warm 193.50 → 195.60 ms. No browser errors; optional panels remain lazy. New saves 123,348 raw JS bytes +147,107 raw CSS bytes; Chat saves 123,030 raw JS bytes, with 556 more CSS bytes. This is a payload/hot-path win, not an across-the-board latency claim. Fresh real-Gateway replay passed PTY first-open/restoration and shortcut isolation, session creation, partial streaming through explicit settlement, history after reload, and one initial project/environment lookup each. Typing reads no browser settings; streaming reads only the existing first-reply confetti key. Separate cross-tab shortcut/microphone/theme, A→B→A and actual WebSocket reconnect proof passed, retaining draft/preferences and excluding tokens from display snapshots. The preserved upstream naming disclosure is visible in the refreshed recording. All media here is inspected, synthetic-only, and recorded against isolated owned Gateways. Validation includes the earlier complete 877-file/13,790-test UI suite and 352-file/1,540-test browser suite, followed by 97 unit/44 browser cases for the renderer integration and 21 browser cases for inset preservation. Complete changed checks, canonical boot generation, architecture/style checks, unchanged build budgets, the full independent build, and fresh scoped autoreviews passed. Exact commands, source qualifications, prior failures and proof limits are in the body and review response. The Gateway fixture failure was reproduced in the original 19-file order (313 passes/one failure →314 passes) and independently reviewed. The canonical snapshot-publication fix landed in PR #136354; this branch reuses it and retains the deterministic regression only. The canonical-helper replay passed 146 tests plus changed checks, without changing production agent validation. Land-ready: CI run33654494095 completed successfully on exact head attachment-3078988656.mp4 |
Keep phone formatting and transcript-only styles out of New Session startup. Bind token-free presentation preferences to the mounted Gateway, carry them through composer renders, and suppress unchanged agent publications. Reuse the canonical authenticated-hello recovery owner from #133789 and retire stale discovery tasks synchronously. Proof: isolated full build and changed-file checks, focused preference/discovery tests, 93-state CSS parity, real Gateway PTY/create/stream/settle/history flow, and independent P0-scoped autoreview. The final broad suites and matched timing measurements remain in progress before publication.
Assert that the pending Chat classes preserve New Session scroll padding across the existing viewport, theme, and motion matrix. Browser CSSOM checks on the reviewed build and baseline confirm the shared stylesheet precedes New Session overrides; no production cascade change is needed.
Keep mutable testState agent entries in the pinned snapshot before real-IO readers or admitted runs can observe an RPC refresh. Extend the managed-worktree case with the observed interleaving, preserving agent validation and initial/follow-up cwd assertions. Controlled original-order proof fails before the helper repair and passes all 314 cases afterward.
0a6efe4 to
5d0eeab
Compare
|
Merged via squash.
|
…nclaw#136362) * perf(ui): streamline startup runtime ownership Keep phone formatting and transcript-only styles out of New Session startup. Bind token-free presentation preferences to the mounted Gateway, carry them through composer renders, and suppress unchanged agent publications. Reuse the canonical authenticated-hello recovery owner from openclaw#133789 and retire stale discovery tasks synchronously. Proof: isolated full build and changed-file checks, focused preference/discovery tests, 93-state CSS parity, real Gateway PTY/create/stream/settle/history flow, and independent P0-scoped autoreview. The final broad suites and matched timing measurements remain in progress before publication. * test(ui): preserve pending session titlebar insets Assert that the pending Chat classes preserve New Session scroll padding across the existing viewport, theme, and motion matrix. Browser CSSOM checks on the reviewed build and baseline confirm the shared stylesheet precedes New Session overrides; no production cascade change is needed. * test(gateway): publish RPC fixture config before yielding Keep mutable testState agent entries in the pinned snapshot before real-IO readers or admitted runs can observe an RPC refresh. Extend the managed-worktree case with the observed interleaving, preserving agent validation and initial/follow-up cwd assertions. Controlled original-order proof fails before the helper repair and passes all 314 cases afterward.



Related: earlier startup reduction. Builds on the landed authenticated-hello recovery owner.
What Problem This Solves
New Session downloads optional phone formatting and Chat-only presentation. Typing and streaming repeatedly hydrate browser settings, including credential storage, although rendering only needs display preferences. Another tab's persisted Gateway selector can influence those unscoped reads.
Pending-start content must remain styled before Chat loads: submitted Markdown/JSON, images/files, and the working indicator are genuine New Session content, not removable payload.
Why This Change Was Made
Reuse the application theme runtime as a live, token-free, mounted-Gateway preference owner, and carry prepared values into New Session and Chat. Publish agent state only when its existing connection lifecycle changes; retire obsolete project/cloud Tasks synchronously rather than after rendering.
Give optional phone formatting its own stable chunk. Share passive message/composer styles while keeping Chat workbench styles lazy. Ordered style-module imports replace CSS inlining, avoiding duplicate shared sheets. Preserve the current-main title-preparation/extracted-renderer, side-panel/workboard, and authenticated-hello ownership boundaries.
User Impact
Less initial JavaScript/CSS, no repeated settings/credential reads during typing/streaming, and live preferences that remain attached to the actual Gateway across tabs, switching and reconnect. Existing pending messages and Chat layouts retain their appearance.
This is a payload/hot-path improvement, not a universal latency speedup: the final cold-New median improves 9.55 ms, while cold Chat is 4.75 ms slower and warm modes remain close. No new configuration, dependencies, schema, persistence representation, compatibility path, timeout increase or budget relaxation.
Evidence
Current head:
5d0eeabd86c287fdd1ddc7abd2c4e52d280d8400, based onad3268ecccbc7758878662b31adcd72475343d3e. Production commit61652274f6cdc7a2c033794531160bc73a7098fcwas fully built in an independent clean checkout and used for the measured/live pair below against9ab092370d5ac819029a04d32c6df55b33c8d241. Later revisions incorporate newer main and test-only coverage; no further performance implementation change is claimed or hidden in those measurements. Hosted validation: exact-head CI. Native prepare/merge must verify its successful completion.Final matched measurement
Six alternating baseline/candidate samples per route and cold/warm mode: 48 navigations, fresh cold contexts and warm reloads, 1440×1000 Chromium, service workers blocked, identical 120 synthetic sessions/40 messages, verified 50 ms HTTP and RPC delay, eight-second observation. No task-owned builds/tests ran concurrently. No browser errors; closed optional panels remained lazy. Composer time is the first frame with a visible, in-viewport, enabled textarea—not model latency or painted-pixel timing.
New saves 123,348 raw JS bytes and 147,107 raw CSS bytes. Chat saves 123,030 raw JS bytes, with 556 additional raw CSS bytes. Brotli New JS/CSS: 870,709/89,197 → 842,260/70,780 bytes. Chat: 1,113,009/91,484 → 1,084,689/94,058 bytes. Phone code is absent from initial route maps; lazy settings/channel formatting remains covered.
All samples and prior series are retained. The preceding corrected series had cold-New −7.95 ms/cold-Chat +12.5 ms. Two earlier series had cold-Chat +33.35/+22.5 ms under a flawed advertised RPC-delay fixture: a constructor returned another object, bypassing a subclass
sendoverride. HTTP delay was applied. The RPC fixture was fixed and independently measured at about 50–51 ms before both corrected series. Results are not discarded or pooled across setups. Network/CPU/source investigation did not establish a new serial CSS or preference-readiness gate; no speculative preload workaround was added.Real behavior and visual proof
Fresh isolated real Gateways and a synthetic OpenAI-compatible provider ran the rebased production build. Passed: avatar rendering, one initial
projects.listandenvironments.list, real PTY first-open/restoration, Ctrl+Backquote not reaching PTY input, session creation, visible streaming, explicit settlement, history after reload, and no false Gateway-change warning. Typing storage reads{}; streaming reads only the existing first-reply confetti key once—no settings/selector/token reads.A second real flow passed cross-tab shortcut/system-default microphone/theme changes, specific fake-device selection within its tab, A→B→A preference isolation/restoration, and real WebSocket reconnect retaining the same owner, draft and preferences. Display snapshots exclude the token. No browser errors. Fake device IDs differ across tabs even without OpenClaw; specific-device cross-tab identity and physical recording are not claimed. No live WhatsApp action or operator state/service mutation.
The real-profile DevTools relay was unavailable. This is explicitly isolated Playwright against real owned Gateways, not real-profile MCP verification. Selected captures and full video contact sheets were inspected for synthetic-only content. Earlier media below remains labeled; refreshed live recording is in the verification comment.
Tests, review and integration
Principal commands:
Benchmark/live drivers and all attempts are retained under
.artifacts/startup-followup; they are proof artifacts, not new product interfaces.Broader proof repaired incomplete preference fixtures, an Oklab-as-RGB test sampler, floating-Inbox stylesheet-order dependence, premature responsive-shell sampling, and synthetic catalog scrolling that bypassed reader takeover. Assertions remain strict; controlled failing-before/passing-after evidence and the failed full-suite attempts are retained. The final complete browser run is a separate clean invocation. An unused import found by changed checks was removed and the full gate replayed.
ClawSweeper response and native-inset proof: the reported inset regression was not reproduced in the exact reviewed bundle or baseline. Both retain desktop
50px 12px 6pxand mobile52px 8px 12pxbefore/pending. CSSOM confirms shared styles precede the New override. Added the requested coverage, resolved the actual upstream conflict, and did not make an unnecessary production reorder. Both rank-up items are addressed.CI also exposed a test-fixture configuration race: after
rpcReqcleared its snapshot, real IO could pin a disk-only config before the admitted turn prepared, omitting the synthetic agent. Controlled original-order proof went from 313 passes/one failure to 314 passes; nine fixture siblings and 29 scoped checks passed. The identical helper fix then landed canonically in PR #136354. This branch reuses that helper and retains the deterministic regression only; the canonical-helper replay passed 146 tests in three files plus its changed checks. Production agent validation is unchanged.An early head's
security-fastfailed downloading public pre-commit hooks before its key scan ran. The next attempt had 63 failed jobs with zero executed steps; its only executing-check failure was the fixture race above. Neither is a secret finding. The current exact-head CI must pass normally—no gate bypass or global runner-setting change.Scope and line accounting
78 paths: production +7,384/−7,285 (net +99), tests/support +1,107/−451 (net +656), generated +13/−49 (net −36), docs +4. Most churn is stylesheet movement (CSS net +3). Remaining production growth supplies explicit token-free preference lifecycle/write/storage ownership, not a parallel cache or settings path. No changelog/release changes.
Earlier inspected before/after media
These captures are from the preceding
b3a6fb2078f8comparison, before the upstream naming-feature rebase. They demonstrate preserved presentation, not a redesign. The final rebased flows were also rerun and inspected.attachment-3206421301.mp4