Repository navigation
fix: speed up chat opening and cache avatars - #138635
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 8:54 PM ET / September 5, 2026, 00:54 UTC. ClawSweeper reviewWhat this changesThe PR opens the selected chat with a smaller history page, delays competing background work, and shares authenticated, cached avatar previews across the Control UI. Merge readiness⛔ Blocked before merge - 4 items remain Both previous avatar findings are addressed, and the central performance improvements remain absent from the inspected main and release snapshots. No additional blocking code defect was established; direct inspection of several pinned dependency contracts remains a reviewer-side limitation. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI requests conversation history and agent identity from the Gateway, then renders chat panes and sidebar images. This change coordinates those requests so the selected conversation loads first while history pagination and avatar authentication remain intact. flowchart TD
A[Selected chat or short link] --> B[Gateway startup request]
B --> C[Authorized recent history]
C --> D[Visible selected conversation]
D --> E[Restored Home and background loading]
F[Agent identity and avatar source] --> G[Shared authenticated image cache]
G --> D
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep history loading and avatar delivery in their existing shared owners, preserving pagination, stored preferences, and non-browser contracts; thumbnail representation and explicit route/image lifetimes justify the remaining production growth. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the large initial history request and separate avatar work on current main, and the captured synthetic 900-message run supplies a concrete before/after scenario. This review did not rerun the application. Is this the best way to solve the issue? Yes at the OpenClaw owner boundary: the patch consolidates existing history, discovery, identity, and authenticated-image paths instead of adding a competing configuration or cache system. Direct pinned-dependency confirmation remains incomplete. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 726b15fa7b8b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
|
@clawsweeper re-review The new head fixes the architecture check’s type-only router cycle, routes every local avatar image through the shared authenticated cache, and fences forwarded-avatar batches across invalidation so an old image cannot overwrite its replacement. The last item has a failing-before/passing-after late-response and image-ownership regression. The complete staged patch passed independent Codex review through P2, the final built-Gateway Chromium performance run passed, all five previously failing widget/cron real-Gateway cases passed unchanged locally, and a targeted probe with the newer main dashboard lifecycle also connected. Local type/lint/architecture/workflow checks and the committed plugin-asset check are green. Exact-head hosted CI is the remaining gate. The avatar caches are transient process/browser state; there is no persistent data-model or schema change. The history budget is an optional additive RPC field, with existing server defaults, complete CLI imports, and older-history paging preserved. The PR body retains synthetic browser evidence and reports timing variability rather than a production latency percentile. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
25cef8f to
330c18d
Compare
330c18d to
9b3eaac
Compare
|
Merged via squash.
|
* fix: speed up chat opening and cache avatars * fix: close avatar refresh races and update startup fixtures * fix: preserve public avatar images through reconnects * fix: preserve encoded avatar formats * test: respect redacted avatar metadata in live proof
What Problem This Solves
Fixes an issue where opening a long chat with a restored Home pane downloads large transcript snapshots for both panes and unopened sessions, repeatedly transfers full-resolution agent avatars, and waits for a separate short-link lookup before loading the selected conversation.
Why This Change Was Made
Startup now prioritizes the selected conversation: short links resolve and load through one observed
chat.startuprequest, the initial tail is bounded to 80 entries/256KiB, Home mounts after the selected transcript commits, and background warming fetches at most two sequential 20-entry/64KiB tails per cycle. Settled transcript rows also stop rerendering for unrelated session metadata changes.Browser identity metadata carries a versioned avatar URL. The authenticated route generates and caches an alpha-preserving 128px PNG for static PNG, JPEG, and WebP avatars, serves private immutable responses with ETag validation, and preserves animated images, SVG charset information, and other accepted image-data-URL bytes. One connection-scoped identity cache and shared image ownership replace duplicate per-pane metadata and image caches; native, CLI, and copilot inline-avatar contracts remain intact. Explicit identity invalidation and a shared 60-second freshness bound pick up avatar file replacement. Forwarded-avatar batches use unique request tokens so a late old image body cannot overwrite the replacement after invalidation; the regression also verifies release of the stale image while the displayed image stays retained.
User Impact
Chats become usable with less data and less competing startup work. Avatars are reused across the sidebar, welcome screen, chat panes, and browser reloads. Every Gateway avatar image uses the shared authenticated loader before assigning its DOM source, avoiding an extra unsigned image request while the cached image is pending. Scrolling still retrieves older messages, complete CLI imports retain their full snapshot contract, and reconnects, access filtering, ambiguous/missing links, and explicit Home opening keep their existing behavior.
Evidence
Real Chromium against an isolated, built Gateway, with the same fully synthetic 900-message conversation and 1,516,415-byte avatar before and after. The same warm-browser-cache repeat-navigation samples measure authoritative transcript completion separately from first-visible cached content; these are not production latency percentiles.
The final live run retained these byte counts, recovered all 900 messages and reused the cached thumbnail. Selected content was visible at 371 ms, the composer at 401 ms, and authoritative content at 498 ms, with LCP 424 ms and wide-viewport CLS 0.00594. Authoritative completion varied from 498–1,487 ms across candidate runs versus 1,201 ms in the baseline sample; the slowest run shared a heavily loaded host. These measurements include test polling and do not establish an end-to-end latency percentile. The payload reductions and foreground-before-Home ordering are deterministic.
The live test passes in wide and narrow layouts, with Home open and closed, and retrieves all 900 messages through backscroll. It asserts one identity request, one avatar resource, fused short-link startup, Home starting after the selected response, immutable cache headers, and authenticated conditional responses. Affected browser E2Es also pass, including the stronger one-authenticated-avatar-request assertion and the merged 12-card gallery/live-preview scenario. The previously failing real-Gateway widget and four cron cases pass unchanged locally through CLI dashboard bootstrap and browser/CLI readback; the complete hosted real-Gateway lane also passed on the integrated 9b3eaac head. The original timeout cause was not established.
Regression tests demonstrate the original failures for avatar representation/caching, duplicate identity/image work, history budgets, Home scheduling, fused startup, navigation-intent prefetch, and settled-row rendering. A separate regression proves that a message appended during startup arrives before the startup response. Validation includes broad UI and Gateway suites, focused final rechecks, 1,103 macOS tooling tests, generated protocol checks, types, formatting, lint, dependency/boundary/dead-export guards, and an independent Codex review with no accepted/actionable P0–P2 findings.
Production LOC: +1,218/−642 (net +576); tests/support +2,874/−837 (net +2,037); generated/baseline net +8; docs net +3. Growth adds the thumbnail representation, fused startup with route/connection lifecycle ownership, and shared pending/retained image ownership. Duplicate per-pane avatar HTTP/metadata/cache paths and the separate assistant identity cache are removed. No new dependency, configuration option, storage schema, or protocol-version change. Avatar representations and identity records are transient process/browser caches, not persisted data models. The history byte budget is an optional additive RPC field; existing callers retain their current server default, complete CLI imports keep their full-snapshot contract, and older-history paging is unchanged.
Validation repairs remove a type-only router cycle using the upstream leaf type, update startup/client fixtures, register the performance case in the real-Gateway CI command and independent inventories, and refresh the generated plugin asset manifest. The stronger sidebar assertion prevents an extra unsigned avatar request. The shared directive classifies original sources so canonical Gateway images use authenticated loading/reacquisition while static/data images remain intact through reconnect. Regressions preserve retired Gateway isolation and forwarded initials while pending or after HTTP 404; the obsolete unresolved-image-map fixture is replaced with actual producer-to-render coverage. A nearby picker test now unregisters its own toggle listener before jsdom teardown.
Final follow-up proof: 357 consumer/sibling tests, 4 picker tests, configured typed lint, UI production/test type graphs, 5 sidebar browser cases and the first-run onboarding case all pass. Canonical
build:ci-artifactsproduced matching Gateway/UI/service-worker identities, and the real-Gateway performance rerun passed. A prior local attempt with mixed build identities was correctly rejected before measurement; no authentication or build-match gate was changed. Final exact-head CI passed on020880738d7: 134 passed, five skipped, and zero failures across 139 jobs, including the real-Gateway performance lane, Windows, iOS, and Apple Watch tests.The avatar format follow-up preserves the existing bounded
image/*data-URL contract through both producer and browser loader, including AVIF, ICO, BMP, and TIFF. The Gateway uses Node’s standards-based in-memory data-URL decoder after validating the boundeddata:image/source; percent-encoded binary and escaped Base64 decode as bytes, original charset parameters survive unchanged representations, and the decoded 2 MiB cap remains. The separate generic resource-image allowlist is unchanged. AVIF/ICO rejection, percent-encoded animation errors, escaped-Base64 corruption, BMP rejection, and SVG charset loss were reproduced before repair. All 80 focused owner/sibling tests and Gateway typed lint pass; fresh full-candidate independent review is scoped-clean through P2. The existing real-Gateway scenario now includes post-measurement AVIF and percent-encoded PNG rendering checks, and the final extended run passes. AVIF decodes to the expected red 1×1 image and percent-encoded PNG to the expected green 2×2 image through authenticated HTTP and shared blob rendering. All seven screenshots were inspected and contain synthetic data only. The final test correction respects intentionally redacted avatar metadata by waiting for a new versioned URL before checking HTTP MIME and decoded dimensions; production remains byte-identical to the pairedd115a5eGateway/UI build. UI test types, configured lint, and independent review of this test-only correction pass.The final ClawSweeper review on 0208807 confirms both earlier findings are addressed and establishes no additional code defect. Its remaining pinned-dependency review gap was completed locally: Rastermill 0.3.2
dist/index.js:993–1063,1208–1237,2122–2152clamps aspect-preserving resize without enlargement and writes RGBA PNG pixels; file-type 22.0.2source/detectors/png.js:20–88detects acTL before IDAT; Lit HTML 3.3.3development/async-directive.js:194–202sets connection state before lifecycle callbacks anddevelopment/directives/until.js:25–101suppresses retired promises and pauses/resumes deferred results; @openclaw/uirouter 0.1.1dist/index.js:160–198,341–344,449–454,532–607,665–711preserves the exact loader controller on pending/active matches, emits match changes, and clears the finished run independently of that match. These contracts match the implemented image leases and completed-route ownership checks. Config and data-model heuristics require no migration: the caches are transient, no persisted representation/schema or operator configuration changes, and existing RPC defaults, complete imports, and older-history paging remain covered.An introducing commit for the original loading costs has not been established; the costs were measured directly in the running application and reproduced on the task baseline. Separate follow-ups from the initial trace: code-highlighting/new-session chunk loading, missing workspace icons, and slow native catalog requests.