Repository navigation
perf(control-ui): reuse versioned assets and uploaded avatars - #167993
Conversation
Serve exact uploaded-avatar content revisions with private immutable caching and credential-aware Vary. Reuse build-inventory public assets from the service-worker cache before fetching, removing the redundant network-first fallback.
|
🦞👀 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. What this changesThe Control UI reuses retained build assets and privately caches uploaded avatars whose URLs match their content revisions. Review scores
ProductKind: Performance · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR remains a useful, focused optimization absent from current main. No actionable correctness defect was identified. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway serves the Control UI's static files and authenticated profile images. The browser's service worker retains public build assets, while its HTTP cache follows the avatar response policy. flowchart TD
B[Browser requests] --> W[Asset service worker]
W --> C[Retained build cache]
C -->|Cache miss| S[Gateway static files]
B --> A[Profile avatar route]
A --> H[Current authentication check]
H --> R[Uploaded content revision match]
R --> P[Private browser cache]
Technical reviewBest possible solution: Keep cache reuse in the existing HTTP and service-worker owners, with content revisions providing invalidation. Do we have a high-confidence way to reproduce the issue? Not applicable as a correctness bug; current-main source confirms the redundant cache paths, and the recorded Chromium comparison demonstrates additional requests after HTTP-cache eviction. Is this the best way to solve the issue? Yes. The patch reuses existing content revisions and build inventories, removes the redundant network-first branch, and adds no competing cache owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 87d3db2aea6a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -11, Tests +60, Docs +6. Total +55 across 5 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 9, 2026, 6:28 PM ET / 22:28 UTC. |
…aw#167993) Serve exact uploaded-avatar content revisions with private immutable caching and credential-aware Vary. Reuse build-inventory public assets from the service-worker cache before fetching, removing the redundant network-first fallback.
What Problem This Solves
A returning Control UI operator can revalidate an unchanged uploaded profile avatar, and redownload already retained build assets after the browser's separate HTTP cache is evicted.
The cold-load campaign's EVIDENCE.md recorded a signed-in reload of a dashboard deep link with 14 visible states over roughly 15 seconds, dashboard content at 11.75 seconds, and repeated avatar/asset requests costing about 1.0–1.4 seconds each. This PR addresses the cache paths below; it does not claim to fix that complete waterfall.
User Impact
Uploaded profile avatars whose URL matches the exact uploaded content revision can stay in the private browser cache. Build-versioned fonts, themes, and the web manifest reuse the service-worker copy before making a fetch. Unversioned or mismatched avatar revisions, host photos, and external avatar fallbacks continue to revalidate.
No visual layout, configuration, durable schema, or authentication changes. Credential changes remain distinct through
Vary: Origin, Authorization, Cookie. Errors are not added to the service-worker cache.Why This Change Was Made
The avatar HTTP owner already has the uploaded content revision but always returned
private, max-age=0, must-revalidate. Only an exact URL/revision match now receivesprivate, max-age=31536000, immutable, on both 200 and 304 responses.The worker already validates public asset URLs against the current/retained build inventories and retains at most three build caches. Those URLs now share the hashed-asset cache-first path. This removes the redundant network-first/fallback branch; asset versions remain the invalidation key and activation still prunes old builds.
Production delta: 16 additions, 27 deletions, net −11 lines, across
user-profiles-http.tsandui/public/sw.js(excluding tests and docs).Remaining campaign work: native plugin bundles are explicitly authorized by per-plugin, expiring cookie grants and current policy. They are not public assets. Putting them into the public URL-only service-worker cache would change that security contract; simply varying a private cache by the renewed cookie would still miss after renewal. This PR leaves that decision to the campaign lead. Workspace icon URLs are unversioned, and the session projection does not advertise icon absence. The server's 32-root LRU already avoids repeated scans, but the HTTP 404 remains. A complete follow-up needs authoritative icon presence/revision, or a separately scoped disposable miss cache with root/placement and lifetime invalidation; guessing from workspace existence is incorrect.
Evidence
Synthetic headless Chromium, actual Gateway
handleControlUiHttpRequeststatic route, actual baseline/current workers, and normal build-inventory substitution:The byte figure includes 38,552 body bytes and 3,558 response-header bytes. Local timing is noise-scale; the meaningful proof is removal of requests and bytes. This is an asset-route boundary measurement, not a full authenticated Gateway/dashboard benchmark, and uses no injected latency or private capture.
tbx_01m4h9a2r89fxgqakytz3nhcpv: 358 tests passed across user-profile HTTP, agent-avatar HTTP, Control UI conditional HTTP, worker cache, and worker lifecycle tests. Initial missing dependency installation was repaired with the frozen install before validation.pnpm test <file> --maxWorkers=1wall time:src/gateway/user-profiles-http.test.ts22.29 s (27 tests),ui/src/app/service-worker-cache.test.ts1.89 s (36 tests).tbx_01m4ha5vdhtk0k94kn49qrn0kj: core, all 27 core-test graphs, and UI typechecks passed. The changed-file gate then stopped on an inherited deprecated-API violation:src/gateway/server-methods/agents.ts:2(direct config writes). Reproduced the identical guard failure in a separate checkout of main commita0ca02fc31df0aa03f63a4a3618b22a7af722641on the same lease. Subsequent checks in that command were not run; this is not a green full-gate claim.CI on
0ef8425bf4d32f2c0c34281bf4603a8aaf08a705completed successfully: 58 checks passed, 49 skipped, no failures, includingopenclaw/ci-gate. CI run. Shared-job wall time: changed Node tests 255 s; UI test shards 275 / 289 / 320 s; UI E2E shards 193 / 222 s. These are whole-job timings, not individual test-file execution times. No CI reruns or unrelated changes were made. Both Testbox leases and the synthetic browser/HTTP servers have been stopped. No merge requested; campaign lead owns landing.