Skip to content

fix(ui): keep model selection ready without repeated catalog waits - #145384

Merged
steipete merged 8 commits into
mainfrom
codex/instant-model-catalog
Sep 12, 2026
Merged

steipete merged 8 commits into
mainfrom
codex/instant-model-catalog

Conversation

@steipete

@steipete steipete commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where returning to New Session or opening a model picker repeatedly waits for the same model catalog. A new draft also showed a loading skeleton even when the agent's default model was already known.

Why This Change Was Made

Cache successful Gateway catalog projections in browser memory, scoped to the connection, agent, session, account, and requested view. Concurrent consumers with the same timeout budget share one read; successful snapshots are reused across budgets. Gateway-owned deadlines stay intact, and an explicit refresh can still publish after an ordinary read or cooldown expiry. Catalog/config changes, session changes, reconnects, and identity changes invalidate the appropriate copies; failed refreshes remain retryable. Server-reported cooldown deadlines also expire cached readiness without requiring a publication event. The cache is bounded and does not persist credentials or change Gateway authorization. Explicit Debug refreshes continue to sample the Gateway directly.

New Session restores warm controls synchronously and shows its known default during a cold catalog read. On the Gateway, authenticated drafts without personal account links reuse the existing prepared projection; account links are still reread each time, and personal projections remain request-local.

User Impact

Reopening model controls no longer adds a catalog round trip. A cold catalog read does not hide a known default or prevent composing a new session. Model/account validation remains with the Gateway.

Evidence

Measured real WebSocket RPCs against an isolated Gateway with trusted-proxy authentication, two agents, two providers, five explicit models, and nine configured model references. The before/after UI catalog owners used the same connection. These are catalog-read timings, not browser paint or provider inference timings.

Measurement Before After
20 warm catalog reads, median 21.47 ms 0.0065 ms
RPCs for those warm reads 20 0
10 simultaneous readers with one timeout budget 10 RPCs 1 RPC

The final 18-scenario probe uses the real Gateway protocol client. It also verifies timeout-budget isolation, warm reuse across budgets, joint model/metadata invalidation, late replies, and explicit-refresh authority. A bounded 1,000 ms request expired while an unbounded request stayed pending with two real Gateway responses held. An active refresh also retained publication authority while 64 other projections completed. Explicit discovery refresh took 22.36 seconds; no cold-discovery improvement is claimed.

An earlier isolated backend comparison reduced authenticated draft metadata median from 29.57 to 9.92 ms. Metadata p95 was higher in its final ten-sample run (32.77 → 50.55 ms), so no tail-latency improvement is claimed. The final merged UI build uses 353,039 bytes gzip for startup JavaScript and passes the existing 355,116-byte enforcement limit. This PR does not raise any budget; metadata lifecycle state remains separate from lazy request/retry code.

All live scenario assertions passed, the final driver exited successfully, and process-group/TCP checks confirmed graceful cleanup. The tested source hashes match the committed merge tree.

Regression checks demonstrate failure on the original code. Focused Gateway account/lifecycle tests, UI cache/cancellation/identity/session tests, and compiled-UI browser flows plus the three-case real-Gateway catalog suite cover recovery, account previews, immediate defaults, and repeated picker opens. The final deadline integration additionally passes 123 focused UI cases and 19 browser scenarios, including real-client deadline recovery. Real Chrome also verifies the live synthetic Gateway's model picker.

Landing validation also exposed timing-dependent test fixtures inherited from main. The test-only corrections distinguish Signal’s absolute deadline from idle timeouts, measure OpenAI’s stalled-response watchdog from the provider request, and control Chrome’s diagnostic classification separately from connection scheduling while preserving real HTTP/WebSocket integration cases. All 119 focused Signal/OpenAI cases and 36 Chrome cases pass. Controlled original failures and missing-deadline/wrong-code checks confirm that regressions remain detectable. Production transport code and timeout limits are unchanged.

Before, while the catalog response is pending:

Model picker waiting for the catalog

After, while the catalog response is still pending:

Known default and usable composer during catalog loading

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 11, 2026
@steipete
steipete marked this pull request as ready for review September 11, 2026 23:12
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 11:43 PM ET / September 12, 2026, 03:43 UTC (Revision 9).

ClawSweeper review

What this changes

Caches model choices across picker openings, shows known defaults during loading, reuses eligible Gateway metadata projections, and stabilizes transport deadline tests.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and the latest release still perform repeated catalog reads. The integrated deadline handling and supplied proof address the prior blockers; no actionable introduced defect was found.

Priority: P2
Reviewed head: 7982301b804d068b46fcf1e207543425f6002c84

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Measured runtime results, inspected visual evidence and focused lifecycle regressions support a coherent implementation with no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured body reports real Gateway RPC results through the changed catalog owner, including warm reuse and integrated deadline recovery; inspected before/after screenshots separately demonstrate the known default and usable composer during loading.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body reports real Gateway RPC results through the changed catalog owner, including warm reuse and integrated deadline recovery; inspected before/after screenshots separately demonstrate the known default and usable composer during loading.
Evidence reviewed 10 items Current main still performs direct reads: At the fetched main revision, every loadModelCatalog call invokes models.list; successful catalog snapshots are not reused by this owner.
Latest release comparison: The same owner in v2026.9.4 directly requests models.list on each call, so that release does not already provide the proposed warm-cache behavior.
Introduced cache and deadline behavior: The verified base-to-head diff scopes cached projections, separates pending requests by timeout budget, preserves explicit-refresh publication, expires cooldown results, and rejects obsolete cache writers.
Findings None None.
Security None None.

How this fits together

The Control UI requests model choices and account readiness from the Gateway for chat and settings controls. Its browser cache reuses those display results, while the Gateway continues to validate model and account selections.

flowchart LR
  A[Chat and settings pickers] --> B[Connection and selection scope]
  B --> C[Browser catalog cache]
  C -->|Warm result| D[Visible model choices]
  C -->|Missing or expired| E[Gateway catalog read]
  E --> C
  F[Account and lifecycle changes] -->|Invalidate| C
  D --> G[Gateway validates submission]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +237, Tests +606, Docs +12. Total +855 across 43 files.

View PR surface stats
Area Files Added Removed Net
Source 12 339 102 +237
Tests 30 817 211 +606
Docs 1 12 0 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 43 1168 313 +855

Review metrics

Metric Value Why it matters
Production versus test growth Production +237 lines; tests and test support +606 lines Production growth implements scoped reuse and lifecycle handling, with measured RPC reduction and regression coverage supporting its cost.

Technical review

Best possible solution:

Keep catalog reuse in the shared display cache, with Gateway-owned freshness, cancellation and model/account validation.

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

Yes, source establishes that repeated catalog reads on current main always issue another RPC; the supplied before/after measurements corroborate the delay. No runtime reproduction was executed in this review.

Is this the best way to solve the issue?

Yes. Extending the existing catalog owner preserves one shared read path, and lifecycle invalidation, cooldown expiry and explicit refresh retain recovery without adding configuration or persisted state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4275c324ce91.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This improves model-picker responsiveness and repeated navigation with a limited UI blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body reports real Gateway RPC results through the changed catalog owner, including warm reuse and integrated deadline recovery; inspected before/after screenshots separately demonstrate the known default and usable composer during loading.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports real Gateway RPC results through the changed catalog owner, including warm reuse and integrated deadline recovery; inspected before/after screenshots separately demonstrate the known default and usable composer during loading.

Evidence

What I checked:

  • Current main still performs direct reads: At the fetched main revision, every loadModelCatalog call invokes models.list; successful catalog snapshots are not reused by this owner. (ui/src/lib/model-catalog-store.ts:53, 4275c324ce91)
  • Latest release comparison: The same owner in v2026.9.4 directly requests models.list on each call, so that release does not already provide the proposed warm-cache behavior. (ui/src/lib/model-catalog-store.ts:27, 3a9d69db306c)
  • Introduced cache and deadline behavior: The verified base-to-head diff scopes cached projections, separates pending requests by timeout budget, preserves explicit-refresh publication, expires cooldown results, and rejects obsolete cache writers. (ui/src/lib/model-catalog-store.ts:105, 7982301b804d)
  • Lifecycle and cancellation coverage: Source and regression cases cover connection, identity, session and account scopes; timeout recovery; shared-reader cancellation; cooldown expiry; and refresh survival under cache pressure. These tests were inspected, not executed during this read-only review. (ui/src/lib/model-catalog-store.test.ts:93, 7982301b804d)
  • Account projection boundary: Authenticated drafts reuse the neutral projection only without personal links or a preferred account; personal projections remain request-local. The account-selection resolver returns automatic selection when no session pin exists, and draft authority checks remain in the Gateway handler. (src/gateway/server-methods/chat-metadata-runtime.ts:290, 7982301b804d)
  • Real behavior evidence and review continuity: The captured PR body reports real Gateway WebSocket measurements: 20 warm reads fall from 20 RPCs to zero, and ten concurrent same-budget readers use one RPC. Its final 18-scenario run covers integrated deadlines, invalidation, late replies and refresh publication. Both downloaded screenshots were inspected: the after image shows the known default and an enabled composer while catalog loading is pending. Screenshots support visible behavior; the reported Gateway observations support runtime behavior. (7982301b804d)

Likely related people:

  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: 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 (8 earlier review cycles)
  • reviewed 2026-09-11T23:25:19.929Z sha 9f301e4 :: blocked before merge. :: [P2] [P2] Expire cached cooldown results before reusing them
  • reviewed 2026-09-11T23:43:18.079Z sha d99e24d :: blocked before merge. :: [P2] [P2] Expire cached cooldown results before reusing them
  • reviewed 2026-09-12T00:19:46.655Z sha 6b0a2c2 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T00:30:22.421Z sha 6b0a2c2 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T00:51:01.082Z sha a4a7e44 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T02:14:12.646Z sha 616117b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T02:49:34.341Z sha 616117b :: blocked before merge. :: none
  • reviewed 2026-09-12T02:56:17.669Z sha 555132b :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/instant-model-catalog branch from 9f301e4 to d99e24d Compare September 11, 2026 23:37
@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. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 12, 2026
@steipete
steipete force-pushed the codex/instant-model-catalog branch from 6b0a2c2 to a4a7e44 Compare September 12, 2026 00:43
Keep publication, retry, reconnect, and account coverage while asserting warm catalog reuse. Use the required non-mutating sort for cache keys.
Preserve request timeout coverage while separating OpenAI setup from the stalled transport watchdog. Verify Signal absolute-deadline errors and connection closure, with repeated-chunk timing covered deterministically. The inherited CI fixture failures reproduce under controlled setup/header delays; deadline-removal checks still fail.
@steipete
steipete force-pushed the codex/instant-model-catalog branch from a4a7e44 to 616117b Compare September 12, 2026 02:03
@openclaw-barnacle openclaw-barnacle Bot added the channel: signal Channel integration: signal label Sep 12, 2026
Control the opened socket state for diagnostic classification while retaining real HTTP and WebSocket integration cases. Preserve the caller budget, discovered URL, command dispatch and cancellation checks; controlled scheduling and missing-timeout/wrong-code probes validate the fixture repair.
Integrate main loading recovery with deadline-scoped pending catalog requests. Share successful snapshots across budgets, preserve explicit-refresh authority through cooldown expiry and cache pressure, and retain Gateway-owned timeout and cancellation semantics. Verified focused UI/browser cases and live Gateway projection, timeout and eviction flows.
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 12, 2026
@steipete
steipete merged commit 3c194de into main Sep 12, 2026
200 of 201 checks passed
@steipete
steipete deleted the codex/instant-model-catalog branch September 12, 2026 04:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
…penclaw#145384)

* fix(ui): keep model selection ready with scoped catalog caching

* test(ui): verify cached model picker refreshes

Keep publication, retry, reconnect, and account coverage while asserting warm catalog reuse. Use the required non-mutating sort for cache keys.

* fix(ui): keep diagnostic refreshes live alongside model caching

* test(ui): reconcile provider publications with catalog caching

* perf(ui): defer metadata requests and expire stale cooldowns

* test: verify provider deadlines independently of fixture timing

Preserve request timeout coverage while separating OpenAI setup from the stalled transport watchdog. Verify Signal absolute-deadline errors and connection closure, with repeated-chunk timing covered deterministically. The inherited CI fixture failures reproduce under controlled setup/header delays; deadline-removal checks still fail.

* test(browser): isolate stale command timeout classification

Control the opened socket state for diagnostic classification while retaining real HTTP and WebSocket integration cases. Preserve the caller budget, discovered URL, command dispatch and cancellation checks; controlled scheduling and missing-timeout/wrong-code probes validate the fixture repair.
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 channel: signal Channel integration: signal docs Improvements or additions to documentation extensions: browser extensions: openai gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL 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