Repository navigation
perf: reduce first-visit work outside chat - #183367
Conversation
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10c4763ae8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs maintainer review before merge. What this changesThis PR defers optional Settings and Automations editors, prepares existing data owners on navigation intent, and paints route-matched loading frames. Example: First visit to Settings → Appearance under the recorded remote HTTP profile.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: the measured performance improvement is useful and owner-directed, and the prior Cron finding is resolved; current-head CI still needs failure attribution. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Control UI receives browser navigation, loads route code and Gateway data through scoped owners, and renders the requested screen through Solid. flowchart LR
A[Browser navigation] --> B[Route preparation]
B --> C[Existing config and session owners]
B --> D[Lazy editor modules]
C --> E[Solid page rendering]
D --> E
F[Static route frame] --> E
Technical reviewBest possible solution: Retain the measured lazy-loading changes and existing data owners, with the repaired Cron consumers and normal exact-head CI gates. Do we have a high-confidence way to reproduce the issue? Current-main eager imports establish the unnecessary first-visit work, and supplied browser measurements exercise it; no target code was executed during this read-only review. Is this the best way to solve the issue? Deferring optional editors through existing Solid boundaries and preparing the existing managed owners is an appropriate focused solution; no unnecessary replacement state owner was found. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dd42213508b9. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +467, Tests +162, Docs +12, Other +37. Total +678 across 30 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
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 HistoryReview history (1 earlier review cycle)
Reviewed October 25, 2026, 3:42 AM ET / 07:42 UTC (Revision 2). |
|
Addressed the Cron lazy-render consumer finding in 9192665, retained in final head 372db57. All 30 prior Cron failures plus both alias-consumer cases pass. Helpers wait for real lazy readiness, and suggestion fixtures enter the editor without weakening assertions. The redundant Sessions mocked call-shape case is removed; the browser intent evidence proves one pre-activation request with no duplicate group. The PR also records the exact Settings base collection-block limitation and the passing unchanged head test. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Use the admitted route to end inactive plugin presentation scopes while rendering is retained. Keep abort-owned asset disposal and fence callbacks against the same live scope. Align the service-worker production fixture setup with the shared E2E hook budget.
Preserve main mobile Settings readiness while retaining intent timing. The prior exact-head full CI passed; the merged head will receive refreshed asset proof and full CI.
|
Merged via squash.
|
* perf: reduce first-route loading work * perf: record measured route-readiness byte tradeoff * test(ui): await lazy views in route readiness coverage * test(ui): remove redundant intent call-shape coverage * test(ui): preserve owner-only cron settlement timing * test(ui): prepare runtime before streaming mutation checks * perf: refresh measured route startup baseline * refactor(ui): keep settings renderer private to its route * test(ui): prepare structured media fixtures before cases * fix(ui): retire inactive Memory settings presentations Use the admitted route to end inactive plugin presentation scopes while rendering is retained. Keep abort-owned asset disposal and fence callbacks against the same live scope. Align the service-worker production fixture setup with the shared E2E hook budget. * chore(ui): record merged route readiness baseline
What Problem This Solves
Settings downloads unrelated editors before Appearance becomes usable, Cron downloads its job editor before showing the list, and cold non-chat routes initially paint a chat-shaped loading frame.
User Impact
First visits to Settings and Automations load less code. New Session, Sessions, Settings, and Automations paint a route-matched frame before JavaScript arrives. Hover/focus preparation uses the existing scoped owners, including the Settings command menu.
Why This Change Was Made
Keep the config/draft, session-list, and Cron owners authoritative. Split optional Settings sections and the Cron detail editor with Solid
lazyand visible retry boundaries. Navigation intent fills the same managed Sessions window and config/schema owners that the mounted routes consume; retained snapshots keep their existing revalidation lifecycle. No second data cache, eager page registration, or shared-capability lifecycle change.The 600 ms Settings/Cron target remains a follow-up goal. This change removes unnecessary first-visit work; it does not eliminate the remaining route-chunk and Gateway-request latency. In a representative head timeline, the first Settings config reads still begin about 1.1 s after activation (base: 1.4 s); Cron reads begin around 0.69 s (base: 0.73 s). Reaching 600 ms needs earlier route preparation and request admission.
Evidence
Acceptance was recorded before measurement: serial interleaved baseline/candidate pairs, a separate A/A control on this loaded Mac, median/p95 readiness and renderer CPU, unchanged request ownership, no chat regression, and no added layout shift. Production HTTP delivery uses the synthetic team-scale Gateway transport, 35 ms default RPC replay, cold HTTP cache, and 100 ms RTT / 10 Mbps HTTP shaping. These are renderer/transport-fixture measurements, not live-provider latency.
Remote, 20 interleaved pairs. Readiness and CPU are median / p95 in milliseconds:
Settings readiness improves 15.8%, script CPU 6.1%, and task CPU 8.3%. Cron readiness improves 4.6%. Chat task CPU moves +0.5% with a slightly lower p95. The isolated Sessions tail from the first ten pairs disappears at twenty pairs.
Localhost, 20 interleaved pairs, same cold-cache workload and 35 ms RPC replay:
Local readiness medians stay within the 5% band or improve, with every readiness p95 lower. Task CPU medians range from −3.6% to +2.1%; Chat task p95 is +0.02%, Sessions +1.7%. Chat script median is +0.06%, p95 +2.7%. The first ten pairs had isolated Chat/Sessions CPU tails; all samples remain in the 20-pair table. The A/A control demonstrates substantial transient task-CPU variability; no GC attribution is claimed.
New Session held-assets capture (one sample each, layout/paint proof): FCP 164→168 ms, first static shell 152→152 ms, CLS 0.001592→0.001139. This establishes route-correct pre-JS paint with no added CLS in the captured transition; it is not a stable latency estimate.
Intent behavior: two additional remote base/head pairs, with a configured 150 ms hover/focus dwell (recorded total dwell 218–462 ms including automation). The head starts the Sessions list request before activation in both pairs and issues it once; base starts it after activation. Per-action RPC counts remain 2 / 7 / 5 for Sessions / Settings / Cron, with no duplicate request groups. Settings code/owner preparation begins on intent, but its config RPCs still start after activation at this dwell. These four runs establish request behavior, not a stable timing estimate.
The A/A control's Cron p95 wall/task movement was +13.5%/+28.5%; CPU and structural counts therefore accompany the timing results. CPU/RPC collection continues through the harness's 750 ms idle settlement; wall readiness ends at the first frame with visible enabled controls. Settings readiness explicitly requires its font control to be enabled.
The startup baseline is set to the actual measured head through the performance checker's reasoned update path, accepting the small byte increase for the measured readiness/CPU win. The unchanged CSS overage on the base is preserved; no unrelated cap increase.
Local proof:
pnpm tsgo:ui; focused mount-fallback/Sessions route tests plus the Settings held-import regression; targeted UI lint and formatting; production Knip; same-host base/head production builds and strict asset comparison; two independent scoped-clean reviews. The Settings regression proves Appearance remains usable while the generic schema-editor import is held and switching back eventually renders the real field.Touched files on the final follow-up head: 13,735 → 14,458 LOC (+723; 38 touched files). CI-driven test synchronization adds 36 net lines, and removing the redundant Sessions preload call-shape test removes 27. Later changes preserve the measured rendering behavior while repairing tests and removing two unused exports. Static-route CSS accounts for most growth. Settings itself adds 64 production lines. Solid census: Settings lazy registrations 0→8; effects/listeners/DOM queries/owner APIs remain zero; memos 11→11, local signals 1→1, optimistic signals 2→2, actions 1→1, intentional
untrack1→1. No owner-state copies.Reproduction
Baseline:
e8b251188f502b088dd037936062a1711ea302e1. Candidate production code:101d25fc9de, with only the 2 px mobile static-frame inset correction separating the timing bundle from the final capture bundle; route runtime is unchanged. Both production builds used Node 26.12.1 on the same Mac,NODE_DISABLE_COMPILE_CACHE=1 OPENCLAW_BUILD_CACHE=0 pnpm ui:build.Run twice serially for 20 remote pairs. Omit network shaping for localhost. Intent proof adds
--critical-path-intent-ms 150; activation-to-ready and total intent-to-ready remain separate. Strict asset check:pnpm ui:check-performance --dist /absolute/head --base-dist /absolute/base(passes after the measured baseline update).New Session capture: same production HTTP profile with
--boot-route new --runs 1 --first-load --cold-http-cache --hold-boot-assets --filmstrip-only.Screenshots
Inspected synthetic-only production HTML captures, with boot assets held. Desktop 1719×1179 and mobile 390×844; chat's static PNGs are byte-identical on both viewports. Representative settled Appearance screenshots are pixel-identical.
CI follow-through
The first full PR run (
40171157362, head10c4763ae8bdb19826213d96973372457ae3e0fb) exposed Cron tests that assumed synchronous detail rendering. Shared test settlement now waits for the actual lazy editor; suggestion assertions enter the editor that owns those lists. All 30 failing Cron cases passed locally, as did two additional alias consumers found by the caller audit. The forwarded-stream disclosure test reproduced its CI failure locally and passes after waiting for the existing asynchronous rendering transition. The Muse Code provider-access fixture now waits for the existing config/provider readiness helper; its exact case passed locally before and after (the intermittent CI race was not reproduced). No assertions were removed, timeouts increased, or production behavior changed by these repairs. UI typecheck, touched-file formatting, and scoped lint passed for the repair batch; a fresh independent review found no actionable P0–P2 findings. All nine browser E2E shards and both real-Gateway shards passed in the first full run.The Skill Workshop failure is inherited from scheduled main run
40170194218: the sameshows a failed configuration read and retries only when requestedtest passes its assertions and then leaksError: Configuration temporarily unavailablefromskill-workshop-page.test.tsx:125:20in both runs. This is exact test/error attribution, not shard-level attribution.Review cleanup removes the Sessions mock call-shape test requested by ClawSweeper. The production-browser intent runs above remain the evidence for shared-owner request reuse and absence of duplicate requests.
Review-cleanup head:
372db57da37(the only delta from the CI-repair head is removal of the redundant mocked Sessions test).Settings base check: the exact held-import test (SHA-256
1e872a71c4689cceb6b5f8847958cd895305742c309538ad9eb949084c46f379) was copied unchanged to original basee8b251188f502b088dd037936062a1711ea302e1. After an isolated frozen install, Vitest started normally but did not complete module collection while the editor import was held; the task stopped it at 60.068 s (SIGTERM / wrapper exit 143). Baseview.tsx:15eagerly imports that held editor. This is blocked-collection evidence, not an assertion-red result. The same test passes on the head and renders the real Infrastructure field after release. An earlier dependency-resolution failure was setup-only and is excluded from behavior evidence.CI follow-through on
372db57da37(40173218608): the earlier Cron consumer cases and Skill Workshop passed, whileretires queued cron event refreshes on gateway sourceexposed a test-helper timing regression. Waiting for dynamic imports added an event-loop turn even to owner-only fixtures with rendering disabled. The helper now waits for imports only withrender: true; the lifecycle case reproduces red before and passes after, and the offline-drafting editor case also passes. This changes no production code or expected request counts.Lifecycle-reviewed head:
1e9994b65ab; the lifecycle guard passed focused regression/editor checks, scoped lint/format, and fresh independent review.Additional pipeline experiment rejected (not in this PR): starting the config owner’s display read before editor activation moved
config.getfrom roughly 1.1 s to 4 ms after activation, but five complete interleaved base/A/A/candidate cycles on the same remote profile showed no readiness gain. Median Settings readiness was 1434 / 1446 / 1483 ms, script CPU 107.34 / 104.94 / 165.77 ms, and task CPU 358.78 / 361.28 / 472.77 ms. The 54% script and 32% task CPU regressions exceed the performance limit despite a stable A/A control. The experiment was stopped early and removed; the measured production change above is retained. Simply starting this read earlier is not a safe route to the 600 ms target.CI on
1e9994b65ab(40174247030) passed the repaired Cron lifecycle case, all other UI unit cases, all nine browser E2E shards, and both real-Gateway shards. Its sole failure wasstreaming Markdown DOM > keeps visible plain text in place when deferred formatting catches up: two observed character-data mutations instead of zero. Both the exact test and all 43 tests in that file passed locally before correction; the exact test also passed on the original base, so this is not attributed as inherited. The formatting-only test now explicitly awaits the existing lazy Markdown runtime before enabling its fake clock and observer. Its assertions are unchanged;markdown-live-loading.test.tsxretains cold-loading DOM coverage. The corrected exact case passes locally. This is a readiness-fixture repair, not a claim that the intermittent CI failure reproduced locally.Pre-integration reviewed head:
80176fa008f; the formatting-fixture correction passed its exact browser case, scoped lint/format, and independent review with no actionable findings. The subsequent export cleanup preserves the measured rendering behavior.Refreshed main integration
Merged
f7fa6508cce4e5e58ca8d0df75e88540b53fbc7cusing a normal merge. The only conflict was the forwarded-stream browser test; retained main’s stronger fresh-DOM polling fix exactly. No production conflicts.pnpm tsgo:uiand the exact conflicting browser case pass after the merge.Both production bundles were rebuilt on this Mac. The strict base/head comparison passes with no violations or warnings:
The standalone main check retains its pre-existing raw-CSS overage; this PR adds no CSS bytes. The startup baseline is refreshed to the exact final 273,686 B measured head. Timing tables above remain the original 20-pair evidence against e8b2511, not a claim of new timing runs after integration.
Pre-cleanup head:
02b6844155a2b5abbc56a1a8f865218aa54f7d31; its generated startup baseline passed independent review.Final export cleanup and proof
Export-cleanup reviewed head:
37b87b4dcdff7b1e193ef2548e8bfb08f6aa5847. Full production Knip exposed two newly unused Settings exports.ConfigPageand its props type are now private; their test-only consumers mount the existingConfigRoute, the same production boundary. The rendered fixture accepts admitted route data; the separate owner-state fixture retains its nullable contract. All normalization/navigation assertions remain; two synthetic null-update setup calls, which cannot reach the internal component throughConfigRoute, were removed. The initial fixture attempt exposed four normalization failures; the corrected route setup passes all 29 distinct cases across lazy-editor, Memory route, and Memory mutation files. UI typecheck, scoped lint/format, and independent review pass.A final production rebuild and strict base/head comparison pass with the updated values in the table above. The remaining full-production Knip exit is inherited: exact comparison against f7fa650 has 14 matching findings and no new entries. No ignores were added. The earlier scoped Knip checks do not replace this final full report.
Identical baseline and final full-production Knip findings
Command:
pnpm dlx --package [email protected] knip --config config/knip.config.ts --production --no-progress --reporter compact --no-config-hints --exclude duplicates.Final-head CI and remaining-latency experiments
Run
40178964351on37b87b4dcdff7b1e193ef2548e8bfb08f6aa5847passed all UI unit and real-Gateway jobs. Its only failed test wasrenders local assistant audio through server metadata (structured.mp3, structured): a 120-second timeout before browser navigation. The retained public failure state shows a blank page with no Gateway RPCs; logs show fixture-worker preparation finishing in 115,610 ms immediately before the timeout. The newest completed scheduled main run (40177240126) passed UI E2E, so this is not attributed as inherited. One rerun of the affected job was requested for the diagnosed fixture-preparation delay; the exact-head CI remains the landing gate.A separate Cron owner/view split was implemented and measured, then rejected and completely removed. The real route owner could start reads while the renderer import was held (regression red on the unchanged source, green with the split). Six complete interleaved base/A/A/candidate cycles at 100 ms RTT / 10 Mbps nevertheless increased readiness medians from 840 / 827 ms to 1,003 ms. Script CPU fell from 75.21 / 74.14 ms to 58.93 ms, but the extra module round trip outweighed request overlap. This was a bounded negative experiment, stopped before the planned twenty cycles; no localhost continuation or candidate publication followed. The retained PR remains the measured win above.
Fixture-preparation repair
Structured-audio repair head:
4dceddeb58d9912be00b0d1cff22702523aeb67f. The single shard rerun reproduced the same pre-navigation structured-audio timeout; worker preparation took144,196 ms against the120,000 ms per-case budget. The file now awaits that same production fixture module in its ownbeforeAllhook. The existing180,000 ms setup budget, per-test timeout, fixture builder, and every assertion are unchanged. This is five net test lines; no production or measured-bundle change. The targeted chat E2E typecheck, scoped UI lint, formatting, and independent P0–P2 review pass. Local E2E was not run under the campaign budget; the new exact-head full CI is the broad gate.Memory presentation lifetime and setup follow-up
Run
40182933694on the structured-audio repair head passes the repaired media shard. Its two remaining failures were the Memory Overview stylesheet-retirement assertion and the service-worker suite's setup hook. The Memory test passes on scheduled main40181005667; it is not treated as inherited.The admitted Memory route now reports no presentation snapshot for an inactive Overview or Memories tab. The existing bridge retires that scope immediately and does not reload its assets while Solid retains the previous component; callback authorization reads the same live scope. Asset disposal remains owned by the runtime's abort signal. This adds no cache, new lifecycle owner, or page remount. A focused test covers explicit scope retirement while the rendered component remains mounted, alongside all existing Memory consumer tests (50 cases total). The original intermittent E2E sequence was not reproduced in the bounded local production captures, with either the editor available or its import held; exact-head full CI remains the end-to-end verdict.
The service-worker suite built its production fixture successfully in 114 seconds, then exceeded its local 120-second setup override before any case ran. Its setup now uses the shared E2E 180-second budget. Case timeouts and all behavior assertions remain unchanged.
UI typechecking, scoped lint and formatting pass. A fresh production build and strict same-machine base comparison retain exactly the asset numbers above: 273,614 B startup JS gzip, seven JS requests, one CSS request, and unchanged total CSS. Solid refactor census for the two production modules is unchanged: zero effects, render effects, untrack, direct listeners/queries, cleanup hooks, flush calls, or owner-API calls were added. Independent review covers the lifetime fix and the setup-budget repair.
Follow-up reviewed head:
18f7b99a45b81719e2ff6bafc4d6d43d5a8828a5.Current-main conflict repair
Full CI 40185265912 passed on
18f7b99a45b81719e2ff6bafc4d6d43d5a8828a5, including the Memory and service-worker cases, all UI unit and E2E shards, and both real-Gateway shards. Native landing then stopped before dispatch on a content conflict after main advanced. Main2f95e977was merged normally; the sole conflict was the benchmark's Settings readiness condition. The resolution retains main's mobile-sidebar handling together with the enabled font-control requirement.The production asset table above is refreshed against this new main on the same Mac. The original timing tables remain original-base measurements; they are not presented as new timing runs after this integration. A fresh independent review covers the merged candidate. Full CI 40187605830 passed on the integrated head, including all UI and real-Gateway shards. No failed or pending CI is being waived.
Current integrated head:
add2fa9f385e4a39ef09b21771b6e032dd73adb3.Current production Knip comparison against
2f95e977: two shared unused core exports (resolveModelFallbackCandidateAgentRuntimeandresetStickyRateLimitFallbacksForTest), no head-only findings or new ignores. The baseline also reports one unresolved build-script import absent on the candidate. Earlier fourteen-finding counts above describe the olderf7fa6508comparison. UI/scripts typechecks, scoped lint/format, and both integration reviews pass.