Skip to content

perf(ui): preserve model caches on unrelated metadata updates - #157254

Merged
steipete merged 7 commits into
mainfrom
steipete/perf-micro-ui-catalog-invalidation-on-chat-metadata-20260919
Sep 24, 2026
Merged

steipete merged 7 commits into
mainfrom
steipete/perf-micro-ui-catalog-invalidation-on-chat-metadata-20260919

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Related: #156784

What Problem This Solves

The Control UI discards cached model choices and authentication status on every chat.metadata.changed, including skill changes and catalog-discovery settlement with unchanged credentials. A deployment sample recorded 5,098 models.authStatus calls/hour across 96 connections; sharing server preparation reduced server work but left redundant client RPCs.

User Impact

Fewer background model/auth requests while retaining credential expiry warnings, account changes, catalog discovery progress, and refreshed commands. No configuration or visual changes. Net production growth: 59 lines.

Why This Change Was Made

The existing metadata owner compares its published config, auth metadata, and catalog facts and sends separate catalog/auth relevance flags. The shell always invalidates command metadata; model consumers and sidebar attention use the corresponding relevance decision. The command palette independently refreshes its combined skill/search results on metadata events while reusing current model choices.

Publication Catalog Auth status
Skills only Retain Retain
Catalog status settlement Refresh Retain
Auth/config/catalog-generation changes, owner replacement, failure/recovery Refresh Refresh

Model-selection policy changes still clear choices. Personal-account/profile updates retain their intentional broad empty-payload notification. Reconnect/identity changes, explicit refreshes, matching models.snapshot publications, catalog cooldowns, and credential expiry deadlines keep their existing lifecycle. External owner replacement stays conservative because auth materializations can change without replacing the snapshot object. Session-scoped event delivery accepts only the bounded boolean flags.

Source audit corrected the initial attribution: title/label/activity and session-model changes use sessions.changed, not chat.metadata.changed. Fact capture moved into the existing metadata-facts owner to keep the runtime under its line cap.

Evidence

Final head 7ac959bb993e1404728519489ede8599a89a081c: both required openclaw/ci-gate checks are SUCCESS. CI run 36021240023 passed in 1,216 s wall, and ClawSweeper marked this exact head ready with no actionable findings. The requested squash auto-merge command was refused locally (string rewrite protection blocked unsafe input), so auto-merge remains disabled and the PR is open.

Before/after: 50 metadata-only publications through the real shell event handler caused 50 → 0 auth RPCs, 50 → 0 catalog RPCs, and 50 → 0 catalog notifications. Command metadata still invalidates. Config/auth changes each trigger exactly one shared reload; catalog-status settlement triggers one catalog reload and zero auth reloads. The regression failed on the original implementation for the expected redundant-request counts.

All heavy validation used Blacksmith Testbox, profile openclaw-check:

  • Baseline and initial eight-file proof: tbx_01m39g2jeq2ynfmg2jc0q58dqk (runner). node scripts/run-vitest.mjs ui/src/app/app-host.chat-metadata.test.ts --maxWorkers=1 -t 'retains model and auth reads across 50' failed as expected (3.99 s). The eight-file owner/cache/expiry proof then passed (53.10 s including cold compilation; UI shard 61 tests in 3.56 s).
  • Final candidate: tbx_01m39hbwxjpe4kwa37jy8hnr2s (runner). node scripts/check-changed.mjs --base fe846d3c9498b855ae0d8bd3c95c318b12a04047 passed all prerequisite guards, core/UI typechecks, all 25 test type graphs, and dead-export scans before reporting one boolean-style lint error. After the equivalent simplification, its exact planned lint/style/schema/database/media/sidecar/import-cycle/webhook/auth tail passed. No checks were disabled; passing proof was reused. Runtime import cycles: 0.
  • Final timed tests: pnpm test <file> --maxWorkers=1 --reporter=dot, 148 tests passed across seven files. The final lint/guard/test command exited 0 in 305.82 s.
  • Fresh independent Codex reviews: no actionable P0–P2 findings. git diff --check and changed-file formatting passed.
  • The review-discovered palette regression was reproduced on the previous PR head and repaired on Testbox tbx_01m39ngsyyzcebpz2cdsz5v7b8 (runner). pnpm test ui/src/components/command-palette.metadata.test.ts --maxWorkers=1 --reporter=dot failed with the renamed skill absent before the fix, then passed in 3.03 s wall. The mounted palette updates the skill name without another models.list call. The existing palette and shell suites also passed (90 tests, 5.36 s runner wall).
  • Palette follow-up: node scripts/check-changed.mjs --base 8e954098b282a72f09d74f9a1e160b9519f90b1d passed in full on that lease, including six affected test type graphs, UI typechecking, dead-export scans, formatting and lint. Combined regression/sibling-test/changed-check command exited 0 in 675.65 s. Fresh independent review was clean.
  • Main reconciliation: Testbox tbx_01m39sp63vbq4zn8nndwwjb6xa (runner) passed 221 tests in 12 model/auth/palette/expiry/broadcast/integration files (61.88 s runner wall), followed by the complete targeted UI/docs changed checks. Combined command exited 0 in 866.26 s. This exercises main's independently loaded palette models together with retained-cache metadata events.
Focused file Tests Command wall
src/gateway/server-broadcast-model-metadata.test.ts 2 2.92 s
src/gateway/server-chat-metadata-lifecycle.catalog-renewal.test.ts 7 31.15 s
src/gateway/server-chat-metadata-lifecycle.test.ts 37 11.94 s
src/gateway/server-methods/chat-metadata-runtime.refresh.test.ts 14 16.21 s
src/gateway/server-methods/chat-metadata-runtime.test.ts 41 10.85 s
ui/src/app/app-host.chat-metadata.test.ts 43 5.19 s
src/agents/prepared-model-catalog-worker.chat-metadata.integration.test.ts 4 19.54 s

The renewal command includes 17.94 s of cold worker compilation; its actual test execution was about 2.6 s. The existing integration test protects actual published-owner composition. No real timers, new serial configuration, or test-only production seams were added.

Validation recovery: fresh leases needed remote dependency installation. The first lease was retired after two checksum-sync timeouts; replacement tbx_01m39h0tayas8zb1pknwqz176y caught a moving-main comparison that included unrelated plugin changes. Pinning the lane base and pushed candidate resolved that. Validation also caught and fixed the runtime line cap, a moved-error test import, the test event's optional payload type, and the boolean-style lint error. All leases were stopped. No local heavy validation or live deployment was performed.

Expected steady-state contribution from skills-only and catalog-status-only publications: 0 auth RPCs/minute. If those account for the observed ~85/minute, that component is eliminated; aggregate production reduction requires a post-deployment event-mix measurement. Genuine changes, explicit refreshes, connections, and expiry deadlines still generate reads.

CI exposed a separate fixture race introduced on main by #157229. Its validation case advanced fake timers before startup's real fs.realpath catalog registration finished, then asserted stdin was already destroyed. Main fixed this in 619405d49ddd by waiting for the mocked Writable's close event. That canonical fix is incorporated; no Codex fixture or runtime changes remain in this PR.

During diagnosis on Testbox tbx_01m39v251ax4hs3bnmt3m7t3dv (runner), the reproduction tree exactly matched CI merge tree 7990c6cb188576d0604740233584ef2d15ec72d0. The original 23-file/two-worker shard reproduced the same assertion failure. An independently prepared stream-close barrier passed the six cleanup cases, 20 standalone runs of the 132-test owning file (13.93–18.33 s wall each), and three original 830-test shard runs (99.34, 108.45, 132.33 s wall). The initial CI shard took 193.54 s and failed two validation cases. Main landed its equivalent repair while this proof was running, so the duplicate repair was removed in favor of the canonical file.

The independently prepared helper repair also passed its full changed-file gate on that lease (516.89 s including fetching the pinned base object), covering extension test typechecking, plugin boundaries, export scans, and lint. The repair preserved timeouts, assertions, and test counts.

The earlier CI typecheck job reached its 20-minute limit after passing the core graphs. Incorporated main commit 9e007615ece5 restores hosted core typecheck stripes; the next CI run passed all five stripes. A missed merge-ref startup was recovered by reopening this same PR after verifying the head was mergeable and had no CI attachment.

CI also exposed a five-second timeout in the existing raw-WebSocket Control UI build-admission fixture: the first case timed out while the second completed in 817 ms. The fixture now prepares a real pending pairing request and reads it back before connecting, explicitly checks the device is still unpaired, and retains real signature authentication and automatic approval. Both five-second phase bounds remain; the close deadline starts only after the test sends the post-rejection frame that permits closure. All no-registration, no-presence and no-RPC assertions remain intact.

The original 13-file/eight-worker shard passed unchanged on Testbox, so cold-start timing is not claimed consistently reproduced there. The fixture correction passed 20 standalone runs (two tests each, 11.16–23.78 s wall) and three original-shard runs (168 passed, the same one pre-existing skip; 135.28, 164.09, 148.12 s wall) on tbx_01m39yvv83rgffs6h0zhkdhjx1 (runner). Fresh independent review was clean.

The fixture's full targeted changed-file gate passed too, including its Gateway test type graph, export scans and lint. The combined stability/check command exited 0 in 1,098.62 s. The production cache change remains +59 lines; this CI repair changes only fixture preparation and close-deadline ordering.

@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@steipete
steipete marked this pull request as ready for review September 24, 2026 11:54
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 11:43 AM ET / 15:43 UTC (Revision 6).

ClawSweeper review

What this changes

The PR adds Gateway metadata relevance flags so the Control UI retains model and authentication caches on unrelated updates, while refreshing affected views and stabilizing a WebSocket admission test.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still invalidates both browser caches on every metadata event, and the merged server-side preparation change does not remove those client RPCs. The earlier palette-skill finding is addressed; this review found no definite introduced defect.

Priority: P2
Reviewed head: 7ac959bb993e1404728519489ede8599a89a081c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and has useful owner-boundary regression coverage; the measured production reduction remains a post-deployment question.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The supplied item metadata lists a MEMBER author, so the external-contributor real-setup gate does not apply. Testbox evidence exercises the changed shell event handler with mocked RPCs and reports zero model/auth reads after 50 metadata-only events; no live deployment is claimed. No persisted-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied item metadata lists a MEMBER author, so the external-contributor real-setup gate does not apply. Testbox evidence exercises the changed shell event handler with mocked RPCs and reports zero model/auth reads after 50 metadata-only events; no live deployment is claimed. No persisted-data contract changes.
Evidence reviewed 8 items Current main behavior: The fetched main revision still treats every chat.metadata.changed event as a catalog refresh; its shell also invalidates auth requests whenever catalog invalidation is returned.
Gateway relevance owner: The proposed runtime compares last-published catalog and auth facts separately and makes an unchanged catalog-status settlement refresh catalog data without forcing auth invalidation.
Browser cache boundary: The shell invalidates authentication reads only when the auth event requires it, while every metadata event still invalidates command metadata.
Findings None None.
Security None None.

How this fits together

The Gateway publishes changes to model, authentication, and skill metadata. The Control UI uses those events to refresh cached model choices, credential status, commands, and search results.

flowchart LR
 A[Config, auth, skills, catalog] --> B[Gateway metadata facts]
 B --> C[Change relevance flags]
 C --> D[Control UI event handler]
 D --> E[Model and auth caches]
 D --> F[Command and skill search]
 E --> G[Pickers and sidebar]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +59, Tests +205, Docs +1. Total +265 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 11 171 112 +59
Tests 11 230 25 +205
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 402 137 +265

Review metrics

Metric Value Why it matters
Metadata-only request fan-out 50 events → 0 auth RPCs and 0 catalog RPCs in the shell harness This bounds the demonstrated client-side performance gain; production event mix has not been measured after deployment.
Code growth production +59 lines, tests +205 lines The production growth supports distinct relevance decisions, and the tests cover the affected event consumers.

Root-cause cluster

Relationship: canonical
Canonical: #157254
Summary: The merged server-side preparation PR reduces repeated Gateway work, while this PR addresses the remaining client RPC fan-out; the Codex fixture repair is adjacent CI history.

Members:

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

Technical review

Best possible solution:

Keep Gateway metadata facts as the relevance owner and let each Control UI cache follow its own invalidation lifecycle; measure the post-deployment RPC rate to confirm the expected reduction.

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

Yes. Current-main source shows broad invalidation on every metadata event, and the PR reports a failing pre-fix 50-event shell regression; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. The Gateway derives relevance from its published facts, while browser consumers retain a conservative refresh path for events without the new flags.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5c13ecfcbf19.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The reported redundant background requests affect connected Control UI clients, but the PR is a bounded performance improvement rather than an urgent broken workflow.
  • 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. Not applicable: The supplied item metadata lists a MEMBER author, so the external-contributor real-setup gate does not apply. Testbox evidence exercises the changed shell event handler with mocked RPCs and reports zero model/auth reads after 50 metadata-only events; no live deployment is claimed. No persisted-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: 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 (5 earlier review cycles)
  • reviewed 2026-09-24T12:03:52.586Z sha 8e95409 :: needs changes before merge. :: [P2] Refresh palette skills when model caches are retained
  • reviewed 2026-09-24T12:39:19.885Z sha 33f7724 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-24T13:36:09.286Z sha 81bac27 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-24T14:31:36.680Z sha 6a83e58 :: blocked before merge. :: none
  • reviewed 2026-09-24T14:41:17.684Z sha f15019e :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: M labels Sep 24, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 24, 2026
@steipete steipete closed this Sep 24, 2026
@steipete steipete reopened this Sep 24, 2026
@steipete
steipete merged commit ff9dce2 into main Sep 24, 2026
234 of 236 checks passed
@steipete
steipete deleted the steipete/perf-micro-ui-catalog-invalidation-on-chat-metadata-20260919 branch September 24, 2026 16:03
vincentkoc added a commit that referenced this pull request Sep 24, 2026
* commit '9a1a6f7db9783d0b8abaf918bfe12978ea745b57': (26 commits)
  fix(maintainer): restore cold PR worktree provisioning (#157394)
  feat(ios): establish native Cloudflare Access sign-in sessions (#146996)
  fix: restore the Gateway after interrupted Doctor maintenance (#156854)
  refactor(line): retire the Express webhook adapter (#157369)
  refactor(cron): consolidate unavailable delivery targets (#157393)
  ci: apply Go memory defaults to architecture checks
  fix(cli): preserve the first PowerShell completion test failure (#157267)
  refactor(agents): consolidate transcript-tail model selection (#157382)
  fix(release): honor frozen validation contracts (#157034)
  fix(perf): use settled Kova terminal CPU accounting (#157029)
  chore(windows): verify packaged repair worker lifecycle (#157047)
  refactor(logging): share memory pressure threshold selection (#157164)
  fix(release): verify bundled fs-safe native bindings (#157027)
  perf(skills): skip warm prompt search when minimum cannot fit (#157343)
  fix(ui): avoid retaining detached tooltip anchors (#157226)
  perf(ci): reuse compiler state and shorten guard and UI tests (#157265)
  perf(ui): preserve model caches on unrelated metadata updates (#157254)
  chore: remove the tracked PR-body artifact and ignore .artifacts (#157296)
  refactor: consolidate duplicate MCP lifecycle tests (#157360)
  test(qa): consolidate CLI runtime fixtures (#118496)
  ...
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…aw#157254)

* perf(ui): preserve model caches on unrelated metadata updates

* perf(ui): complete metadata invalidation validation fixes

* perf(ui): refresh palette skills independently of model caches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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