Repository navigation
fix(ui): keep usage helpers out of chat startup - #132140
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 6:38 PM ET / 22:38 UTC. ClawSweeper reviewWhat this changesThe PR lazily loads Usage-page request assembly and regenerates the Control UI boot manifest from an isolated build that omits the prior boot grouping. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessNo blocking defect found in the introduced patch. The previous manifest-feedback finding is addressed; this maintainer-owned PR remains open for normal exact-head CI and merge handling. Priority: P2 Review scores
Verification
How this fits togetherControl UI Chat is the default startup route, while Usage is an optional route that requests session and provider data only when opened. The boot manifest records Chat-fetched modules so production chunking can consolidate startup code without pulling optional Usage helpers back into Chat. flowchart LR
A[Chat startup] --> B[Usage route module]
B --> C{Usage opened}
C -->|Yes| D[Usage request helpers]
C -->|No| E[Chat remains ready]
F[Isolated boot capture] --> G[Boot module manifest]
G --> H[Production chunk grouping]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +12, Docs 0, Other +33. Total +45 across 9 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the direct owner imports and isolated manifest capture, then land only after the exact-head build verifies the generated manifest and normal grouped output. Do we have a high-confidence way to reproduce the issue? Yes—current main’s static request-snapshot import and the PR’s loader-local dynamic import establish the startup reachability change from source; the submitted build/browser evidence supplies the recorded runtime scenario. Is this the best way to solve the issue? Yes—the direct owner imports remove the eager barrel edge, and the loader-local dynamic import is the narrow canonical boundary; the regenerated manifest corrects the separate grouping feedback path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a920626fc6d4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
effc014 to
7d48fe2
Compare
|
Accepted the boot-manifest finding and its Rank-up move. The earlier evidence proved that the static initial bundle shrank, but checking only the names of later network requests did not prove that Usage code was absent from shared boot chunks. I strengthened the canonical-dist browser probe to join every Chat-ready JavaScript request to its source-map modules. On head 7d48fe2 it fails for all three Usage owners inside two downloaded boot chunks. The four visible Chat/Usage/Model Providers flows still pass, so this is specifically an incomplete lazy boundary. Regenerating from the already-grouped bundle would feed those stale modules straight back into the manifest. The correction now makes the generator build a private temporary capture bundle with only the previous boot group omitted, preserving the other groups and execution-order settings. It captures real Chat readiness, generates the manifest, closes its browser/server and removes its temporary output. Normal production builds retain the canonical recursive boot grouping. There is no new configuration option, budget increase or hand-edited generated membership. Two generator runs produce byte-identical output and remove all three Usage owners. After a normal grouped rebuild, the exact same stronger browser assertion passes: none of those modules is in any Chat-fetched chunk, and all appear after Usage entry. Chat send/final, Usage data/error, and Model Providers error flows pass with zero page errors. The production build passes at 344,910 startup gzip bytes against the unchanged inherited 349,025-byte limit. This replaces the earlier filename-only boot claim; the original same-base 607-byte static-initial reduction remains a separate valid measurement. The generator flaw dates to #128514 (8fe2c1b, 2026-08-24; code author, PR author and merger @steipete). Its old capture consumed already-grouped dist. The complete correction is now published as 06d283e6383. All 12 browser cases pass. The full changed-file gate passed all stages except a callback-shadowing lint error; the callback was renamed and the full scripts lint stage, scripts typecheck, format check and generator rerun successfully. Final isolated review is clean. The three review-requested route/provenance/chunking test files also pass on the committed head (14 tests). Current main through 855346b was directly inspected; the repaired owners were not superseded. The latest review's generated-manifest correction, preserved exact-source behavior evidence and Rank-up request are all addressed. CI33216943737 is running for exact source 06d283e; native review artifacts are refreshed and validated. The earlier green run on 7d48fe2 is not being used as landing evidence for this correction. |
|
Merged via squash.
|
* fix(ui): keep usage helpers out of chat startup * fix(ui): measure boot manifest without stale grouping
Preserve main's canonical lazy Usage loading and check the router, transport epoch, and selected agent after the deferred import. Carry the existing route signal to all aggregate requests so obsolete navigation does not start new RPCs or retain client waits. Keep independent preload lifetime intact. Consolidate pending results to absorb the ownership checks with a net reduction of one production line. Real router/Gateway/selection regressions fail before the fix and pass afterward. Browser Back during a held service-worker fetch starts three obsolete Usage requests before the fix and none afterward; a fresh Usage visit still loads normally. This does not claim cancellation of server work already sent. Refs: #131503 (CLI startup preparation and integration repair) Related: #132140 (canonical Usage startup loading)
Preserve main's canonical lazy Usage loading and check the router, transport epoch, and selected agent after the deferred import. Carry the existing route signal to all aggregate requests so obsolete navigation does not start new RPCs or retain client waits. Keep independent preload lifetime intact. Consolidate pending results to absorb the ownership checks with a net reduction of one production line. Real router/Gateway/selection regressions fail before the fix and pass afterward. Browser Back during a held service-worker fetch starts three obsolete Usage requests before the fix and none afterward; a fresh Usage visit still loads normally. This does not claim cancellation of server work already sent. Refs: #131503 (CLI startup preparation and integration repair) Related: #132140 (canonical Usage startup loading)
* fix(ui): keep usage helpers out of chat startup * fix(ui): measure boot manifest without stale grouping
* fix(cli): retain invocation-owned plugin startup facts Bind non-Gateway CLI work to one operation PluginCache while closing preparation authority before actions. Preserve selected-workspace execution and config-wide validation. Defer the config writer, broad runtime state, and complete SDK aliases until demanded; keep late CJS and ESM actions in their creating cache. Rebuild the startup-only fix on the canonical progressive plugin cache without restoring superseded metadata and cache layers. Startup split from the standalone relay investigation in #128379; updates #131503. * fix(doctor): preserve registry scope across metadata refreshes Give explicit post-lease and post-mutation reads a fresh metadata generation without retiring the invoking CLI or Gateway owner. Persist the original workspace index while retaining the complete config-wide validation view. Bind rebased snapshots to their creating cache so later consumers cannot borrow a stale or foreign generation. Replace mocked persistence assertions with real scoped-index, lease, checkpoint, schema and provenance regressions. Follow-up to the installed startup verification for #131503. * fix(cli): defer MCP serving and stabilize startup checks Load the existing channel MCP server only for the serve action, and use the already-eager client-runtime import for reload. Registration and probes no longer evaluate the unused serving owner. Initialize the config CLI runtime capture before hoisted mocks. Give the real Doctor checkpoint fixture explicit build provenance and verify durable rows for successful, interrupted, and unidentified builds without changing runtime checkpoint policy. Remove duplicate fixture initialization and avoid dumping captured environments on rejection failures. Refs: #131503 (CLI startup preparation) * test(plugins): follow runtime load context module split Import the canonical runtime context resolver from its new owning module in the CLI lifetime regression. Preserve the existing behavior assertions; the original CI TS2724 reproduces before the import correction and the same type program and 16 lifetime cases pass afterward. Refs: #131503 (CLI startup preparation) * test(plugins): drop duplicate alias memoization assertion Remove the case that compares the same cached alias object with itself. Keep the stronger identity/no-repeated-filesystem-read test, context-isolation cases, and real source/native loader coverage. No production API or behavior changes. Refs: #131503 (CLI startup preparation) * fix(ui): stop retired usage loads before requests Preserve main's canonical lazy Usage loading and check the router, transport epoch, and selected agent after the deferred import. Carry the existing route signal to all aggregate requests so obsolete navigation does not start new RPCs or retain client waits. Keep independent preload lifetime intact. Consolidate pending results to absorb the ownership checks with a net reduction of one production line. Real router/Gateway/selection regressions fail before the fix and pass afterward. Browser Back during a held service-worker fetch starts three obsolete Usage requests before the fix and none afterward; a fresh Usage visit still loads normally. This does not claim cancellation of server work already sent. Refs: #131503 (CLI startup preparation and integration repair) Related: #132140 (canonical Usage startup loading) * test(ui): assert fresh usage data after epoch changes Keep the waited fresh-result identity and stale-result rejection checks. Remove two redundant assertions that required the old two-argument request shape and rejected the newly forwarded cancellation signal. The same failure appeared in both Control UI and Node CI lanes. Both test entrypoints now pass, along with adjacent Usage/controller coverage, UI test types, lint, and formatting. No production code, mock response, timeout, or stale/fresh data assertion changes. Refs: #131503 (CLI startup and Usage lifecycle integration) CI: https://github.com/openclaw/openclaw/actions/runs/33224402718
* fix(cli): retain invocation-owned plugin startup facts Bind non-Gateway CLI work to one operation PluginCache while closing preparation authority before actions. Preserve selected-workspace execution and config-wide validation. Defer the config writer, broad runtime state, and complete SDK aliases until demanded; keep late CJS and ESM actions in their creating cache. Rebuild the startup-only fix on the canonical progressive plugin cache without restoring superseded metadata and cache layers. Startup split from the standalone relay investigation in openclaw#128379; updates openclaw#131503. * fix(doctor): preserve registry scope across metadata refreshes Give explicit post-lease and post-mutation reads a fresh metadata generation without retiring the invoking CLI or Gateway owner. Persist the original workspace index while retaining the complete config-wide validation view. Bind rebased snapshots to their creating cache so later consumers cannot borrow a stale or foreign generation. Replace mocked persistence assertions with real scoped-index, lease, checkpoint, schema and provenance regressions. Follow-up to the installed startup verification for openclaw#131503. * fix(cli): defer MCP serving and stabilize startup checks Load the existing channel MCP server only for the serve action, and use the already-eager client-runtime import for reload. Registration and probes no longer evaluate the unused serving owner. Initialize the config CLI runtime capture before hoisted mocks. Give the real Doctor checkpoint fixture explicit build provenance and verify durable rows for successful, interrupted, and unidentified builds without changing runtime checkpoint policy. Remove duplicate fixture initialization and avoid dumping captured environments on rejection failures. Refs: openclaw#131503 (CLI startup preparation) * test(plugins): follow runtime load context module split Import the canonical runtime context resolver from its new owning module in the CLI lifetime regression. Preserve the existing behavior assertions; the original CI TS2724 reproduces before the import correction and the same type program and 16 lifetime cases pass afterward. Refs: openclaw#131503 (CLI startup preparation) * test(plugins): drop duplicate alias memoization assertion Remove the case that compares the same cached alias object with itself. Keep the stronger identity/no-repeated-filesystem-read test, context-isolation cases, and real source/native loader coverage. No production API or behavior changes. Refs: openclaw#131503 (CLI startup preparation) * fix(ui): stop retired usage loads before requests Preserve main's canonical lazy Usage loading and check the router, transport epoch, and selected agent after the deferred import. Carry the existing route signal to all aggregate requests so obsolete navigation does not start new RPCs or retain client waits. Keep independent preload lifetime intact. Consolidate pending results to absorb the ownership checks with a net reduction of one production line. Real router/Gateway/selection regressions fail before the fix and pass afterward. Browser Back during a held service-worker fetch starts three obsolete Usage requests before the fix and none afterward; a fresh Usage visit still loads normally. This does not claim cancellation of server work already sent. Refs: openclaw#131503 (CLI startup preparation and integration repair) Related: openclaw#132140 (canonical Usage startup loading) * test(ui): assert fresh usage data after epoch changes Keep the waited fresh-result identity and stale-result rejection checks. Remove two redundant assertions that required the old two-argument request shape and rejected the newly forwarded cancellation signal. The same failure appeared in both Control UI and Node CI lanes. Both test entrypoints now pass, along with adjacent Usage/controller coverage, UI test types, lint, and formatting. No production code, mock response, timeout, or stale/fresh data assertion changes. Refs: openclaw#131503 (CLI startup and Usage lifecycle integration) CI: https://github.com/openclaw/openclaw/actions/runs/33224402718
Related: #121497. Investigated from the shared build failure observed in #132102, #132105 and #132115; does not change those fixes.
What Problem This Solves
Fixes an issue where developers cannot complete the normal CI/build workflow because Control UI startup JavaScript exceeds its existing gzip limit. The optional Usage request helpers are eagerly included even when the operator opens Chat.
Why This Change Was Made
Keep Usage request assembly behind the Usage route's existing asynchronous loader, following the Model Providers route's established pattern. Capture Gateway and query provenance before the import, retain the disconnected short circuit and existing error handling, and import request helpers directly from their owner in the three off-default consumers. Remove the obsolete eager sessions-barrel reexports.
Both eager edges must be removed: changing only the barrel leaves the route's static snapshot import in the startup graph. The old boot manifest also needs regeneration without its own grouping, or its stale entries pull the newly lazy modules back into Chat's downloaded chunks. The generator now builds a temporary capture bundle with only that old boot group omitted, records actual Chat readiness, writes the generated manifest, and closes/removes its owned resources. Final production grouping and execution-order settings are unchanged.
The fix preserves all usage RPC shapes, lifecycle ownership, request/error results, and page rendering. No new loader abstraction, fallback, configuration option, dependency or storage change. No budget, baseline, chunk-size setting, tolerance or retry is changed. Runtime production LOC +7/-12 (net -5); tooling +58/-25 (net +33) owns fresh isolated capture and cleanup; generated manifest +46/-29; two comment lines and one guide paragraph updated. No test-only production seam.
Source attribution: the eager usage barrel predates this regression (65e1232, 2026-07-04, code author Shakker). #132064 expanded the reachable helpers for on-demand context details (code author, PR author and merger @steipete, d9f3d88, 2026-08-28). The observed overrun is cumulative startup growth, not a claim that this one feature alone caused it. Removing functionality or byte-golfing feedback is unnecessary when the optional owner can remain lazy.
User Impact
Chat startup no longer downloads Usage-only RPC assembly. Usage and Model Providers retain their existing behavior when opened. There is no visual/layout change. This is the release-note context.
Evidence
CI recovery: the first hosted run passed the build/UI lanes but failed one pre-cancellation checkpoint in
bash-tools.exec-host-node.cancellation.test.ts. That fixture polled for its second policy call under Vitest's default one-second wait, although real preparation may still be loading the local Bash parser. The canonical repair independently landed in #132038: wait on the owned policy-entry deferred, raced against the original result so early errors surface, preserving the cancellation reason, no-dispatch checks, cleanup, test deadline and production policy. This PR refreshes onto that fix and does not duplicate its test edit.A temporary 1.2-second delay around the real parser initializer reproduced the original failure (one failed, three passed); equivalent repaired synchronization passed all four cases with the same modeled delay and normally. The temporary diagnostic and duplicate local repair were discarded in favor of #132038. This proves susceptibility to slow initialization; the original CI log cannot identify its exact delayed phase or swallowed preparation error. The fixture uses mocked node discovery/Gateway transport and local filesystem/WASM analysis, not native command execution. Provenance: #131717 introduced real preparation into this test while retaining the polling checkpoint.
Actual canonical production build on unchanged main 04f6630 failed at 347,454 startup gzip bytes against the unchanged 347,037-byte enforcement limit. With this patch it passes at 346,847 bytes (607 bytes lower), still eight startup JS requests. Source maps confirm all three optional owners are absent from initial chunks. Finalized asset sidecars and the remaining size limits pass.
During verification, #132020 independently landed a 347,255-byte baseline on main. This PR does not edit that baseline or claim its CI recovery: the measured reduction above is an exact same-base comparison against the earlier, stricter limit. It removes unnecessary startup work rather than making another ratchet change.
The existing performance gate is executable RED/GREEN regression proof; no implementation-coupled source-grep test is added. All 54 existing tests across seven Usage route/provenance, request, detail/export, and Model Providers files pass. All 12 Chromium/mock-Gateway browser cases across Usage cost analysis and Model Providers usage outcomes pass, with the test wrapper exiting successfully. Isolated Codex review reports no accepted/actionable findings.
The original five-path changed-file gate passes, including test/UI typechecking, lint, export checks and the default architecture guards. A separate canonical-production-bundle recorder passes four observable flows: default Chat boot/send/final, opening Usage with canonical RPC parameters and visible results, visible Usage request failure, and Model Providers entry/error. Its original filename-only network inference was insufficient: the named lazy entry chunks arrived later, but their implementations remained in shared boot chunks. The stronger source-map proof and complete correction are below. Browser and preview cleanup verified; no page errors.
Recorder-only recovery: the first attempt used a mismatched synthetic build identity and Playwright's unavailable remote-video
path()API. The fixture was corrected to the actual built artifact identity and the documentedsaveAs()API; one corrected run passed all assertions. No product change, timeout increase or assertion relaxation was needed.Dependency contract inspected: @openclaw/uirouter 0.1.1 starts async loaders and components together and fences stale publication; the preserved pre-await snapshot is covered by the existing route-provenance test. Browser proof uses synthetic fixtures, not authenticated provider/Gateway traffic. Exact-head hosted CI and the native prepare/merge workflow remain required before landing.
The full canonical build also passes after commit (346,850 startup gzip bytes against the original 347,037-byte limit; the three-byte metadata/hash variation does not affect the result).
Refreshed head
7d48fe29b63649d5f52c5d9fa46c99888b987677incorporates canonical main through #132038; range-diff confirms the five-file UI patch is unchanged. All 58 focused tests pass (54 Usage/Model Providers plus the canonical four-case cancellation fixture). The refreshed production UI build passes at 344,757 startup gzip bytes; that total includes other main changes and is not attributed entirely to this PR. The same-base 607-byte comparison remains the isolated measurement above.All 12 bundled Chromium browser cases passed again on that refreshed head. CI33215504527 succeeded, but does not cover the subsequent accepted review correction below.
Accepted boot-manifest review correction
ClawSweeper's boot-manifest finding and Rank-up move are addressed. On the refreshed production bundle, joining every Chat-ready JS request to its source-map modules fails for all three Usage owners inside shared boot chunks. That is stronger evidence than either the initial-byte gate or chunk filenames. The generator itself caused a feedback loop by recording already-grouped dist; this dates to #128514 (8fe2c1b, 2026-08-24; code author, PR author and merger @steipete).
The repaired canonical generator measures a temporary bundle with the old boot group omitted. It directly replaces the group list through the documented output-options hook, avoiding Vite array merging and preserving ordinary dynamic splitting. Two complete generator runs yield byte-identical output, remove all three Usage owners, and clean up their temporary builds. No hand-edited manifest membership.
After a normal grouped rebuild, the same browser/source-map assertion passes: all three modules are absent from every Chat-fetched chunk and present after Usage entry. The four real Chromium/mock-Gateway flows pass, with zero page errors and verified process/preview cleanup. The normal production build passes at 344,910 startup gzip bytes against the unchanged inherited 349,025-byte limit. That total includes independent main changes; it does not replace the original same-base 607-byte initial-bundle comparison.
All 12 bundled browser cases pass with the regenerated manifest. Isolated Codex review of the generator correction reports no actionable findings. The nine-path changed-file gate passed every stage except a shadowed callback name in the new cleanup code; that callback was renamed, then the complete scripts lint stage, script typecheck, formatting and generator were rerun successfully. The generator still produces identical output. Final isolated review is clean. New exact-head hosted CI and native prepare/merge remain required before landing. Existing executable generation/build/browser proof covers the actual defect; no source-grep test or production test seam is added.
Final published source: 06d283e6383. The three review-requested route/provenance/chunking files pass on this commit (14 tests). Exact-head CI33216943737 completed successfully. Native review artifacts validated and preparation passed without changing the tested head. The latest ClawSweeper review at 22:38 UTC reviewed this exact commit, confirmed the prior finding resolved, and reported no actionable findings. Its missing installed dependency source was a reviewer limitation; the lead directly inspected the installed Rolldown output-options/group contracts and executed the generator/build/browser proofs above.
Recorded flow on the original five-file patched production bundle, before opening Usage and after entry. These show preserved behavior, not a visual before/after redesign; the actual before/after size comparison is above. The stronger final manifest/source-map proof described above was recorded separately.