Repository navigation
fix(agents): show provider rejection details in failed chats - #145402
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: needs maintainer review before merge. Reviewed September 11, 2026, 10:05 PM ET / September 12, 2026, 02:05 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR preserves redacted provider rejection details in live and saved chats, defers Usage-page initialization, and consolidates existing MCP doctor test coverage. Merge readiness✅ Ready for maintainer review The fix remains necessary on the reviewed main and release. No blocking correctness or security defect was found, and the supplied evidence supports the intended behavior. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw converts provider HTTP failures into bounded diagnostics and safe chat messages. The agent runtime and Gateway history projection consume those errors; the Control UI displays the resulting explanation. flowchart TD
A[Provider HTTP rejection] --> B[Bounded response reader]
B --> C[Diagnostic redaction]
C --> D[Status and error projection]
D --> E[Curated request-limit explanation]
E --> F[Live chat failure]
E --> G[Saved chat history]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +53, Tests +151, Docs +12. Total +216 across 20 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one redacted diagnostic projection and one curated request-limit renderer shared by live failures and saved history. Do we have a high-confidence way to reproduce the issue? Yes: main clips long Anthropic JSON errors before structured redaction, explaining the lost rejection detail; the supplied live observation corroborates that path. This review did not execute a reproduction. Is this the best way to solve the issue? Yes: the patch repairs the existing transport and display owners, preserves bounded previews and redaction, and avoids a parallel error-handling path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 47ce03dbc699. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
921e04b to
f8df6fb
Compare
cdad4b0 to
e84be2c
Compare
|
Merged via squash.
|
…w#145402) * fix(agents): preserve provider rejection details in failed chats * fix(ai): keep provider error previews bounded * perf(ui): defer Usage route initialization * test(mcp): consolidate doctor JSON failure coverage
## Problem and fix The Control UI startup bundle grew past its original budget in #145347. This PR keeps route definitions light: one pathname owner classifies dynamic routes, Sessions query construction lives with the lazy page, and duplicate router classification is removed. Recovery remains unchanged from main. Main now owns the Usage lazy-loader extraction through #145402. This rebased PR retains both Usage files exactly from main and contains only the remaining 9 router/Sessions files. Picker structural fixes have landed separately; this PR changes no budget, baseline, compressor, ignore rule, schema, configuration key or protocol. ## Current revision and labeled proof Current head: `db654b48699c75f521ed5b9628f54f40832bce62`, rebased onto `658ae6189ea97d12cce52d458219b580bdaea7d9`. Main includes #145540, commit `41861b80`, which fixes the former test-type error. All five commits are unchanged in the rebase range-diff; the final patch remains nine files and 38 fewer lines. - Fresh census passes on CI merge `e7b38fecdd40487f169deda8a7dd699e9b44138a`. The exact native command `pnpm ui:check-performance:base 658ae61` passes there at **352,276 bytes gzip**, with **2,840 bytes of headroom** below the unchanged 355,116-byte limit. Fresh CI run **34670046624 / attempt 1** completed successfully: **87 passed jobs, 13 skipped, zero failures**. The test-type gate and all structural/UI/browser checks, including real-Gateway tests, passed on this revision. - Prior paired performance proof belongs to the source tree committed as `be3c2b1ea9aebdf648fc9f4cd8655e3a95ea97af`, compared with base `da762af0e80c9fe6a61422dc5591ab24e5c9a3ce`: 352,387 versus 352,969 bytes gzip, saving 582 bytes. These are not new-head measurements. - Prior CI merge `210c6fc5182f32c83ff97d90bfe0ed94d3d588c5` measured 352,542 bytes gzip both natively and in CI, with 2,574 bytes below the unchanged 355,116-byte limit. That result remains labeled with its old tested merge. - On the prior source tree and prior CI merge, all 132 targeted tests in seven files and both production-bundle reconnect cases passed. Prior CI run 34668494939 / attempt 1 also passed all UI/browser suites, including real-Gateway tests, and all lint/format/ratchet checks. Its test-type failure was inherited from main; this revision must pass that check. - Source review at `be3c2b1e` remains applicable to the unchanged patch. Its original artifact is retained without relabeling it as a new-head review. Fresh CI validates integration with the new base. - Historical introducing-parent proof for #145347 measured 354,263 bytes on its parent and 354,498 on the introducing commit, crossing the then-current 354,270-byte limit. Current main already passed before this rebase; this PR is a measured performance refactor, not a claim of a current budget outage. - Older-host/previous-state and config-corpus gates do not apply: no plugin runtime, SDK, version, updater, Doctor, config loading or persistence change. ## Consumers Inventory at `db654b48699c75f521ed5b9628f54f40832bce62`; paths below are relative to `ui/src/`; bare Sessions filenames are relative to `ui/src/pages/sessions/`. Both symbol searches and import/re-export path searches cover all of `ui/src`, including tests and support files. The import inventory includes 188 files and 201 statements for `app-route-paths`, `app-routes`, and `list-query`; imports of unrelated constants, path constructors and types are not classifier calls. There is no namespace/star import or renamed binding hiding another classifier/query call, and no extensionless or `.js` import of these owners. The `import("../../app-routes.ts").RouteId` in `test-helpers/app-sidebar-cases/sidebar-zone.ts:50` is type-only. Earlier cross-tree searches also covered `src/`, `extensions/`, `apps/`, docs and schemas; no external contract changes. Coverage citations identify existing tests, not new executions. Mounted-page tests exercise the registered element but sometimes call its methods; they are not claims of a live Gateway operation. Renderer/helper coverage is marked separately. Execution labels remain those in the proof section above. Current archived job **103489709553** and transcript job **103489709586** passed on merge **e7b38fecdd40487f169deda8a7dd699e9b44138a**, in run **34670046624 / attempt 1**. ### Sessions query: all direct readers and all wrapper reads `sessionsPageListQuery` is retired. Its identical implementation is `buildSessionsListQuery` at `pages/sessions/list-query.ts:19`; `SessionsPageListFilters` is private there, with its sole parameter use at `:21`. Existing `SessionsRouteData` consumers remain on `route.ts`. Exactly four files import the builder: | Reader and read path | Behavior and existing covering test | | --- | --- | | `pages/sessions/sessions-page.ts:79,104,453–464` | Import, binding query type, and the sole production builder call in `sessionListOptions`. Mounted `openclaw-sessions-page`: `pages/sessions/sessions-page.roster.test.ts:367` checks selected/all-agent query switching. | | `pages/sessions/sessions-page.test-support.ts:16,231` | Builds the initial managed query before mounting the registered Sessions element (`:225–252`). Its seven users are `sessions-page.test.ts`, `.archived.test.ts`, `.groups.test.ts`, `.plugin-actions.test.ts`, `.roster.test.ts`, `.transcript-search.test.ts`, and `.typing.test.ts`, all in `pages/sessions/`; behavior coverage is mapped below. | | `pages/sessions/route.test.ts:7,43` | Supplemental query assertions accompany registered `page.loader` cases at `:33–113`: selected active, all-agent archived, selected all-status and another agent's deep link. Loader no-list assertions remain. | | `components/app-sidebar.child-history-freshness.test.ts:13,249` | Query fixture for the mounted sidebar. `:240–301` checks fresh child labels/running state after older pages settle; this is a test reader, not a production sidebar import of the builder. | `sessionListOptions` has exactly four reads, with three request pipelines and one invalidation key: | Read and complete downstream path | Existing covering test | | --- | --- | | **Sessions list**: `sessions-page.ts:473` → binding/subscription `:467–513` → `loadSessionList` `:551–581` → managed query window `lib/sessions/session-managed-list-refresh.ts:91–164,169–183` → encoding `lib/sessions/session-requests.ts:163–186` → `sessions.list` → accepted snapshot `sessions-page.ts:515–533` → `renderSessions` `:1606` / `pages/sessions/view.ts`. Query reuse also occurs in refresh/snapshot adoption (`:547,558,580,592`), binding retirement (`:193`), binding key construction (`:474`), and the old-query loading check (`:479`). Load-more reads accepted `nextOffset`/`hasMore` (`:1713–1718`); filter/status/deep-link/scope changes rebuild the binding. | Mounted page `sessions-page.roster.test.ts:44–116` (latest query/retired rows), `:117` (append server page), `:308` (reconnect), `:329` (capability replacement), `:367` (scope), `:416` (last-good rows), `:451` (explicit refresh). Mounted input `sessions-page.typing.test.ts:420,463` checks coalescing and debounce. | | **Transcript search**: Task `sessions-page.ts:200–231` → wrapper read `:225` with empty metadata search → `lib/sessions/transcript-search.ts:68–119` → paged `sessions.list` → grouping keys by agent → `sessions.search` → Task completion `sessions-page.ts:1622–1627` → hits/status in `view.ts:383–385,505`; hit activation calls the page's navigation callback (`sessions-page.ts:1753`). Other filters, deep links and scope remain active. Client/context/scope/capability/submitted-query changes retire pending work; `isCurrent` carries retirement through paging. | Mounted `sessions-page.transcript-search.test.ts:26` (bounded results/status), `:91` (all-agent fanout), `:171,208` (query/scope retirement), `:335` (error/retry), `:370–438` (fresh roster after filters and metadata-query exclusion). Renderer `view.test.ts:349` checks provenance and matching-session activation. | | **Transcript invalidation key**: `sessions-page.ts:476` → JSON key built without metadata search → `:477–485` comparison/reset when query or capability changes. This is a separate query read, not another request. | `sessions-page.transcript-search.test.ts:370–438` checks that relevant filter changes refresh the roster while metadata-only edits neither narrow nor retire transcript search. | | **Delete all archived**: button `view.ts:1018–1028` → callback `sessions-page.ts:1728` → `deleteAllArchived` `:826–881` → wrapper read `:843` → builder → `fetchPagedSessionRows` / `scope.sessions.list` / `sessions.list` → archived-row filter → confirmation → `deleteSessions` `:739–823` → `deleteMany` → deletion owner `lib/sessions/session-deletions.ts:181–209` → encoder `session-requests.ts:213–227` → `sessions.delete` → selection/deep-link cleanup and refresh. The options are snapshotted once, metadata `search` and linked `agentId` are removed, selected agent scope is restored, and page size is 1000. Failed/incomplete enumeration aborts. Original request scope is checked while paging and after confirmation (`sessions-page.ts:319–349,848,876`). Current deletion access, expected session generation and archived-only checks remain. | Mounted `sessions-page.archived.test.ts:81–142` (full enumeration), `:165–243` (failure/paging), `:246` (moved/duplicate rows), `:312–367` (incomplete enumeration refusal), `:370–424` (all-agent/selected-agent deep-link exclusion through final deletion targets). All ten existing cases passed job **103489709553** on **e7b38fec**. | ### Downstream readers of the accepted Sessions roster These consume returned rows or page callbacks; they do not call the builder independently. The page owns the accepted `result`, while the managed-list owner owns publication. In addition to render/paging, every `this.result` read is accounted for below. | Reader and read path | Existing covering test and scope | | --- | --- | | Snapshot projection `sessions-page.ts:525–529` → archive filtering, `ensureAgentIdentities`, checkpoint-cache reconciliation; render reads `:1583,1606,1630` → owner availability, row identities, grouping/sort/pagination, details, links and controls in `view.ts`. | Mounted `sessions-page.roster.test.ts:481` checks result-pointer/cache reconciliation; `sessions-page.test.ts:97` checks active/archived routing. Renderer `view.test.ts:110,158,427,458,479,581,1077` checks headings, sorting, status, archived rows, pagination, owner grouping and identities. These renderer cases supplement the mounted-page path. | | **Selected/bulk deletion**: selection callbacks `sessions-page.ts:1731–1752` → `deleteSelected` `:708–737`, which snapshots selected rows from `this.result` at `:718` → confirmation/scope check → the same `deleteSessions` / `deleteMany` / `sessions.delete` chain above. `selectedDeleteDisabledReason` reads rows at `:378` for per-row authority. This population is the current selection, distinct from full archived enumeration. | Mounted `sessions-page.test.ts:414–467` checks session-generation snapshots during confirmation; `:468–503` checks optimistic removal with concurrent roster publication; `:504–524` rejects a changed Gateway; `:570–612` checks per-row archive authority. Renderer `view.test.ts:261` checks selectable identities. | | **Row deletion and archive/unarchive**: `renderSessionMenu` looks up exact key/sessionId at `sessions-page.ts:1451`, then menu dispatch `:1559–1574` → `archiveSessionWithUndo` `:1177–1204`, `patchSession` `:1119–1175`, or `deleteSessionFromMenu` `:883–897` → shared deletion. Archive Undo remains store-owned after page navigation. | Mounted `sessions-page.test.ts:133,173` (Undo and navigation), `:328` (archive versus deletion access), `:525–612` (archived/active/unknown deletion authority); `sessions-page.archived.test.ts:30` (optimistic deletion rejection). | | **Groups**: `knownCategories` reads result at `sessions-page.ts:950`; drag/drop `assignCategory` finds an existing row at `:988`; `requestNewCategory` captures identity at `:1039` → group catalog write before session assignment/patch. Rendered group controls use the same accepted rows. | Mounted `sessions-page.groups.test.ts:56,123,227,242,250,259,269` covers write ordering, stale connection, captured identity, empty groups, failed catalog write and unbound/stale assignment. Renderer `view.test.ts:638,695` covers group cell/drop controls and write access. | | **Checkpoint details**: `toggleSessionDetails` reads row checkpoint metadata at `sessions-page.ts:1260`; accepted-result reconciliation is at `:529`; detail/branch/restore callbacks are at `:1771–1775`. | Mounted `sessions-page.test.ts:245,353` checks disconnected drawers and retirement of checkpoint work; `sessions-page.roster.test.ts:481` checks cache reconciliation. Renderer `view.test.ts:244` checks visible checkpoint failure. | | **Menus and row actions**: exact-generation row lookup `sessions-page.ts:1451` supplies menu labels, pin/unread/category/appearance, permissions, fork state, worker state, work details and plugin descriptors (`:1461–1506`). Dispatch `:1507–1575` supplies that row to navigation/copy, patch/rename, fork, group, archive/delete, owner assignment and cloud-worker actions. View callbacks also navigate/open menus from accepted rows (`:1753–1770`). | Mounted `sessions-page.test.ts:222,306,375,615,678,819` covers read marking, locked fork, disconnect/menu retirement, worker stop/reclaim and active-session fork; archive/delete/group cases above cover those dispatches. Renderer `view.test.ts:291,738` covers links/menu opening. These are representative action/dispatch assertions, not a claim of a separate mounted-page assertion for every menu action; unchanged menu/navigation owners have their own `components/session-menu.test.ts` and `lib/sessions/session-menu-navigation.test.ts`. | | **Plugin action freshness**: menu descriptors read the current row (`sessions-page.ts:1504`); `runPluginAction` re-reads exact key/sessionId at `:1791` before calling the plugin action owner, with page-lifetime cancellation. | Mounted `sessions-page.plugin-actions.test.ts:76,105,130` checks labels/disabled state, current scoped session values, and removed/replaced rows. | ### Shared route classifier: all owner, router and direct downstream reads `app-route-paths.ts` is the single pathname-classification owner. Its private `dynamicRouteIdFromPath` (`:465`) has exactly three calls: bridge adaptation (`:499`), route-ID lookup (`:527`), and base inference (`:573`). Private `isLegacyPluginsDiscoveryPath` (`:339`) has exactly one call (`:487`). The removed router duplicate and private `DynamicRoute` annotation have no remaining reader or alias. The exported bridge result retains route ID, search key and real pathname; static Memory overview and static-route precedence stay intact. | Reader and read path | Existing covering test | | --- | --- | | Bridge adapter `dynamicRouteFromPath` (`app-route-paths.ts:496–503`) → three runtime reads in `app-routes.ts`: `routerHistoryLocation` `:173`, initial dynamic navigation `:247`, later history navigation `:364`. | `app-route-paths.test.ts:170` starts the registered application router for dynamic-route startup; `app-navigation.test.ts:477` checks session navigation; `pages/workboard/route.test.ts:104` onward checks final history/state through registered navigation/preload. Bundled `e2e/session-link-reconnect.e2e.test.ts:62–118` checks both final visible destinations/URLs after reconnect. | | `routeIdFromPath` (`app-route-paths.ts:506`) → router facade option `app-routes.ts:168` and re-export `:395–401`; `startApplicationRouter` reads it for initial canonicalization `:219`, unknown-route fallback `:238`, and later canonicalization `:357`. Router consumers use this supplied callback for location navigation/preload. | `app-route-paths.test.ts:170` onward (startup), `app-navigation.test.ts:343–548` (route families, aliases, base mounts, malformed paths, static precedence), `pages/workboard/route.test.ts` (navigation/preload), `e2e/plugin-tab-slugs.e2e.test.ts:95` (unknown slug after hello). | | **Startup warming**: `app/bootstrap.ts:586–589` → `warmApplicationRouteModule` (`app-routes.ts:128–137`) → route-ID read `:133` → `router.getRoute(routeId)` → `route.component()`. Explicit initial routes start their lazy download before normal routing without executing the loader. Default first-run landing waits for setup's destination. | `app/bootstrap.test.ts:132–174`, “warms only explicit application routes at startup”, covers explicit routes/deep links and default/focus/approval exclusions; first-run/default setup cases follow at `:216` onward. | | Bootstrap landing/default decisions: `app/bootstrap-location.ts:29–34`; `app/bootstrap.ts:213,678,688` passes or reads the classifier; `pages/model-setup/first-run.ts:11–16` invokes that supplied callback. | `app/bootstrap-location.test.ts:7–113` checks persisted/default and explicit startup routes; `pages/model-setup/first-run.test.ts:88–149` checks the default-landing predicate; `app/bootstrap.test.ts:216` onward checks initial-route selection and retirement. | | Native shell navigation: `app/app-shell-chrome.ts:297` classifies native paths, then retains the full destination for `host.navigate`. | Registered shell event-handler test `app/app-host-native-shell.test.ts:422–459` checks destinations and acknowledgement across root/base mounts. | | Deferred shell panels: `app/app-shell-panels.ts:104–108` reads the current pathname's route ID, with route-state fallback, to decide session-panel ownership. | Registered shell owner test `app/app-host.panel-toggles.test.ts:161` checks toggle buffering until the chat pane mounts; restoration/retry cases follow. This exercises the owner/fallback path; route-path classification itself is asserted in `app-navigation.test.ts:343–548`. | | Markdown links: `components/markdown.ts:351–362` classifies root and configured-base paths before docs-link rewriting. | Renderer entry `toSanitizedMarkdownHtml` in `components/markdown.test.ts:425–451` checks app links, docs roots and base-mounted app/resource links. | | Custodian user-turn context: `pages/custodian/session-lifecycle.ts:25–27` combines base inference and route ID into `context.page`. | Mounted page `pages/custodian/custodian-page.test.ts:306–340` checks resolved/unknown paths, excludes context from initial turns and observes user-turn request context. | | Base inference `app-route-paths.ts:553–579` → browser route/resource bases `app/browser.ts:36`. | `app/browser.test.ts:10–34` checks configured, inferred, root-resource and cold plugin paths. | | Base inference → public asset URLs `app/public-assets.ts:41`. | `app/public-assets.test.ts:63–98` checks nested mounts, ambient-state independence and explicit-base precedence. | | Base inference → startup settings `app/startup-settings.ts:194–198` → session-route detection before token-triggered session reset (`:236`). | Startup entry `app/settings.node.test.ts:45,60` exercises this read during fragment credential handling; `app-navigation.test.ts:551–582` directly checks mounted-path inference. These do not independently assert the token-on-mounted-session reset branch. Custodian's additional base-inference read is listed above. | | Private discovery matcher → private classifier at `app-route-paths.ts:487`. | The two rewritten cases `app-route-paths.test.ts:710–721` exercise `createApplicationRouter().routeIdFromPath`, retaining root/base discovery, settings detail and nested-path rejection. | ### Classifier output: every pathname-bridge reader The shared restorer (`app-route-paths.ts:605–617`) removes the internal parameter and restores the real location. `app-route-paths.test.ts:549–582` checks absent/empty/duplicate/encoded values without mutating the source. The full production import/read inventory of the internal path parameters is: | Reader and read path | Existing covering test | | --- | --- | | Chat/dashboard loader dependencies `pages/chat/route.ts:13–24`; ordinary target restoration `pages/chat/route-loader.ts:138–156`; catalog-share target restoration `pages/chat/route-loader-catalog-share.ts:18–30`. These feed registered chat/dashboard route loading and final destination data. | `app-route-paths.test.ts:170` onward exercises the initial bridge; `pages/chat/route.test.ts:61,107,241` covers resolved targets/dashboard data; `pages/chat/route-loader-catalog-share.test.ts:257` checks the internally bridged stale-name/full-ID path. The two bundled reconnect cases cover final rendered session destinations. | | Terminal `pages/terminal/route-location.ts:14` → terminal target/catalog query. | `pages/terminal/route-location.test.ts:35` restores an initial dynamic path with its remaining query. | | Agents `pages/agents/route-location.ts:19` → agent/panel location. | `pages/agents/route-location.test.ts:87` checks restored path and removal of the internal parameter. | | Activity `pages/activity/route.ts:9` → person/filter route data. | Registered loader `pages/activity/route.test.ts:51` compares direct and bridged paths under a mount. | | Workboard `pages/workboard/route-location.ts:22` → board/filter location. | Registered router `pages/workboard/route.test.ts:104` onward checks canonicalization, newer-navigation preservation and preload; final history/route data are asserted. | | Memory `pages/config/route-data.ts:50–64` → pathname/search/tab data. | `pages/config/route-data.test.ts:72` restores the dynamic Memory path and preserves the agent query. | | Plugins and plugin settings `pages/plugins/route-data.ts:19–23` → nested restorer for both internal parameters. | `pages/plugins/route-data.test.ts:32,42` checks hub and settings-detail restoration without parameter leakage. | | Plugin tabs `pages/plugin/route.ts:15–22` → advertised tab lookup from bridged pathname, then tab reference/page params. | `pages/plugin/tab-slugs.test.ts:21–33` checks bridge lookup; bundled `e2e/plugin-tab-slugs.e2e.test.ts:53,107` checks the tab shell and generic-URL canonicalization with params/hash. | ### Direct test imports and retained adjacent owners Direct route-ID/base-inference test import readers are exactly `app-route-paths.test.ts`, `app-navigation.test.ts`, `app-routes.test.ts:2,22`, `app/approval-deep-link.test.ts:3,62–63`, `app/bootstrap.test.ts:6,299`, `pages/model-setup/first-run.test.ts:3,88–149`, and `pages/plugin/tab-slugs.test.ts:2,23,32,49`. They are test consumers themselves: route registry/classification, approval base inference, startup/first-run selection and plugin mapping assertions. No test imports `dynamicRouteFromPath` directly; production-router tests reach it through `startApplicationRouter`. The query fixture's seven test users and all four builder imports are listed above. Recovery is unchanged from main. The former branch-only `replaySessionRoute` / `SessionRouteRecoveryState` module is absent; `startApplicationRouter` retains its synchronous observer and microtask replay, covered by unchanged `app/session-route-recovery.test.ts` and the two reconnect browser flows. No new asynchronous recovery boundary remains. Adjacent Usage remains base-owned and unchanged: route registration uses `loadUsageRouteData` from #145402; `usage-page.ts:239` consumes admitted data; `requestUsageSnapshot` remains the shared request owner, and `lit/gateway-page-controller.ts:110` validates client/hello identity. The branch-only `loadUsageRoute` is absent. Additional loader/data test readers remain `pages/usage/usage-page.test-support.ts:182`, `pages/usage/usage-page-details.test.ts:784`, `pages/gateway-source-replacement.test.ts:224`, and `pages/route-provenance.test.ts:111`; their request/result contracts are unchanged. No display sentinel enters the changed typed paths or identities. No schema, migration, configuration key or protocol changes. ## Contention The classifier and query builder are synchronous pure operations. They hold no lock or transaction and add no wait. The unchanged Sessions page retains one in-flight list slot and its managed owner retains a trailing refresh queue (`sessions-page.ts:551`, `lib/sessions/session-managed-list-refresh.ts:169`). The helper move does not change either owner. Recovery and its microtask remain byte-for-byte from main; normal navigation uses the shared classifier. ## Invalidation No new cache or asynchronous boundary. Recovery and its invalidation behavior are unchanged from main. The existing plugin-slug map refreshes on startup and changed hello; static route maps retain module lifetime. Sessions bindings recompute on filters, deep-link/status changes, agent scope, context/capability replacement and page updates; disconnect/disposal invalidates pending page work. Usage retains admission checks, cancellation, client/hello/agent-scope checks, scope subscriptions, reconnect refresh, manual/filter refresh and disposal cancellation. Reload and restart construct fresh owners. ## Tests and deletion ledger No test case is deleted, disabled or skipped. - `app/session-route-recovery.test.ts`: restored exactly to main because recovery is unchanged. Its existing router/start/navigation scenarios pass. - `app-route-paths.test.ts`: the two former legacy-matcher tests now exercise `createApplicationRouter().routeIdFromPath`, retaining root/base-mounted links, settings detail routes and nested-path rejection. - `e2e/session-link-reconnect.e2e.test.ts`: restored exactly to main; both registered browser flows pass. The branch-only held-import case is retired with the removed lazy recovery mechanism. No main test is removed. - Sessions `route.test.ts`, `sessions-page.test-support.ts` and `app-sidebar.child-history-freshness.test.ts`: query-helper imports/names move; registered loader/page and sidebar-refresh assertions remain. All seven indirect fixture users are named above. - The discriminating sibling is `pages/workboard/route.test.ts`; the targeted set also covers Usage admission, Sessions roster and sidebar behavior. - Older real-Gateway empty-state captures from `c72997b42e243d41349f26e30eb95d768e637d98` remain historical evidence only. They are not exact-head captures. The retained be3c2b1e/210c6fc5 browser evidence is the production-bundle reconnect suite; fresh hosted real-Gateway validation remains part of this revision's CI. Removed mechanisms: the duplicate private router classifier now uses the pathname owner; `sessionsPageListQuery` is replaced by the identical `buildSessionsListQuery` body in `pages/sessions/list-query.ts:19`; the unsuccessful lazy replay trial is removed completely. Recovery remains router-owned and unchanged from main. No retired export alias remains. ## Measured scope correction on the prior base The temporary single-mechanism variants and rejected `fb5279bb` combination were measured against base `da762af0`. The retained combination was committed as `be3c2b1e`. These are historical experiments, not measurements of `db654b4`. The first rebased combination grew startup from 352,969 to 354,408 bytes. Isolated trials measured classifier-only at 352,925, lazy-recovery-only at 353,062, and query-only at 352,385 bytes. Removing lazy recovery produces the final 352,387-byte combination and removes 38 lines net across the nine changed files. The full contrary measurements remain retained; no budget was weakened. ## Integration status Main's Usage implementation is retained. Structural fixes from #145415 and #145516 are present, and #145540 fixes the former test-type failure. The branch has been rebased once onto the stated base. Fresh CI is green with zero failures. Landing still requires the independent census verdict and the orchestrator's grants. Co-authored-by: Ayaan Zaidi <[email protected]>
## Problem and fix The Control UI startup bundle grew past its original budget in openclaw#145347. This PR keeps route definitions light: one pathname owner classifies dynamic routes, Sessions query construction lives with the lazy page, and duplicate router classification is removed. Recovery remains unchanged from main. Main now owns the Usage lazy-loader extraction through openclaw#145402. This rebased PR retains both Usage files exactly from main and contains only the remaining 9 router/Sessions files. Picker structural fixes have landed separately; this PR changes no budget, baseline, compressor, ignore rule, schema, configuration key or protocol. ## Current revision and labeled proof Current head: `db654b48699c75f521ed5b9628f54f40832bce62`, rebased onto `64fa7d74b99eb51ad9fcf26d8013441f0e95673c`. Main includes openclaw#145540, commit `c046e868`, which fixes the former test-type error. All five commits are unchanged in the rebase range-diff; the final patch remains nine files and 38 fewer lines. - Fresh census passes on CI merge `e7b38fecdd40487f169deda8a7dd699e9b44138a`. The exact native command `pnpm ui:check-performance:base 64fa7d7` passes there at **352,276 bytes gzip**, with **2,840 bytes of headroom** below the unchanged 355,116-byte limit. Fresh CI run **34670046624 / attempt 1** completed successfully: **87 passed jobs, 13 skipped, zero failures**. The test-type gate and all structural/UI/browser checks, including real-Gateway tests, passed on this revision. - Prior paired performance proof belongs to the source tree committed as `be3c2b1ea9aebdf648fc9f4cd8655e3a95ea97af`, compared with base `a36b17617e45afce9b8571a69ffd5f26b3771360`: 352,387 versus 352,969 bytes gzip, saving 582 bytes. These are not new-head measurements. - Prior CI merge `210c6fc5182f32c83ff97d90bfe0ed94d3d588c5` measured 352,542 bytes gzip both natively and in CI, with 2,574 bytes below the unchanged 355,116-byte limit. That result remains labeled with its old tested merge. - On the prior source tree and prior CI merge, all 132 targeted tests in seven files and both production-bundle reconnect cases passed. Prior CI run 34668494939 / attempt 1 also passed all UI/browser suites, including real-Gateway tests, and all lint/format/ratchet checks. Its test-type failure was inherited from main; this revision must pass that check. - Source review at `be3c2b1e` remains applicable to the unchanged patch. Its original artifact is retained without relabeling it as a new-head review. Fresh CI validates integration with the new base. - Historical introducing-parent proof for openclaw#145347 measured 354,263 bytes on its parent and 354,498 on the introducing commit, crossing the then-current 354,270-byte limit. Current main already passed before this rebase; this PR is a measured performance refactor, not a claim of a current budget outage. - Older-host/previous-state and config-corpus gates do not apply: no plugin runtime, SDK, version, updater, Doctor, config loading or persistence change. ## Consumers Inventory at `db654b48699c75f521ed5b9628f54f40832bce62`; paths below are relative to `ui/src/`; bare Sessions filenames are relative to `ui/src/pages/sessions/`. Both symbol searches and import/re-export path searches cover all of `ui/src`, including tests and support files. The import inventory includes 188 files and 201 statements for `app-route-paths`, `app-routes`, and `list-query`; imports of unrelated constants, path constructors and types are not classifier calls. There is no namespace/star import or renamed binding hiding another classifier/query call, and no extensionless or `.js` import of these owners. The `import("../../app-routes.ts").RouteId` in `test-helpers/app-sidebar-cases/sidebar-zone.ts:50` is type-only. Earlier cross-tree searches also covered `src/`, `extensions/`, `apps/`, docs and schemas; no external contract changes. Coverage citations identify existing tests, not new executions. Mounted-page tests exercise the registered element but sometimes call its methods; they are not claims of a live Gateway operation. Renderer/helper coverage is marked separately. Execution labels remain those in the proof section above. Current archived job **103489709553** and transcript job **103489709586** passed on merge **e7b38fecdd40487f169deda8a7dd699e9b44138a**, in run **34670046624 / attempt 1**. ### Sessions query: all direct readers and all wrapper reads `sessionsPageListQuery` is retired. Its identical implementation is `buildSessionsListQuery` at `pages/sessions/list-query.ts:19`; `SessionsPageListFilters` is private there, with its sole parameter use at `:21`. Existing `SessionsRouteData` consumers remain on `route.ts`. Exactly four files import the builder: | Reader and read path | Behavior and existing covering test | | --- | --- | | `pages/sessions/sessions-page.ts:79,104,453–464` | Import, binding query type, and the sole production builder call in `sessionListOptions`. Mounted `openclaw-sessions-page`: `pages/sessions/sessions-page.roster.test.ts:367` checks selected/all-agent query switching. | | `pages/sessions/sessions-page.test-support.ts:16,231` | Builds the initial managed query before mounting the registered Sessions element (`:225–252`). Its seven users are `sessions-page.test.ts`, `.archived.test.ts`, `.groups.test.ts`, `.plugin-actions.test.ts`, `.roster.test.ts`, `.transcript-search.test.ts`, and `.typing.test.ts`, all in `pages/sessions/`; behavior coverage is mapped below. | | `pages/sessions/route.test.ts:7,43` | Supplemental query assertions accompany registered `page.loader` cases at `:33–113`: selected active, all-agent archived, selected all-status and another agent's deep link. Loader no-list assertions remain. | | `components/app-sidebar.child-history-freshness.test.ts:13,249` | Query fixture for the mounted sidebar. `:240–301` checks fresh child labels/running state after older pages settle; this is a test reader, not a production sidebar import of the builder. | `sessionListOptions` has exactly four reads, with three request pipelines and one invalidation key: | Read and complete downstream path | Existing covering test | | --- | --- | | **Sessions list**: `sessions-page.ts:473` → binding/subscription `:467–513` → `loadSessionList` `:551–581` → managed query window `lib/sessions/session-managed-list-refresh.ts:91–164,169–183` → encoding `lib/sessions/session-requests.ts:163–186` → `sessions.list` → accepted snapshot `sessions-page.ts:515–533` → `renderSessions` `:1606` / `pages/sessions/view.ts`. Query reuse also occurs in refresh/snapshot adoption (`:547,558,580,592`), binding retirement (`:193`), binding key construction (`:474`), and the old-query loading check (`:479`). Load-more reads accepted `nextOffset`/`hasMore` (`:1713–1718`); filter/status/deep-link/scope changes rebuild the binding. | Mounted page `sessions-page.roster.test.ts:44–116` (latest query/retired rows), `:117` (append server page), `:308` (reconnect), `:329` (capability replacement), `:367` (scope), `:416` (last-good rows), `:451` (explicit refresh). Mounted input `sessions-page.typing.test.ts:420,463` checks coalescing and debounce. | | **Transcript search**: Task `sessions-page.ts:200–231` → wrapper read `:225` with empty metadata search → `lib/sessions/transcript-search.ts:68–119` → paged `sessions.list` → grouping keys by agent → `sessions.search` → Task completion `sessions-page.ts:1622–1627` → hits/status in `view.ts:383–385,505`; hit activation calls the page's navigation callback (`sessions-page.ts:1753`). Other filters, deep links and scope remain active. Client/context/scope/capability/submitted-query changes retire pending work; `isCurrent` carries retirement through paging. | Mounted `sessions-page.transcript-search.test.ts:26` (bounded results/status), `:91` (all-agent fanout), `:171,208` (query/scope retirement), `:335` (error/retry), `:370–438` (fresh roster after filters and metadata-query exclusion). Renderer `view.test.ts:349` checks provenance and matching-session activation. | | **Transcript invalidation key**: `sessions-page.ts:476` → JSON key built without metadata search → `:477–485` comparison/reset when query or capability changes. This is a separate query read, not another request. | `sessions-page.transcript-search.test.ts:370–438` checks that relevant filter changes refresh the roster while metadata-only edits neither narrow nor retire transcript search. | | **Delete all archived**: button `view.ts:1018–1028` → callback `sessions-page.ts:1728` → `deleteAllArchived` `:826–881` → wrapper read `:843` → builder → `fetchPagedSessionRows` / `scope.sessions.list` / `sessions.list` → archived-row filter → confirmation → `deleteSessions` `:739–823` → `deleteMany` → deletion owner `lib/sessions/session-deletions.ts:181–209` → encoder `session-requests.ts:213–227` → `sessions.delete` → selection/deep-link cleanup and refresh. The options are snapshotted once, metadata `search` and linked `agentId` are removed, selected agent scope is restored, and page size is 1000. Failed/incomplete enumeration aborts. Original request scope is checked while paging and after confirmation (`sessions-page.ts:319–349,848,876`). Current deletion access, expected session generation and archived-only checks remain. | Mounted `sessions-page.archived.test.ts:81–142` (full enumeration), `:165–243` (failure/paging), `:246` (moved/duplicate rows), `:312–367` (incomplete enumeration refusal), `:370–424` (all-agent/selected-agent deep-link exclusion through final deletion targets). All ten existing cases passed job **103489709553** on **e7b38fec**. | ### Downstream readers of the accepted Sessions roster These consume returned rows or page callbacks; they do not call the builder independently. The page owns the accepted `result`, while the managed-list owner owns publication. In addition to render/paging, every `this.result` read is accounted for below. | Reader and read path | Existing covering test and scope | | --- | --- | | Snapshot projection `sessions-page.ts:525–529` → archive filtering, `ensureAgentIdentities`, checkpoint-cache reconciliation; render reads `:1583,1606,1630` → owner availability, row identities, grouping/sort/pagination, details, links and controls in `view.ts`. | Mounted `sessions-page.roster.test.ts:481` checks result-pointer/cache reconciliation; `sessions-page.test.ts:97` checks active/archived routing. Renderer `view.test.ts:110,158,427,458,479,581,1077` checks headings, sorting, status, archived rows, pagination, owner grouping and identities. These renderer cases supplement the mounted-page path. | | **Selected/bulk deletion**: selection callbacks `sessions-page.ts:1731–1752` → `deleteSelected` `:708–737`, which snapshots selected rows from `this.result` at `:718` → confirmation/scope check → the same `deleteSessions` / `deleteMany` / `sessions.delete` chain above. `selectedDeleteDisabledReason` reads rows at `:378` for per-row authority. This population is the current selection, distinct from full archived enumeration. | Mounted `sessions-page.test.ts:414–467` checks session-generation snapshots during confirmation; `:468–503` checks optimistic removal with concurrent roster publication; `:504–524` rejects a changed Gateway; `:570–612` checks per-row archive authority. Renderer `view.test.ts:261` checks selectable identities. | | **Row deletion and archive/unarchive**: `renderSessionMenu` looks up exact key/sessionId at `sessions-page.ts:1451`, then menu dispatch `:1559–1574` → `archiveSessionWithUndo` `:1177–1204`, `patchSession` `:1119–1175`, or `deleteSessionFromMenu` `:883–897` → shared deletion. Archive Undo remains store-owned after page navigation. | Mounted `sessions-page.test.ts:133,173` (Undo and navigation), `:328` (archive versus deletion access), `:525–612` (archived/active/unknown deletion authority); `sessions-page.archived.test.ts:30` (optimistic deletion rejection). | | **Groups**: `knownCategories` reads result at `sessions-page.ts:950`; drag/drop `assignCategory` finds an existing row at `:988`; `requestNewCategory` captures identity at `:1039` → group catalog write before session assignment/patch. Rendered group controls use the same accepted rows. | Mounted `sessions-page.groups.test.ts:56,123,227,242,250,259,269` covers write ordering, stale connection, captured identity, empty groups, failed catalog write and unbound/stale assignment. Renderer `view.test.ts:638,695` covers group cell/drop controls and write access. | | **Checkpoint details**: `toggleSessionDetails` reads row checkpoint metadata at `sessions-page.ts:1260`; accepted-result reconciliation is at `:529`; detail/branch/restore callbacks are at `:1771–1775`. | Mounted `sessions-page.test.ts:245,353` checks disconnected drawers and retirement of checkpoint work; `sessions-page.roster.test.ts:481` checks cache reconciliation. Renderer `view.test.ts:244` checks visible checkpoint failure. | | **Menus and row actions**: exact-generation row lookup `sessions-page.ts:1451` supplies menu labels, pin/unread/category/appearance, permissions, fork state, worker state, work details and plugin descriptors (`:1461–1506`). Dispatch `:1507–1575` supplies that row to navigation/copy, patch/rename, fork, group, archive/delete, owner assignment and cloud-worker actions. View callbacks also navigate/open menus from accepted rows (`:1753–1770`). | Mounted `sessions-page.test.ts:222,306,375,615,678,819` covers read marking, locked fork, disconnect/menu retirement, worker stop/reclaim and active-session fork; archive/delete/group cases above cover those dispatches. Renderer `view.test.ts:291,738` covers links/menu opening. These are representative action/dispatch assertions, not a claim of a separate mounted-page assertion for every menu action; unchanged menu/navigation owners have their own `components/session-menu.test.ts` and `lib/sessions/session-menu-navigation.test.ts`. | | **Plugin action freshness**: menu descriptors read the current row (`sessions-page.ts:1504`); `runPluginAction` re-reads exact key/sessionId at `:1791` before calling the plugin action owner, with page-lifetime cancellation. | Mounted `sessions-page.plugin-actions.test.ts:76,105,130` checks labels/disabled state, current scoped session values, and removed/replaced rows. | ### Shared route classifier: all owner, router and direct downstream reads `app-route-paths.ts` is the single pathname-classification owner. Its private `dynamicRouteIdFromPath` (`:465`) has exactly three calls: bridge adaptation (`:499`), route-ID lookup (`:527`), and base inference (`:573`). Private `isLegacyPluginsDiscoveryPath` (`:339`) has exactly one call (`:487`). The removed router duplicate and private `DynamicRoute` annotation have no remaining reader or alias. The exported bridge result retains route ID, search key and real pathname; static Memory overview and static-route precedence stay intact. | Reader and read path | Existing covering test | | --- | --- | | Bridge adapter `dynamicRouteFromPath` (`app-route-paths.ts:496–503`) → three runtime reads in `app-routes.ts`: `routerHistoryLocation` `:173`, initial dynamic navigation `:247`, later history navigation `:364`. | `app-route-paths.test.ts:170` starts the registered application router for dynamic-route startup; `app-navigation.test.ts:477` checks session navigation; `pages/workboard/route.test.ts:104` onward checks final history/state through registered navigation/preload. Bundled `e2e/session-link-reconnect.e2e.test.ts:62–118` checks both final visible destinations/URLs after reconnect. | | `routeIdFromPath` (`app-route-paths.ts:506`) → router facade option `app-routes.ts:168` and re-export `:395–401`; `startApplicationRouter` reads it for initial canonicalization `:219`, unknown-route fallback `:238`, and later canonicalization `:357`. Router consumers use this supplied callback for location navigation/preload. | `app-route-paths.test.ts:170` onward (startup), `app-navigation.test.ts:343–548` (route families, aliases, base mounts, malformed paths, static precedence), `pages/workboard/route.test.ts` (navigation/preload), `e2e/plugin-tab-slugs.e2e.test.ts:95` (unknown slug after hello). | | **Startup warming**: `app/bootstrap.ts:586–589` → `warmApplicationRouteModule` (`app-routes.ts:128–137`) → route-ID read `:133` → `router.getRoute(routeId)` → `route.component()`. Explicit initial routes start their lazy download before normal routing without executing the loader. Default first-run landing waits for setup's destination. | `app/bootstrap.test.ts:132–174`, “warms only explicit application routes at startup”, covers explicit routes/deep links and default/focus/approval exclusions; first-run/default setup cases follow at `:216` onward. | | Bootstrap landing/default decisions: `app/bootstrap-location.ts:29–34`; `app/bootstrap.ts:213,678,688` passes or reads the classifier; `pages/model-setup/first-run.ts:11–16` invokes that supplied callback. | `app/bootstrap-location.test.ts:7–113` checks persisted/default and explicit startup routes; `pages/model-setup/first-run.test.ts:88–149` checks the default-landing predicate; `app/bootstrap.test.ts:216` onward checks initial-route selection and retirement. | | Native shell navigation: `app/app-shell-chrome.ts:297` classifies native paths, then retains the full destination for `host.navigate`. | Registered shell event-handler test `app/app-host-native-shell.test.ts:422–459` checks destinations and acknowledgement across root/base mounts. | | Deferred shell panels: `app/app-shell-panels.ts:104–108` reads the current pathname's route ID, with route-state fallback, to decide session-panel ownership. | Registered shell owner test `app/app-host.panel-toggles.test.ts:161` checks toggle buffering until the chat pane mounts; restoration/retry cases follow. This exercises the owner/fallback path; route-path classification itself is asserted in `app-navigation.test.ts:343–548`. | | Markdown links: `components/markdown.ts:351–362` classifies root and configured-base paths before docs-link rewriting. | Renderer entry `toSanitizedMarkdownHtml` in `components/markdown.test.ts:425–451` checks app links, docs roots and base-mounted app/resource links. | | Custodian user-turn context: `pages/custodian/session-lifecycle.ts:25–27` combines base inference and route ID into `context.page`. | Mounted page `pages/custodian/custodian-page.test.ts:306–340` checks resolved/unknown paths, excludes context from initial turns and observes user-turn request context. | | Base inference `app-route-paths.ts:553–579` → browser route/resource bases `app/browser.ts:36`. | `app/browser.test.ts:10–34` checks configured, inferred, root-resource and cold plugin paths. | | Base inference → public asset URLs `app/public-assets.ts:41`. | `app/public-assets.test.ts:63–98` checks nested mounts, ambient-state independence and explicit-base precedence. | | Base inference → startup settings `app/startup-settings.ts:194–198` → session-route detection before token-triggered session reset (`:236`). | Startup entry `app/settings.node.test.ts:45,60` exercises this read during fragment credential handling; `app-navigation.test.ts:551–582` directly checks mounted-path inference. These do not independently assert the token-on-mounted-session reset branch. Custodian's additional base-inference read is listed above. | | Private discovery matcher → private classifier at `app-route-paths.ts:487`. | The two rewritten cases `app-route-paths.test.ts:710–721` exercise `createApplicationRouter().routeIdFromPath`, retaining root/base discovery, settings detail and nested-path rejection. | ### Classifier output: every pathname-bridge reader The shared restorer (`app-route-paths.ts:605–617`) removes the internal parameter and restores the real location. `app-route-paths.test.ts:549–582` checks absent/empty/duplicate/encoded values without mutating the source. The full production import/read inventory of the internal path parameters is: | Reader and read path | Existing covering test | | --- | --- | | Chat/dashboard loader dependencies `pages/chat/route.ts:13–24`; ordinary target restoration `pages/chat/route-loader.ts:138–156`; catalog-share target restoration `pages/chat/route-loader-catalog-share.ts:18–30`. These feed registered chat/dashboard route loading and final destination data. | `app-route-paths.test.ts:170` onward exercises the initial bridge; `pages/chat/route.test.ts:61,107,241` covers resolved targets/dashboard data; `pages/chat/route-loader-catalog-share.test.ts:257` checks the internally bridged stale-name/full-ID path. The two bundled reconnect cases cover final rendered session destinations. | | Terminal `pages/terminal/route-location.ts:14` → terminal target/catalog query. | `pages/terminal/route-location.test.ts:35` restores an initial dynamic path with its remaining query. | | Agents `pages/agents/route-location.ts:19` → agent/panel location. | `pages/agents/route-location.test.ts:87` checks restored path and removal of the internal parameter. | | Activity `pages/activity/route.ts:9` → person/filter route data. | Registered loader `pages/activity/route.test.ts:51` compares direct and bridged paths under a mount. | | Workboard `pages/workboard/route-location.ts:22` → board/filter location. | Registered router `pages/workboard/route.test.ts:104` onward checks canonicalization, newer-navigation preservation and preload; final history/route data are asserted. | | Memory `pages/config/route-data.ts:50–64` → pathname/search/tab data. | `pages/config/route-data.test.ts:72` restores the dynamic Memory path and preserves the agent query. | | Plugins and plugin settings `pages/plugins/route-data.ts:19–23` → nested restorer for both internal parameters. | `pages/plugins/route-data.test.ts:32,42` checks hub and settings-detail restoration without parameter leakage. | | Plugin tabs `pages/plugin/route.ts:15–22` → advertised tab lookup from bridged pathname, then tab reference/page params. | `pages/plugin/tab-slugs.test.ts:21–33` checks bridge lookup; bundled `e2e/plugin-tab-slugs.e2e.test.ts:53,107` checks the tab shell and generic-URL canonicalization with params/hash. | ### Direct test imports and retained adjacent owners Direct route-ID/base-inference test import readers are exactly `app-route-paths.test.ts`, `app-navigation.test.ts`, `app-routes.test.ts:2,22`, `app/approval-deep-link.test.ts:3,62–63`, `app/bootstrap.test.ts:6,299`, `pages/model-setup/first-run.test.ts:3,88–149`, and `pages/plugin/tab-slugs.test.ts:2,23,32,49`. They are test consumers themselves: route registry/classification, approval base inference, startup/first-run selection and plugin mapping assertions. No test imports `dynamicRouteFromPath` directly; production-router tests reach it through `startApplicationRouter`. The query fixture's seven test users and all four builder imports are listed above. Recovery is unchanged from main. The former branch-only `replaySessionRoute` / `SessionRouteRecoveryState` module is absent; `startApplicationRouter` retains its synchronous observer and microtask replay, covered by unchanged `app/session-route-recovery.test.ts` and the two reconnect browser flows. No new asynchronous recovery boundary remains. Adjacent Usage remains base-owned and unchanged: route registration uses `loadUsageRouteData` from openclaw#145402; `usage-page.ts:239` consumes admitted data; `requestUsageSnapshot` remains the shared request owner, and `lit/gateway-page-controller.ts:110` validates client/hello identity. The branch-only `loadUsageRoute` is absent. Additional loader/data test readers remain `pages/usage/usage-page.test-support.ts:182`, `pages/usage/usage-page-details.test.ts:784`, `pages/gateway-source-replacement.test.ts:224`, and `pages/route-provenance.test.ts:111`; their request/result contracts are unchanged. No display sentinel enters the changed typed paths or identities. No schema, migration, configuration key or protocol changes. ## Contention The classifier and query builder are synchronous pure operations. They hold no lock or transaction and add no wait. The unchanged Sessions page retains one in-flight list slot and its managed owner retains a trailing refresh queue (`sessions-page.ts:551`, `lib/sessions/session-managed-list-refresh.ts:169`). The helper move does not change either owner. Recovery and its microtask remain byte-for-byte from main; normal navigation uses the shared classifier. ## Invalidation No new cache or asynchronous boundary. Recovery and its invalidation behavior are unchanged from main. The existing plugin-slug map refreshes on startup and changed hello; static route maps retain module lifetime. Sessions bindings recompute on filters, deep-link/status changes, agent scope, context/capability replacement and page updates; disconnect/disposal invalidates pending page work. Usage retains admission checks, cancellation, client/hello/agent-scope checks, scope subscriptions, reconnect refresh, manual/filter refresh and disposal cancellation. Reload and restart construct fresh owners. ## Tests and deletion ledger No test case is deleted, disabled or skipped. - `app/session-route-recovery.test.ts`: restored exactly to main because recovery is unchanged. Its existing router/start/navigation scenarios pass. - `app-route-paths.test.ts`: the two former legacy-matcher tests now exercise `createApplicationRouter().routeIdFromPath`, retaining root/base-mounted links, settings detail routes and nested-path rejection. - `e2e/session-link-reconnect.e2e.test.ts`: restored exactly to main; both registered browser flows pass. The branch-only held-import case is retired with the removed lazy recovery mechanism. No main test is removed. - Sessions `route.test.ts`, `sessions-page.test-support.ts` and `app-sidebar.child-history-freshness.test.ts`: query-helper imports/names move; registered loader/page and sidebar-refresh assertions remain. All seven indirect fixture users are named above. - The discriminating sibling is `pages/workboard/route.test.ts`; the targeted set also covers Usage admission, Sessions roster and sidebar behavior. - Older real-Gateway empty-state captures from `c72997b42e243d41349f26e30eb95d768e637d98` remain historical evidence only. They are not exact-head captures. The retained be3c2b1e/210c6fc5 browser evidence is the production-bundle reconnect suite; fresh hosted real-Gateway validation remains part of this revision's CI. Removed mechanisms: the duplicate private router classifier now uses the pathname owner; `sessionsPageListQuery` is replaced by the identical `buildSessionsListQuery` body in `pages/sessions/list-query.ts:19`; the unsuccessful lazy replay trial is removed completely. Recovery remains router-owned and unchanged from main. No retired export alias remains. ## Measured scope correction on the prior base The temporary single-mechanism variants and rejected `fb5279bb` combination were measured against base `a36b1761`. The retained combination was committed as `be3c2b1e`. These are historical experiments, not measurements of `db654b4`. The first rebased combination grew startup from 352,969 to 354,408 bytes. Isolated trials measured classifier-only at 352,925, lazy-recovery-only at 353,062, and query-only at 352,385 bytes. Removing lazy recovery produces the final 352,387-byte combination and removes 38 lines net across the nine changed files. The full contrary measurements remain retained; no budget was weakened. ## Integration status Main's Usage implementation is retained. Structural fixes from openclaw#145415 and openclaw#145516 are present, and openclaw#145540 fixes the former test-type failure. The branch has been rebased once onto the stated base. Fresh CI is green with zero failures. Landing still requires the independent census verdict and the orchestrator's grants. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes an issue where users received only “The agent run failed before producing a reply” after an Anthropic-compatible provider rejected a follow-up request, even when the upstream response explained exactly what was invalid. Long JSON error responses were truncated before redaction, leaving an unreadable diagnostic placeholder.
Why This Change Was Made
Preserve HTTP status and bounded structured error data before redaction and display clipping. Read the terminal upstream rejection from proxy attempt envelopes, and share curated request-limit copy between live failures and saved chat history. Credential and media redaction, the existing 500-character error-body preview, retry timing, compaction-replay rejection handling, and existing recovery-message precedence remain in place.
The earlier CI base already exceeded its startup JavaScript budget; controlled builds of the original PR merge and base produced 1,320 byte-identical browser assets. A bounded Usage-route repair defers page-specific initialization and rendering until navigation, saving 426 gzip bytes without changing budgets. Connection, scope, and date are captured before the import, and request ownership is revalidated afterward. Module-load failures use the existing router error/Retry display; RPC failures retain their inline explanations.
An unchanged MCP doctor regression moves into its existing JSON-failure suite, restoring the 720-root test-group limit without removing coverage. The conflicting New Session/account-picker cleanup was dropped during the required rebase: #145415 independently landed those fixes and the shared picker animation-completion helper on main. This PR retains no duplicate picker implementation or test rewrite.
User Impact
A request rejected for five cache-control blocks now explains that the provider allows four and the request contained five. Operators retain the redacted upstream diagnosis in logs instead of a hash of a generic placeholder. This PR repairs OpenClaw's error handling; the proxy's extra cache marker is a separate owner-level fix.
Evidence
Final exact-head CI run 34666385581 passed, including the required aggregate gate.
Regressions failed on the original transport, shared error projection, live error formatter, and persisted chat projection; the repaired paths pass.
Focused transport, redaction, failover, and saved-history tests passed, including Mistral preview compatibility. The final preview-cap correction passed 485 tests; the Usage/router boundary passed 16 tests, covering import-time retirement, navigation/preload cancellation, and redaction.
node scripts/check-changed.mjspassed for the final combined core, test, UI, and docs changes, including typechecks, lint, unused-export scans, and runtime import cycles.Independent reviews found no actionable P0–P2 findings. The provider/Usage patch remained identical across the CI-driven rebase; the final guard and CI repairs passed separate fresh reviews.
Fresh live candidate transport received the real provider HTTP 400 / 2,282-byte response from a synthetic image-and-tool-result request. It retained the status and exact maximum-four/found-five reason in its complete error message while keeping the separate preview at 500 characters plus its truncation suffix. A transient provider 503 cleared on one retry of the same route. Replaying the previous clipping against the same response reproduced the unreadable placeholder.
The repaired head passed hosted CI’s Control UI performance check. Local measurement was 353,996 B startup gzip versus its 354,270 B limit; startup CSS remained 45,842 B. A browser module-load failure probe showed a visible Retry action, redacted diagnostics, and zero Usage RPCs.
Seven cloud recovery/dispatch browser cases pass after adopting the upstream picker helper.
The cursor and picker guard repairs are now inherited from main through fix: show package icons instead of generated plugin artwork #145415; their overlapping commits were removed. The retained provider/Usage patch and MCP test consolidation have identical patch IDs across the conflict-driven rebase.
All nine consolidated MCP JSON-failure cases passed, including the unchanged moved directory/PATH case; the test ownership guard passed at 720 roots.
Actual live-failure formatting and saved-history projection both produced the specific cache-limit explanation. The real Control UI rendered these results through synthetic Gateway fixtures, with zero browser page errors. These are UI boundary captures, not production-Gateway screenshots.
Before:
After: