Repository navigation
refactor: type chat prefetch dependencies and clean loading tests - #138793
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: needs maintainer review before merge. Reviewed September 4, 2026, 10:52 PM ET / September 5, 2026, 02:52 UTC. ClawSweeper reviewWhat this changesThe PR narrows chat prefetch dependency types, replaces unsafe test-client casts with the shared helper, and simplifies avatar-cache and test code without intended behavior changes. Merge readiness✅ Ready for maintainer review Keep open: this useful cleanup is absent from current main, and review found no introduced correctness or security defect. Priority: P3 Review scores
Verification
How this fits togetherThe Control UI prefetches recent conversation history after visible chats finish loading. Its session lifecycle checks protect cached transcripts, while a separate authenticated Gateway route supplies shared avatar images. flowchart TD
A[Session list and navigation intent] --> B[Chat prefetch controller]
C[Connection and visible pane state] --> B
B --> D[Bounded history requests]
D --> E[Conversation cache]
F[Authenticated avatar request] --> G[Thumbnail promise cache]
G --> H[Shared browser avatar]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +14, Tests -6. Total +8 across 9 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep prefetch dependencies explicit at the existing controller boundary while retaining the canonical session lifecycle and shared test-client helper. Do we have a high-confidence way to reproduce the issue? Not applicable: this refactor addresses unchecked fixture dependencies rather than a reported runtime failure; current main confirms the broad type and double cast remain. Is this the best way to solve the issue? Yes: narrowing the existing controller contract removes the unsafe fixture cast without fabricating unrelated application fields or introducing a second runtime path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4311b45631b3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
5bf9e1c to
b08185f
Compare
|
Merged via squash.
|
…enclaw#138793) * refactor: type chat prefetch dependencies and clean loading tests * test: repair dashboard gallery session fixtures
* refs/remotes/origin/main: (602 commits) fix(plugins): trace trust refusals and repair legacy provenance (openclaw#138746) perf(sqlite): reuse compiled plugin state point reads (openclaw#138758) refactor: type chat prefetch dependencies and clean loading tests (openclaw#138793) ci: reduce Doctor test startup and core lint jobs (openclaw#138796) feat(update): retain run history and share outcome reports (openclaw#138690) chore(deps): update @openclaw/fs-safe to 0.8.1 (openclaw#138500) fix: preserve global board ownership from pinning to notifications (openclaw#138675) fix(gateway): deliver session catalog updates from slow hosts (openclaw#138674) perf(sessions): index pending conversation replies (openclaw#127182) perf(auth): reuse ordered provider alias entries (openclaw#138805) docs(diagnostics): clarify whole-process CPU metrics (openclaw#138804) perf(memory): narrow source reads and stream embedding cache rows (openclaw#138766) fix: allow older source on newer Testbox checkouts (openclaw#138782) fix(agents): preserve recovered task progress and lifecycle ownership (openclaw#138785) perf(codex): reduce rollout tail scan CPU (openclaw#138784) perf(gateway): stop projecting history deltas at the byte budget (openclaw#138655) fix(build): bound native declaration inputs to checkout (openclaw#138742) fix(cli): preserve foreground Gateway argument handling (openclaw#138765) fix(ui): align task toolbar with side-panel tabs (openclaw#138769) fix(logbook): drain accepted work before closing SQLite (openclaw#138754) ... # Conflicts: # src/agents/embedded-agent-runner/compact.queued.ts
Related: #138635
What Problem This Solves
The loading-performance tests hid a partial application context behind a double cast. Removing that cast required 27 unrelated application fields, so the fixture could not check the prefetch controller's actual dependencies.
CI also exposed a stale dashboard-gallery fixture: its missing resolver response and list-only metadata produced “Session not found.” #138769 landed the missing resolver fix on
mainduring validation. This PR retains that fix and consolidates the fixture data, types, diagnostics, and cold-reload coverage.Why This Change Was Made
Prefetch now accepts only the snapshot fields, roster, session rows, notifications, and connection-scope methods it uses. Its caller keeps the same context object, preserving subscription identity and stale-connection fencing. The inferred fixture is checked directly; 26 partial-client casts use the existing typed helper.
The gallery now seeds one canonical set of session rows and shares a typed resolution between startup and dashboard navigation. Duplicate list/describe stubs are removed. The shared browser fixture captures failures before closing the page, and a cold reload verifies resolution without a warm navigation handoff. All previous gallery assertions remain.
The remaining cleanup simplifies private avatar-promise cache lookup, places the avatar lifetime explanation beside its owner, removes an unused metadata mock branch, and initializes fixture variables at their declaration.
User Impact
No intended production behavior change. The prefetch refactor emits byte-identical JavaScript. Loading priority, cache ownership, avatar caching, and reconnect protections remain covered; the gallery test now exercises the current dashboard flow reliably.
Evidence
8a6cced8, containingb08185ff. The loading case verifies the 80-message/256-KiB startup budget, selected-before-Home ordering, all 900 messages reachable, one 128px authenticated avatar resource, immutable caching with 304 revalidation, and AVIF/percent-encoded PNG decoding.b08185ff: 119 checks passed, 13 intentionally skipped, zero failures, including the corrected gallery and aggregate gate. The local gallery Chromium case also passed again after rebasing onto fix(ui): align task toolbar with side-panel tabs #138769. All ten touched files are byte-identical to the independently reviewed candidate before the rebase.Production: +23/-9, net +14 lines. The private compile-time capability contract adds 17 lines; the avatar cache simplification removes three runtime lines. Tests/support: net -12 lines; most gallery churn is indentation under the shared fixture owner. No new public API, configuration, schema, or runtime adapter.
Follow-up: Complete the gallery's expanded MCP app fixture. The synthetic gallery includes an incomplete embedded-app placeholder to check that gallery previews exclude it; this placeholder remains visible in the expanded screenshot. Fully initialized MCP rendering is covered separately by the passing real-Gateway conformance test and would require a complete sandbox/SDK fixture here.