Skip to content

fix(control-ui): old tabs 404 on lazy chunks after every update - #163099

Merged
steipete merged 4 commits into
mainfrom
fix/control-ui-retained-identity-assets
Oct 2, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/control-ui-retained-identity-assets

Conversation

@steipete

@steipete steipete commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Related: #129922, #131930, #163090

What Problem This Solves

Fixes: already-open Control UI tabs fail to load routes they had not visited yet after every openclaw update, because the retained-asset cache always prunes the previous build.

User Impact

After an update, an open tab from the previous build can still load its lazy chunks. Those responses are uncompressed (identity bytes) instead of Brotli/gzip; the current build still serves its precompressed sidecars. The retained cache now holds about 70 MB on disk (current plus previous build) instead of about 53 MB (current only). If a future build grows too large for the previous generation to fit, the Gateway logs Control UI asset retention cannot keep the previous generation instead of failing silently.

Why This Change Was Made

The retention owner keeps at most 3 generations within 96 MiB (100,663,296 B), current first. When #129922 set that budget, a generation was 24.6 MB. A fresh pnpm ui:build today lists 1,434 assets totaling 53.1 MB, about a third of which is precompressed sidecars:

Manifest bytes (df8c0ee) Bytes
Identity assets (401 .js, 69 .css, 24 .webp) 35,090,278
.br sidecars (470) 8,430,582
.gz sidecars (470) 9,593,000
Total per generation 53,113,860
Current + previous, full 106,227,720 (over budget)
Current + previous, identity only 70,180,556 (fits)

Retained generations now store an identity-only manifest, named by its own hash. That is what old documents need: bundled .br/.gz URLs are never directly addressable (control-ui.ts 404s them), and the HTTP path already falls back to identity bytes when a retained sidecar is missing. The sidecar rule comes from the static-response owner (isControlUiPrecompressedAssetExtension), so retention follows that owner's sidecar policy.

Options weighed:

  • Chosen: drop sidecars from retained generations. Each generation shrinks by 34%, the absolute disk bound and generation limit stay unchanged, and no state or config is added.
  • Budget derived from the measured build: rejected. It removes the disk bound exactly when a build bloats, and the generation count limit already scales with build size.
  • Count only the bytes prior documents need: counting identity bytes while still storing sidecars would make the budget misreport real disk use. Storing only what is counted is the chosen option.

Tradeoffs: a stale tab downloads lazy chunks uncompressed during the post-update window, about 4 times the Brotli size (33.5 MB of JavaScript in this build is 8.4 MB as Brotli). A third generation (105.3 MB identity) no longer fits today's build; one prior covers the update contract. Identity bytes can grow to 48 MiB (50.3 MB) per build, about +43%, before the previous generation stops fitting. Locale catalogs are 19.1 MB (55%) of identity and grow with UI strings across 20 locales, so the new warning is the early signal.

Compatibility: the manifest format is unchanged. Directories written by older Gateways (full format, sidecars included) still verify as generations and count at their real size. On the first update onto this change, the new 35.09 MB identity-only current plus the old 53.11 MB full prior is 88.2 MB, so the operator's existing previous build survives. After a downgrade, an older Gateway reads identity-only directories as ordinary generations and serves identity bytes. All verification properties are untouched: manifest parse and hash, directory name equals generation, per-asset size and SHA-256, path containment, symlink and hardlink policy, staging and collision handling, prune claims, and cancellation.

Coordination: #163090 (on-miss lookups await the startup inventory) landed first by agreement, making resolveAsset async. This branch merges main and converts the new budget test's lookups to await. It also adds the identity-only HTTP case to #163090's control-ui-retained-assets.http.test.ts: the real owner publishes a prior build that ships .br/.gz sidecars, and a client accepting br, gzip gets 200 identity bytes with no Content-Encoding. That case fails on the pre-PR retention code, which answers with Brotli.

Evidence

  • Fresh measurement: pnpm ui:build at df8c0ee, manifest summed as in the table above. A read-only look at the operator's ~/.openclaw/cache/control-ui-assets showed a single generation of 53,076,371 B (35,065,545 identity), consistent with the bug.

  • Regression tests in the new src/gateway/control-ui-asset-retention.budget.test.ts, owner-level and worker-free, with sparse zero-filled fixtures at the measured sizes:

    • A previous build in the full format older Gateways published survives the next realistic build's publication. The new generation is identity-only and contains no sidecars, and no warning is logged.
    • The warning fires with exact bytes when a prior at exactly the budget cannot sit beside the current build.
    • With the production change reverted, both tests fail: the previous build resolves to undefined, and the warning is never called. Both pass with the change.
    • HTTP composition case (in control-ui-retained-assets.http.test.ts): an identity-only retained generation serves identity bytes to a client accepting br, gzip; with the production change reverted, the handler sets Content-Encoding: br and the case fails.
  • Test cost: pnpm test src/gateway/control-ui-asset-retention.budget.test.ts --maxWorkers=1 gave 3.9 s and 0.7 s per test (Duration 15.7 s; process CPU 5.7 s user + 3.6 s sys) on a host at load average ~81. On CI (checks-node-changed-compact-large-10, gateway-core shard) the tests took 120 ms and 73 ms; the local times were host contention.

  • Focused suites: on the merged head, the 4 existing retention files, the budget file, control-ui-retained-assets.http.test.ts, server-control-ui-root.resolve.test.ts, and control-ui.http.test.ts: 8 files, 148 tests passed.

  • Gates:

    • pnpm run tsgo:core passed.
    • pnpm run tsgo:core:test --ci-graphs-json '["core-test-gateway-root"]' passed.
    • pnpm check:import-cycles: 0 cycles.
    • oxfmt check: 3 files clean.
    • Type-aware oxlint: 263 rules on both touched files, 0 diagnostics. It was run from a symlink outside .claude/ because the parent checkout's ignore rules otherwise lint nothing.
    • Docs MDX and link checks passed; git diff --check was clean.
  • Autoreview (Codex, two passes, the second with the full retention module attached): no actionable findings.

  • Isolated Gateway proof at head 2fb0d8d, through the supported pnpm openclaw gateway run wrapper. Each phase used a fresh scratch state, a free loopback port, token auth, and no gateway.controlUi.root, so the bundled root was auto-resolved. Builds were real pnpm ui:build outputs (OPENCLAW_CONTROL_UI_BUILD_ID=dev with distinct build timestamps), each 1,434 assets and about 53.11 MB. P1 was a read-only copy of an older real generation. Probes ran only after preparation settled, in the same fresh process, against chunks that process had never served.

    Phase Cache before Current build Survivors after preparation Probe
    1: first update onto this fix P1 full (oldest), B1 full B2 B2 identity-only (35,090,235 B) + B1 full (53,113,020 B) = 88,203,255 B; P1 pruned B1-only chunk, Accept-Encoding: br: 200, Content-Encoding: br, bytes match its sidecar entry. P1-only chunk: 404
    2: next update Phase 1 survivors B3 B3 + B2, both identity-only = 70,180,470 B; B1 pruned B2-only chunk, Accept-Encoding: br, gzip: 200, no Content-Encoding, sha256 matches the identity entry

    In both phases, directory names match their manifest hashes, identity-only directories contain no sidecars or unlisted files, and the cannot keep the previous generation warning did not appear. The fail-before side of this composition comes from the owner-level regression test and the operator cache observation; the old code's 106.2 MB pair cannot fit the budget.

Retained Control UI generations let already-open documents from the
previous build load hashed lazy assets after `openclaw update` restarts
the Gateway. A current build manifest lists 53,113,860 bytes per
generation, 18,023,582 of them precompressed .br/.gz sidecars, so the
current generation plus one prior (106.2 MB) no longer fit the 96 MiB
budget and every preparation after an update pruned the previous build.

Retained generations now store an identity-only manifest named by its
own hash. Bundled sidecars are never directly addressable and a missing
retained sidecar is already served as identity bytes, so stale tabs keep
working with uncompressed responses while the current build still uses
its sidecars from the bundled root. Current plus previous now needs
70.2 MB. Existing full-format cache directories remain valid generations
in both upgrade and downgrade directions; every verification property is
unchanged. Pruning now warns when the byte budget drops the newest prior
generation, so a future build that outgrows the budget is visible.
@clawsweeper

clawsweeper Bot commented Oct 1, 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 docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 1, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 4:31 AM ET / 08:31 UTC (Revision 3).

ClawSweeper review

What this changes

The PR omits compressed sidecars from retained Control UI builds, warns when the previous build cannot fit, and adds documentation and regression coverage.

Merge readiness

✅ Ready for maintainer review

This repair remains necessary: current main still retains compressed sidecars and can prune the previous build. No actionable introduced defect was found, and the supplied Gateway evidence covers retention and existing-cache compatibility.

Priority: P2
Reviewed head: 36751552683189e3fcb93ce79d36df83e17ebe02

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-level repair with convincing Gateway observations, existing-cache coverage, and meaningful regression tests.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured isolated Gateway observations exercise retention preparation and previously unserved prior-only HTTP assets: an older full-format cache survives the first update, and the next identity-only generation returns matching bytes with HTTP 200 and no Content-Encoding. Existing-state compatibility is supported by that upgrade case and the unchanged manifest reader; later production changes incorporate the already-merged inventory wait.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured isolated Gateway observations exercise retention preparation and previously unserved prior-only HTTP assets: an older full-format cache survives the first update, and the next identity-only generation returns matching bytes with HTTP 200 and no Content-Encoding. Existing-state compatibility is supported by that upgrade case and the unchanged manifest reader; later production changes incorporate the already-merged inventory wait.
Evidence reviewed 10 items Pinned introduced change: Read the complete introduced diff between the pinned base and exact head. Production changes filter sidecars, recompute the retained manifest hash, and add a capacity warning; verification, publication, and pruning safeguards remain intact. The stale test merge was not used to infer merge effects.
Still missing on current main: The fetched main revision reads and publishes the complete build manifest within the unchanged 96 MiB budget. It contains the async inventory lookup repair but lacks identity-only retention.
Latest release also retains full manifests: The v2026.9.7 source likewise publishes the full manifest and applies the 96 MiB limit; this requested repair is not present in the supplied latest release.
Findings None None.
Security None None.

How this fits together

The Gateway retains verified Control UI build assets so already-open browser tabs can request older lazy-loaded modules after an update. Its HTTP server uses these retained files when the current bundled build lacks the requested asset.

flowchart TD
  A[Bundled build manifest] --> B[Select identity assets]
  B --> C[Verify and publish retained build]
  D[Existing retained builds] --> E[Apply generation and disk limits]
  C --> E
  F[Old tab requests missing module] --> G[Gateway asset lookup]
  E --> G
  G --> H[Serve verified asset bytes]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +23, Tests +178, Docs 0. Total +201 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 24 1 +23
Tests 2 179 1 +178
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 204 3 +201

Review metrics

Metric Value Why it matters
Implementation versus regression coverage production net +23 lines; tests net +178 lines Production growth implements the retained-asset selection and capacity warning; tests cover disk-budget compatibility and HTTP encoding.
Reported retained-build capacity 106.23 MB full pair → 70.18 MB identity pair The measured build pair moves below the unchanged 100.66 MB disk budget.

Root-cause cluster

Relationship: canonical
Canonical: #163099
Summary: This PR owns runtime budget eviction; the linked changes address the original retention capability, startup timing, and build-time capacity reporting.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep verified identity assets within the existing disk bound while preserving older cache readers and current-build compression.

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

Yes: current-main pruning cannot retain two reported 53.11 MB full generations within 96 MiB, and the supplied fail-before regression establishes prior-build eviction. This read-only review did not execute the reproduction.

Is this the best way to solve the issue?

Yes: filtering non-addressable sidecars at the existing retention owner restores the compatibility window without increasing the disk bound or introducing another cache owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4ad3766a2169.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This fixes post-update lazy-route failures in existing Control UI tabs with a bounded Gateway asset-cache change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured isolated Gateway observations exercise retention preparation and previously unserved prior-only HTTP assets: an older full-format cache survives the first update, and the next identity-only generation returns matching bytes with HTTP 200 and no Content-Encoding. Existing-state compatibility is supported by that upgrade case and the unchanged manifest reader; later production changes incorporate the already-merged inventory wait.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured isolated Gateway observations exercise retention preparation and previously unserved prior-only HTTP assets: an older full-format cache survives the first update, and the next identity-only generation returns matching bytes with HTTP 200 and no Content-Encoding. Existing-state compatibility is supported by that upgrade case and the unchanged manifest reader; later production changes incorporate the already-merged inventory wait.

Evidence

What I checked:

  • Pinned introduced change: Read the complete introduced diff between the pinned base and exact head. Production changes filter sidecars, recompute the retained manifest hash, and add a capacity warning; verification, publication, and pruning safeguards remain intact. The stale test merge was not used to infer merge effects. (src/gateway/control-ui-asset-retention.ts:177, 367515526831)
  • Still missing on current main: The fetched main revision reads and publishes the complete build manifest within the unchanged 96 MiB budget. It contains the async inventory lookup repair but lacks identity-only retention. (src/gateway/control-ui-asset-retention.ts, 4ad3766a2169)
  • Latest release also retains full manifests: The v2026.9.7 source likewise publishes the full manifest and applies the 96 MiB limit; this requested repair is not present in the supplied latest release. (src/gateway/control-ui-asset-retention.ts:434, c074824a27c9)
  • Existing HTTP fallback and manifest compatibility: Read the retention owner, manifest builder/parser, static-response policy, and root lifecycle. Filtering preserves sorted entries and version 1, recomputes the ordinary manifest hash, and leaves existing full-format readers unchanged. The root reader already tolerates absent sidecars, and encoding selection serves identity when permitted. Direct bundled sidecar URLs remain blocked. (src/gateway/server-control-ui-root.ts:145, 367515526831)
  • Real Gateway and existing-cache proof: The captured PR body reports an isolated Gateway through the supported wrapper, auto-resolved bundled builds, and previously unserved prior-only chunks. First-update preparation retained 88,203,255 B including an older full-format generation, whose Brotli response returned 200 with matching bytes. The next update retained 70,180,470 B of identity-only generations; a prior-only chunk returned 200 without Content-Encoding and with its expected SHA-256. These observations exercise the changed retention owner through final HTTP delivery and verify existing-cache compatibility. (2fb0d8d382c7)
  • Re-review continuity: The earlier completed review had no findings or published rank-up moves. Reading its exact production source through GitHub confirmed that sidecar filtering, generation hashing, and the warning match the reviewed head; later changes incorporate the merged async inventory owner and add HTTP coverage. Local historical blob inspection encountered HTTP 403 and a missing blob, so GitHub contents reads supplied the required source comparison. (src/gateway/control-ui-asset-retention.ts:177, 2fb0d8d382c7)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-01T23:43:09.197Z sha 2fb0d8d :: needs maintainer review before merge. :: none
  • reviewed 2026-10-02T00:06:02.986Z sha 2fb0d8d :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 2, 2026
@steipete
steipete merged commit caff35c into main Oct 2, 2026
123 checks passed
@steipete
steipete deleted the fix/control-ui-retained-identity-assets branch October 2, 2026 08:51
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

RomneyDa pushed a commit that referenced this pull request Oct 2, 2026
* fix(release): backport retained Control UI assets

Backport the merged retained-asset startup and identity-only generation fixes from #163090 and #163099 onto release/2026.9.8. Include the timer-free test helpers required by the older release branch.

Co-authored-by: RomneyDa <[email protected]>

Co-authored-by: vincentkoc <[email protected]>

* test(release): keep compact node plan within cap

Consolidate the retained-asset budget cases under the existing publication test owner so the frozen release branch does not add another compact-plan shard.

Co-authored-by: RomneyDa <[email protected]>

Co-authored-by: vincentkoc <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: roboclaw-bot <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…claw#163099)

* fix(control-ui): old tabs 404 on lazy chunks after every update

Retained Control UI generations let already-open documents from the
previous build load hashed lazy assets after `openclaw update` restarts
the Gateway. A current build manifest lists 53,113,860 bytes per
generation, 18,023,582 of them precompressed .br/.gz sidecars, so the
current generation plus one prior (106.2 MB) no longer fit the 96 MiB
budget and every preparation after an update pruned the previous build.

Retained generations now store an identity-only manifest named by its
own hash. Bundled sidecars are never directly addressable and a missing
retained sidecar is already served as identity bytes, so stale tabs keep
working with uncompressed responses while the current build still uses
its sidecars from the bundled root. Current plus previous now needs
70.2 MB. Existing full-format cache directories remain valid generations
in both upgrade and downgrade directions; every verification property is
unchanged. Pruning now warns when the byte budget drops the newest prior
generation, so a future build that outgrows the budget is visible.

* test(control-ui): await async retained lookups and pin identity-only HTTP serving
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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