Skip to content

test(ui): fix retained machine capture reference - #145540

Merged
steipete merged 1 commit into
mainfrom
codex/pr145463-capture-composition-20260912
Sep 12, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/pr145463-capture-composition-20260912

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Refs #145463 #145436

What Problem This Solves

The merged New Session cloud-dispatch proof fails with ReferenceError: retainedMachine is not defined when OPENCLAW_CAPTURE_UI_PROOF=1 is enabled. The two independently passing PRs composed a new screenshot reference with an earlier removal of that local variable.

Why This Change Was Made

Use the same scoped Fast-machine locator that the test already uses immediately above the capture. This is a one-line repair; interaction, selection and dispatch assertions remain intact.

User Impact

Restores the synthetic capture flow without changing production UI or timing limits.

Evidence

Reproduced the failure on merged main da762af0e80c9fe6a61422dc5591ab24e5c9a3ce. The repaired cloud-dispatch case passes with capture enabled in 22.16 seconds, and its synthetic screenshot was inspected. The other three capture cases passed during that merged-main replay.

Targeted type-aware lint, the UI E2E typecheck, git diff --check, and fresh P2 autoreview passed. No retries, timeouts, assertions, snapshots, or production behavior changed.

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XS maintainer Maintainer-authored PR labels Sep 12, 2026
@steipete
steipete marked this pull request as ready for review September 12, 2026 02:41
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 10:47 PM ET / September 12, 2026, 02:47 UTC.

ClawSweeper review

What this changes

Repairs the New Session browser test’s screenshot capture by replacing an undefined variable with the existing Fast-machine locator.

Merge readiness

✅ Ready for maintainer review

The repair remains necessary on inspected main and has no actionable correctness findings. The maintainer-authored, protected PR should remain open for normal landing.

Priority: P3
Reviewed head: a105d9ad727dc3db07046618b5abc7a9ae1335de

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow, source-supported repair preserves existing assertions and includes relevant reported validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor gate does not apply to this maintainer-authored test repair; its body reports the exact capture-enabled browser case passing, without claiming production cloud execution.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor gate does not apply to this maintainer-authored test repair; its body reports the exact capture-enabled browser case passing, without claiming production cloud execution.
Evidence reviewed 7 items Verified introduced change: The pinned merge-base-to-head diff replaces only the undefined retainedMachine reference at line 438; interaction, selection, dispatch, and timing assertions remain unchanged.
Current main still needs the repair: Inspected main retains the undefined reference at line 438. Immediately preceding assertions already use the proposed scoped locator and verify that Fast is visible and selected.
Capture helper contract: The complete helper accepts Locator objects, waits for their visibility and surface readiness, then captures the viewport. The replacement preserves that contract.
Findings None None.
Security None None.

How this fits together

The Control UI browser tests exercise session creation using a synthetic Gateway. Optional screenshot capture waits for the selected cloud configuration to become visible before recording proof artifacts.

flowchart LR
  A[Synthetic Gateway responses] --> B[New Session browser test]
  B --> C[Retained cloud and machine selection]
  C --> D{Capture enabled}
  D -->|Yes| E[Wait for visible configuration]
  E --> F[Screenshot artifact]
  D -->|No| G[Continue dispatch assertions]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests 0. Total 0 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 1 1 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 1 1 0

Review metrics

None.

Technical review

Best possible solution:

Keep the existing screenshot readiness helper and supply the already-validated scoped machine locator.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: enabling OPENCLAW_CAPTURE_UI_PROOF reaches an undefined retainedMachine reference on inspected main. This review did not execute the browser test.

Is this the best way to solve the issue?

Yes. Reusing the locator already checked immediately above the capture fixes the reference without weakening assertions or introducing another helper.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 828cedb240bf.

Labels

Label changes:

  • add P3: This is a bounded synthetic-proof capture repair with no production UI behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor gate does not apply to this maintainer-authored test repair; its body reports the exact capture-enabled browser case passing, without claiming production cloud execution.

Label justifications:

  • P3: This is a bounded synthetic-proof capture repair with no production UI behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor gate does not apply to this maintainer-authored test repair; its body reports the exact capture-enabled browser case passing, without claiming production cloud execution.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 41861b8 into main Sep 12, 2026
135 checks passed
@steipete
steipete deleted the codex/pr145463-capture-composition-20260912 branch September 12, 2026 03:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant