Skip to content

refactor: type chat prefetch dependencies and clean loading tests - #138793

Merged
steipete merged 2 commits into
mainfrom
codex/chat-loading-deslop
Sep 5, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/chat-loading-deslop

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

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 main during 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

  • Removing the context cast before repair produces TS2740 for 27 unrelated fields. The inferred fixture and real ChatPage caller now pass the canonical typechecks.
  • All 89 focused UI tests and all 33 configured changed-check steps passed for the nine-file cleanup. Its unchanged avatar implementation passed 19 HTTP tests. Independent Codex review through P2 found no actionable defects.
  • The gallery failure reproduced twice in hosted CI and locally. Captured route/request evidence showed the unresolved dashboard navigation. The repaired browser case passes with a cold reload, preserving lazy preview loading, expanded/split/dashboard-only layouts, and mobile assertions. Its final canonical UI E2E typecheck, type-aware lint, formatting, and independent Codex review through P2 pass.
  • Fresh real-Gateway Chromium proof: the canonical paired Gateway/UI build and all 13 files / 24 tests passed on the final merge candidate 8a6cced8, containing b08185ff. 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.
  • That hosted job did not upload successful screenshots or measurement JSON; no fresh timing or byte measurements are claimed. The attached before/after images are local synthetic gallery proof.
  • Final-head CI passed at 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.

Before: synthetic gallery navigation showed Session not found

After: dashboard opens after cold reload; embedded MCP placeholder remains a separate fixture gap

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete steipete self-assigned this Sep 5, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 10:52 PM ET / September 5, 2026, 02:52 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 9a64b619ee3ca36f0225bf3df38deaaa83adb657

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving refactor with retained regression coverage and supplied real-Gateway validation.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The supplied successful Chromium run exercises the prefetch and avatar owners through a real Gateway, including reload ordering, backscroll and authenticated image reuse; inspected scenario source matches those claims, though hosted logs could not be reopened here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The supplied successful Chromium run exercises the prefetch and avatar owners through a real Gateway, including reload ordering, backscroll and authenticated image reuse; inspected scenario source matches those claims, though hosted logs could not be reopened here.
Evidence reviewed 8 items Verified patch ownership: The recorded test merge has the pinned base and PR head as its two parents; comparison against that base contains the same nine introduced paths, without the unrelated endpoint drift.
Cleanup remains absent from current main: Current main still requires ApplicationContext in the prefetch controller and casts the partial fixture to it. All nine reviewed paths are unchanged between the pinned merge base and fetched main. The merged loading improvement at #138635 is related groundwork, not a replacement for this cleanup.
Dependency boundary and production caller: The new private type describes only fields the controller reads. ChatPage still passes its original context at chat-page.ts:106; the controller retains context identity checks and canonical connection-scope validation before using the shared history request owner. These changes do not depend on a Codex runtime or protocol contract.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +14, Tests -6. Total +8 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 3 23 9 +14
Tests 6 45 51 -6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 68 60 +8

Review metrics

Metric Value Why it matters
Production versus test LOC Production net +14: type-only +17, runtime −3; tests/support net −6 The growth establishes a compiler-checked dependency boundary without adding a runtime adapter or public API.

Technical review

Best 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.

Labels

Label changes:

  • add P3: This is bounded type-safety and test cleanup with no intended user-visible behavior change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied successful Chromium run exercises the prefetch and avatar owners through a real Gateway, including reload ordering, backscroll and authenticated image reuse; inspected scenario source matches those claims, though hosted logs could not be reopened here.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The supplied successful Chromium run exercises the prefetch and avatar owners through a real Gateway, including reload ordering, backscroll and authenticated image reuse; inspected scenario source matches those claims, though hosted logs could not be reopened here.

Label justifications:

  • P3: This is bounded type-safety and test cleanup with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The supplied successful Chromium run exercises the prefetch and avatar owners through a real Gateway, including reload ordering, backscroll and authenticated image reuse; inspected scenario source matches those claims, though hosted logs could not be reopened here.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied successful Chromium run exercises the prefetch and avatar owners through a real Gateway, including reload ordering, backscroll and authenticated image reuse; inspected scenario source matches those claims, though hosted logs could not be reopened here.

Evidence

What I checked:

  • Verified patch ownership: The recorded test merge has the pinned base and PR head as its two parents; comparison against that base contains the same nine introduced paths, without the unrelated endpoint drift. (13befa9dce1c)
  • Cleanup remains absent from current main: Current main still requires ApplicationContext in the prefetch controller and casts the partial fixture to it. All nine reviewed paths are unchanged between the pinned merge base and fetched main. The merged loading improvement at fix: speed up chat opening and cache avatars #138635 is related groundwork, not a replacement for this cleanup. (ui/src/pages/chat/session-prefetch.ts:479, 4311b45631b3)
  • Dependency boundary and production caller: The new private type describes only fields the controller reads. ChatPage still passes its original context at chat-page.ts:106; the controller retains context identity checks and canonical connection-scope validation before using the shared history request owner. These changes do not depend on a Codex runtime or protocol contract. (ui/src/pages/chat/session-prefetch.ts:33, 9a64b619ee3c)
  • Retained behavioral coverage: The existing helper constructs the real browser-client class and delegates requests to the supplied stub. Reviewed tests retain assertions for reconnects, deleted sessions, cache invalidation, foreground priority, navigation intent, and shared avatar ownership; no assertions are removed. (ui/src/test-helpers/gateway-client.ts:14, 9a64b619ee3c)
  • Avatar cache equivalence and security: The private map contains only promises, so nullish lookup preserves the previous truthiness branch. Cache promotion, eviction and rejection cleanup remain unchanged. The HTTP caller authorizes requests before thumbnail access, and existing tests retain authenticated 304 and unauthorized 401 checks. (src/gateway/assistant-avatar-thumbnail.runtime.ts:74, 9a64b619ee3c)
  • Supplied real-Gateway proof: The captured body links https://github.com/openclaw/openclaw/actions/runs/33939152046/job/101233072074 and reports a successful candidate run containing the reviewed head; supplied checks also record the real-Gateway lane as successful. The inspected scenario uses a built Gateway and Chromium, asserting bounded startup, selected-before-Home ordering, 900-message backscroll, shared 128px avatars and authenticated revalidation. The workflow explicitly includes this scenario. (ui/src/e2e/chat-loading-performance.real-gateway.e2e.test.ts:623, 9a64b619ee3c)

Likely related people:

  • Peter Steinberger: Raw commit 7126225 adds src/gateway/assistant-avatar-thumbnail.runtime.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 712622517abb; files: src/gateway/assistant-avatar-thumbnail.runtime.ts)

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 force-pushed the codex/chat-loading-deslop branch from 5bf9e1c to b08185f Compare September 5, 2026 03:07
@steipete
steipete merged commit a44ab9a into main Sep 5, 2026
193 checks passed
@steipete
steipete deleted the codex/chat-loading-deslop branch September 5, 2026 03:21
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…enclaw#138793)

* refactor: type chat prefetch dependencies and clean loading tests

* test: repair dashboard gallery session fixtures
vincentkoc added a commit to LiuwqGit/openclaw that referenced this pull request Sep 5, 2026
* 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
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 gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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