Skip to content

fix(ui): model pickers stay on the old catalog when a change arrives mid-read - #174812

Merged
RomneyDa merged 1 commit into
mainfrom
fix/model-catalog-invalidated-request-sharing
Oct 16, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/model-catalog-invalidated-request-sharing

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: Control UI model pickers (for example the automation draft model picker) can keep showing the previous model list after a model catalog change, when the change notification arrives while an earlier catalog read is still in flight.

User Impact

User impact: after config set models.providers... (or any other catalog publication), open model pickers update to the new catalog instead of staying on the previous one until something else triggers a reload.

Why This Change Was Made

Readers that started after a catalog invalidation joined a models.list request sent before it, and that request's reply was then cached as current. The store's own comment noted this ("may display the older list until its next refresh"). Now an invalidation retires matching in-flight requests: their original readers still settle, readers that arrive later send a fresh request, and a retired reply is never published to the cache. Retired requests stay tracked until they settle, so connection clears still abort them and settleModelCatalogRequests still waits for them. Two existing tests that expected sharing across an invalidation now expect a second request.

This is the cause of the intermittent checks-ui-e2e-real-gateway (2/2) failure cron-duration-save.real-gateway.e2e.test.ts > Automation catalog publication with a real Gateway, where the fixture/published poll times out with expected +0 to be 1. That failure appeared 9 times between 2026-10-13 and 2026-10-15, including Full Release Validation runs and the 2026.10.10-beta.2 candidate.

Evidence

  • New regression ui/src/lib/model-catalog-store.test.ts › "reads again after an invalidation instead of joining the earlier request" fails on the base commit (one transport request; the reader that arrived after the invalidation gets the reply from before it) and passes with the fix.
  • Real Gateway frame capture (local, models.list replies delayed 1.5s to mimic a loaded runner): config.changed and two chat.metadata.changed{modelCatalogChanged:true} all arrived during one in-flight models.list, and every read after those invalidations joined it (1 request for 4 invalidations).
  • pnpm test ui/src/lib/model-catalog-store.test.ts ui/src/lib/model-catalog-store.lifecycle.test.ts ui/src/lib/chat/chat-metadata-store.test.ts ui/src/lib/chat/chat-metadata-refresh.test.ts ui/src/pages/cron/cron-page.lifecycle.test.ts ui/src/pages/cron/cron-page.test.ts: 131 passed. Wider ui/src/lib ui/src/pages/{cron,model-providers,agents} ui/src/app: only dev-gateway.node.test.ts failed once, and it passes on rerun (unrelated dev proxy).
  • ui/src/e2e/cron-duration-save.real-gateway.e2e.test.ts (whole file, real Gateway) with this commit cherry-picked onto release/2026.10.10: 6/6 passed.
  • pnpm check:changed: typecheck UI/core tests, lint, and format pass. The max-lines ratchet flags 3 untouched files (chat-message.test.tsx, config-page-state.ts, sessions-page-state.ts). The dead-export scan flags only untouched files.
  • Test cost: pnpm test ui/src/lib/model-catalog-store.test.ts --maxWorkers=1 takes 7.9s wall (3.1s vitest). The two updated lifecycle files take 7.7s wall together. No timers or sleeps were added.

@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR starts fresh catalog reads after invalidation while retaining older requests until their transports settle.

Example: An open automation picker receives a catalog change from fixture/retiring to fixture/published during an outstanding models.list read.

  • Before: The replacement reader joins the earlier request and keeps showing fixture/retiring.
  • After: The replacement reader requests the new catalog, and the earlier reply cannot repopulate the shared cache.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch appears correct and useful; runtime validation is reported without inspectable output, and exact-head CI remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor-proof gate; its body reports real-Gateway publication and recovery coverage, while independently inspectable evidence consists of source and regression tests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Open model pickers can retain a previous catalog after receiving a catalog-change notification.
Reason: The maintainer-authored direction addresses a concrete shared-owner failure and explains why recurring Gateway failures warrant revisiting the earlier best-effort tradeoff.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a source-confirmed stale-catalog path still present on main, and no concrete introduced defect was found.

Priority: P2
Reviewed head: 8eb06b61cb217509900853eb6681c85236d427bc

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The reported real-Gateway run lacks an attached trace showing invalidation during an outstanding read followed by the updated picker.
Agent review details

How this fits together

The browser catalog cache shares Gateway models.list requests across scoped consumers and supplies model choices to chat, settings, and automation pickers.

flowchart LR
  A[Gateway catalog change] --> B[Catalog invalidation]
  B --> C[Retire matching requests]
  B --> D[Picker reload]
  D --> E[Fresh models.list request]
  E --> F[Shared catalog cache]
  F --> G[Model picker]
  C --> H[Original readers settle]
Loading

Technical review

Best possible solution:

Keep invalidation and request retirement in the shared catalog owner while preserving original-reader settlement and connection cleanup.

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

Source shows that invalidation leaves an outstanding request joinable and its reply publishable; the new regression exercises that sequence, but this read-only review ran no target code.

Is this the best way to solve the issue?

The change fixes request admission and publication at their shared owner without restoring the removed scheduler or adding consumer-specific workarounds.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 646647245f1a.

Provenance checked

  • Catalog request sharing, invalidation, and transport settlement changes intended behavior with a stated reason (224c0bc: The earlier simplification deliberately removed request chronology machinery and accepted older inventory until refresh; this PR cites recurring Gateway failures and restores only request retirement.)
  • Invalidation notifications and retained transport ownership keeps the original intent (80e086f: Shared metadata notifications and settlement barriers prevent redundant background work and preserve connection-scoped request cleanup.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

  • Introduced patch: The pinned introduction diff retires matching requests before notifying consumers, suppresses their cache publication, and preserves transport settlement and connection cleanup. (ui/src/lib/model-catalog-cache.ts:103, 8eb06b61cb21)
  • Current-main failure path: Current main still joins the pre-invalidation request and unconditionally publishes its result; the affected production files have no changes between the merge base and fetched main. (ui/src/lib/model-catalog-store.ts:194, 646647245f1a)
  • Consumer boundary: The automation page reloads on matching cache invalidations and permits only its latest request to publish suggestions, so fresh request admission addresses the visible picker failure. (ui/src/pages/cron/cron-page-state.ts:405, 8eb06b61cb21)
  • Prior intent and reason for reversal: refactor(ui): simplify display refresh bookkeeping #168656 deliberately accepted stale display results to remove request chronology machinery; this maintainer-authored PR explains its narrower reversal with recurring real-Gateway failures and retains the existing owner. (ui/src/lib/model-catalog-store.ts:216, 224c0bcd8991)
  • Supplied validation: The full body reports a base-failing regression, delayed real-Gateway frame capture, 131 focused passing tests, and six passing real-Gateway browser cases on the release branch; no raw capture or run artifact is attached. (ui/src/lib/model-catalog-store.test.ts:341, 8eb06b61cb21)
  • Review state: GitHub reports the reviewed head mergeable, with exact-head checks still running and no failed check in the inspected inventory; the checkout remains clean. (8eb06b61cb21)

PR surface

Source +34, Tests +21. Total +55 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 49 15 +34
Tests 3 24 3 +21
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 73 18 +55

Labels

Label changes:

  • add P2: Stale model choices affect an existing picker workflow but remain recoverable through another refresh.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Stale model choices affect an existing picker workflow but remain recoverable through another refresh.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 16, 2026, 7:07 PM ET / 23:07 UTC.

@RomneyDa

Copy link
Copy Markdown
Member Author

Real-Gateway frame trace (local run on release/2026.10.10 without this fix, cron-duration-save.real-gateway.e2e.test.ts catalog test, with models.list replies held 1.5s at the test's WebSocket proxy to mimic a loaded runner). After the first config set ... --replace publish:

RES  models.list #13  [anchor, retiring]             (initial picker)
EVT  chat.metadata.changed {modelCatalogChanged: true}
SENT models.list #31
EVT  config.changed                                  <- arrives while #31 is outstanding
EVT  chat.metadata.changed {modelCatalogChanged: false}
EVT  chat.metadata.changed {modelCatalogChanged: true}  <- arrives while #31 is outstanding
EVT  chat.metadata.changed {modelCatalogChanged: true}  <- arrives while #31 is outstanding
RES  models.list #31  [anchor, published]

Four invalidations produced one models.list: every reader after an invalidation joined #31. Here #31 happened to carry the new catalog, so the test passed. In the CI failures (9 between 10-13 and 10-15, e.g. FRV job 117198691875), the fixture/published poll never succeeds, which is consistent with the joined request carrying the catalog from before the change and nothing triggering another read. With this PR applied to the release branch, the full real-Gateway cron e2e file passes 6/6.

@RomneyDa
RomneyDa merged commit 919e835 into main Oct 16, 2026
95 checks passed
@RomneyDa
RomneyDa deleted the fix/model-catalog-invalidated-request-sharing branch October 16, 2026 23:13
steipete added a commit that referenced this pull request Oct 17, 2026
The model catalog owner now retires requests sent before an invalidation
(919e835, #174812). The metadata E2E still expected that old request to
serve later demand, leaving all six ordering/presentation variants red.

Hold the replacement request, return a distinct obsolete catalog from the
retired request, and verify that panes retain the prior accepted display.
Then release the fresh result and require exactly one replacement read for
the invalidation burst. Preserve command counts and all timeouts.

Proof: current main reproduces all six old expectations failing with three
models.list calls instead of two. The native bundled UI E2E file passes all
16 cases with the updated contract (--maxWorkers=1). Targeted chat-E2E
typecheck, source-backed typed lint and formatting pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
The model catalog owner now retires requests sent before an invalidation
(e6ed736, openclaw#174812). The metadata E2E still expected that old request to
serve later demand, leaving all six ordering/presentation variants red.

Hold the replacement request, return a distinct obsolete catalog from the
retired request, and verify that panes retain the prior accepted display.
Then release the fresh result and require exactly one replacement read for
the invalidation burst. Preserve command counts and all timeouts.

Proof: current main reproduces all six old expectations failing with three
models.list calls instead of two. The native bundled UI E2E file passes all
16 cases with the updated contract (--maxWorkers=1). Targeted chat-E2E
typecheck, source-backed typed lint and formatting pass.
RomneyDa added a commit that referenced this pull request Oct 20, 2026
…78169)

* fix: distinguish workflow approval and exception capabilities (#172661)

(cherry picked from commit aade2f8)
Co-authored-by: RomneyDa <[email protected]>

* fix(release): expose Linux builder admission and retain failed bundles (#170297)

* fix(release): expose Linux builder admission and retain failed bundles

* fix(release): preserve unconfirmed Linux dispatch status

* fix(ci): make Linux build event admission explicit

* fix(ci): separate Linux mirror dispatch from release builds

* fix(ci): budget cold Linux source package builds

(cherry picked from commit 614f559)
Co-authored-by: RomneyDa <[email protected]>

* fix(ui): let locale refresh workers bootstrap new locale memory (#172689)

(cherry picked from commit 17bea1c)
Co-authored-by: RomneyDa <[email protected]>

* test(gateway): prewarm history worker before composed SDK request budgets (#172745)

(cherry picked from commit 2051055)
Co-authored-by: RomneyDa <[email protected]>

* fix(android): prepare focused proof before running Gradle (#172668)

* fix(android): prepare focused proof before running Gradle

* test(android): reach proof prerequisites on Linux ARM

* test: remove duplicated Android job structure assertion

* fix: seed stored inference account for Docker cron cleanup

(cherry picked from commit 404b708)
Co-authored-by: RomneyDa <[email protected]>

* fix: preserve bound Codex history after app-server restart (#172705)

(cherry picked from commit 9fe4372)
Co-authored-by: RomneyDa <[email protected]>

* fix(release): Linux channel promotion fails after a withdrawn Windows companion (#173615)

(cherry picked from commit c58afa2)
Co-authored-by: RomneyDa <[email protected]>

* ci(release): temporarily disable Windows companion publication (#173656)

(cherry picked from commit 99ce3ea)
Co-authored-by: RomneyDa <[email protected]>

* fix(qa): Telegram live lane fails scenarios when the stale-update drain hits a transient Bot API error (#173465)

* fix(qa): retry Telegram stale-update drain through transient Bot API failures

* fix(qa): cancel Telegram drain waits on proxy stop and cap attempts by budget

* test(qa): prove the Telegram drain abandons a stalled attempt at its deadline

* test(qa): drop timing-dependent upstream count from Telegram drain deadline test

(cherry picked from commit 387ebd6)
Co-authored-by: RomneyDa <[email protected]>

* fix(release): validate shipped release provenance markers against main (#173781)

(cherry picked from commit eee5b40)
Co-authored-by: RomneyDa <[email protected]>

* fix(sqlite): settle peer closes after shared worker refusal (#173813)

A refused opener stops its shared worker, so queued peer closes receive the
slot's existing operation failure without running. Join native exit without
recording that exact failed-slot error as a second cleanup failure. Distinct
close, termination and lease-cleanup failures still propagate.

Update and Doctor teardown can finish retiring peer agent stores after another
opening is revoked. The rejected opening retains its error, exact lease cleanup
remains owned, and uncertified native exit cannot publish a clean-close seal.

The real-worker regression fails on main with native retirement failed and
passes with all peer leases removed. The original intermittent sessions-tail
case passed six pre-fix replays; the forced owner boundary proves this repair.

Proof: sessions-tail/creation-owner/cleanup 62 passed; broker/client/reply,
close-wedge and retention siblings 54 passed; final integrity owner 27 passed,
one existing Linux-only skip. pnpm test
src/state/openclaw-agent-execution.integrity.test.ts --maxWorkers=1: 76.57s wall,
26.00s Vitest, new regression 2.66s. Scoped types, lint, formatting, line-cap and
independent P2 reviews pass. PR CI supplies broad proof.

(cherry picked from commit 6d51bb2)
Co-authored-by: RomneyDa <[email protected]>

* fix(gateway): restore 2026.10.4 startup memory by keeping cold start from opening every memory index (#174718)

* perf(agents): bound catalog worker young-generation heap

Keep the catalog worker's existing 512 MiB old-generation allowance while
bounding its young generation to 32 MiB. Forward-port of the release/2026.10.4
fix; main moved the catalog pool into prepared-model-catalog-worker.pool.ts, so
the limit now lives on that pool's single resource-limit object.

(cherry picked from commit a3510e8)

* fix(memory): keep cold Gateway start from opening every agent's index

#167756 started Memory Core's index service eagerly on every Gateway start,
opening each configured agent's memory manager right after readiness. On an
idle Gateway that startup catch-up touches every session-transcript read lane,
so each lane spawns its own worker isolate (plus a memory-search worker): the
2026.10.5 Gateway startup peak RSS rose from ~1.1 GB to ~1.8 GB.

Cold start is demand-driven again, as before #167756: the first search, flush,
or turn that needs an agent's index opens it. Once a watched manager has run in
the process (a process-wide fact that survives plugin instance replacement and
resets with a Gateway restart), every later service start reopens all configured
indexes, so plugin reloads, provider-only reloads, rollback recovery, and
memory/agent config restarts still resume watching without a search or turn.

* perf(sqlite): bound broker and transcript worker young-generation heaps

Cap the SQLite broker carriers and session-transcript reader workers at a
32 MiB young generation, matching the catalog worker bound, while keeping the
existing 512 MiB old-generation allowance. Worker counts, lanes, admission,
and lifecycle custody are unchanged.

V8's default nursery grows to ~63 MiB per worker after a startup allocation
burst and stays resident on idle workers. On the 2026.10.5 Gateway (fresh
state, forced 16 CPUs) the broker's heap total at startup peak fell
125 -> 91 MiB and the transcript reader 81 -> 34-66 MiB; with the Memory Core
cold-start fix, max Gateway peak RSS over the runs fell 1152 -> 1117 MB.
Tradeoff: more frequent scavenges during large allocation bursts in these
workers.

(cherry picked from commit 6c050f8)
Co-authored-by: RomneyDa <[email protected]>

* fix(ui): start a fresh model catalog read after invalidation (#174812)

(cherry picked from commit 919e835)
Co-authored-by: RomneyDa <[email protected]>

---------

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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