Repository navigation
fix(native-chat): a new structured chat's model list comes from the machine that runs it - #25143
Conversation
…ost that runs it agentSession.modelCatalog builds the structured-session host like agentSession.options, so a host with no saved chats since it started answers instead of refusing. When the host answers unknown because its first listing runs in the background, the picker re-reads on a bounded schedule until that listing lands. Local terminal-backed chat skips the structured catalog when a custom launch command is configured.
…e-reading on a timer A new structured chat's picker read the host catalog once; on an account the host had never listed, the answer was "unknown" while a background listing ran, and the client re-read on a 1-30 s schedule. Replace the schedule with the host's own completion signal: - The host answers a cold read with `listingInProgress: true` (new optional field) once it has started or joined that listing. A read that passes the new optional `waitForListing` param awaits the same joined listing and answers with it, or a plain "unknown" if it failed. The at-rest options read never waits. A host that predates the field never sends it, so the client never sends the param to a host that would refuse it. - The picker reads once per open and attach; after the host's report it sends one waiting read, with a 90 s client timeout above the slowest listing. While that read is out, the model pill keeps its label but cannot open or be set (typed /model included). An answer, failure, timeout, hide, attach or the provider's own list releases it. - `agentSession.modelCatalog` builds the structured-session host only for a read that names a session (a structured chat). Terminal-backed chat's session-less read keeps the non-building gate, so a desktop that never runs structured chat never opens the session journal.
…enu open The waiting catalog read was owned by one run of the picker's effect. Attach (a new fence), hide/show or a send re-ran the effect: the cleanup released the model picker onto the built-in list for a round trip, and the new run sent a second waiting read while the first, which cannot be withdrawn, kept a remote call slot until the listing ended. The waiting read now belongs to the chat (runtime target + agent + session): a small registry keeps one in flight per chat, every re-run or remount joins it, and the entry is deleted when the read settles. The picker hold is derived from that entry being in flight, so it lasts across attach and hide/show and ends when the read settles, the provider reports its own list, or the pane switches to another session. Answers still pass the stale and record checks. A bare /model typed while the list loads no longer opens the model menu by itself when the list lands: the menu stays keyed on the request, and only its initial open is suppressed while pending, so the request is spent shut and the end of the pending period never remounts it.
…host list When the waiting catalog read settled in the chat that started it, the registry dropped its entry and told subscribers first, and the host list was applied a few microtasks later. React committed once with the picker enabled on the built-in list, then again with the host's list. Joiners now hand the registry their apply callback, and the registry runs every joiner (with the answer, or nothing when the read failed or timed out) before it deletes the entry and notifies. The release and the list land in one commit. An effect cleanup leaves the wait instead of flagging itself stale.
A model catalog read that waits on a host's first listing replies only when that listing ends, yet it took one of the 8 foreground call slots for its server. Enough chats opened during one cold listing would stall that server's sends and interrupts until a wait settled. agentSession.modelCatalog now joins worktree.rm in the long-wait lane: same concurrency, counted apart from the foreground calls. The queue classifies by method only, and a warm catalog read answers at once, so the whole method moves.
Review status — ready for review (head
|
There was a problem hiding this comment.
ℹ️ No critical issues — one minor note on the new timeout and a couple of nits.
Reviewed changes
- Host builds for a named chat's read —
agentSession.modelCatalognow usesrequireInstalledStructuredHostwhen the params name asessionId, so a new chat's picker can read before anything built the host; a session-less terminal-backed read keeps the non-building gate. - First-listing handshake —
agent-model-catalog-service.tsanswers{ origin: 'unknown', listingInProgress: true }when it starts or joins the account's first listing, and awaitForListing: trueread awaits that same joined listing (adding the optional params/result fields on the wire). - One waiting read per chat — new
host-model-listing-waits.tsshares a single waiting read across every mount/effect run, anduse-host-model-catalog-upgrade.tsderivesawaitingListingfrom it viauseSyncExternalStore. - Picker hold is derived — the model descriptor is marked
settable:false, choicesPending:truewhile the wait is in flight and no live catalog exists, so the pill keeps its label but cannot open; a typed/modelis refused. - Queue lane —
agentSession.modelCatalogmoved into the long-wait lane besideworktree.rm, so waiting reads don't hold foreground slots. - Custom launch command — the terminal-backed local shortcut to the host catalog is skipped when a custom TUI command is set, so the CLI listing (which honors it) runs instead.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| const STRUCTURED_AGENT_SESSION_METHOD_TIMEOUT_MS: ReadonlyMap<string, number> = new Map([ | ||
| ['agentSession.conversationCommand', 195_000], | ||
| // A waiting catalog read lasts as long as the host's listing: Claude's is 60 s, after up to 15 s | ||
| // for an account switch to settle and 5 s of login-shell environment. | ||
| ['agentSession.modelCatalog', 90_000] | ||
| ]) |
There was a problem hiding this comment.
The 90 s timeout is keyed by method, so it applies to every agentSession.modelCatalog call, not only the waitForListing read the PR describes. On an environment target callRuntimeRpc forwards timeoutMs into the compatibility status.get probe (runtime-rpc-client.ts:72), so a black-holed server now stalls the first warm read ~6× longer (90 s vs the default 15 s); and for kind: 'local' it drops timeoutMs entirely (runtime-rpc-client.ts:83-85), so the deadline is remote-only despite the desktop being the common case.
Technical details
# Method-keyed timeout is broader than intended
## Affected sites
- `src/renderer/src/runtime/structured-agent-session-client.ts:88-93` — map keyed only by method name.
- `src/renderer/src/runtime/runtime-rpc-client.ts:72-76` — `timeoutMs` flows into `ensureRuntimeEnvironmentCompatible`.
- `src/renderer/src/runtime/runtime-rpc-client.ts:83-85` — local branch ignores `options.timeoutMs`.
## Required outcome
- Only the read that actually waits on a listing needs the extended deadline; a warm read and the compatibility probe can keep the default.
## Suggested approach (optional)
- Select the timeout from `params` (e.g. `waitForListing === true`) rather than method alone, or apply it only to `callRuntimeEnvironmentWithRevision` and not the compatibility options.
## Open questions for the human (optional)
- Is extending the compatibility probe to 90 s intentional (mirroring the existing 195 s `conversationCommand` behavior)? If so, the local path silently having no deadline may still be worth a comment.There was a problem hiding this comment.
ℹ️ No new issues in the delta — the prior timeout note remains open.
Reviewed changes (delta since 4256aed)
- Merge of
origin/main(5558107) — the only commit added since the prior review. It brings main's OpenCode transcript-reader changes (src/main/native-chat/transcript-opencode*) into the branch and touches none of this PR's 22 changed files, so no authored code changed and no conflict resolution affected the model-catalog work.
The one minor note on method-keyed timeouts from the prior review still applies; nothing else changed.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (22)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe host catalog read can report an initial listing in progress and optionally wait for that listing. Renderer reads share in-flight waits, and model choices remain unavailable until the host list arrives. Model catalog calls use a long-wait queue lane and a dedicated timeout. Local agents with an explicit TUI launch command use runtime CLI discovery instead of the host catalog. Priority: ➖ Normal Merge Risk: 🔵 Low · up to This change makes structured-chat model pickers wait for the host's own model list instead of showing the built-in one. One open concern remains: the longer timeout may apply to quick catalog reads too, which could make an unresponsive remote server stall the first model read for longer than intended. The impact is bounded and the author can address it with a small change. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change coordinates waiting on the selected machine and prevents premature choices. No privilege increase was demonstrated, and discovery has deadlines and shared-work controls. Access-control coverage remains incomplete. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |

ELI5
When you open a new agent chat (the structured chat, not the terminal one), the model picker should list the models of the machine that will run the chat: your desktop, or a paired Orca server. Two things went wrong. On a machine that hadn't run a chat since it last started, the picker showed the desktop's built-in model list instead. And the first time a machine ever listed models for an account, the picker never got the real list at all. You could pick a model that machine doesn't have, and the chat refused it with an error toast when it started.
Now the picker asks the right machine even if it has run no chat yet. If that machine is still listing its models for the first time, the picker is greyed out for those few seconds and then shows the real list.
What Changed
What you saw before
What you see now
/model <name>during that wait shows the existing "Could not apply model" message. A bare/modelopens nothing until the list arrives.Mechanism
agentSession.modelCatalog(the read behind the picker) used the gate that refuses when the host's structured-session service isn't built yet. It answered "service disabled" until a chat was created or saved chats were restored at startup. Now a read that names a chat (structured chats always do) builds the service, the same way its neighbouragentSession.optionsalready does. The terminal-backed chat's read names no chat, so it keeps the old non-building gate: a desktop that only uses terminal-backed chat never opens the structured-session journal.unknownplus a new optionallistingInProgress: true. The picker then sends one more read with a new optionalwaitForListing: true. The host awaits that same listing and answers with the real list, orunknownif it failed. That second read gets a 90 s client timeout, above the slowest listing: Claude is about 80 s worst case, 85 s on Windows with a fallback shell. The at-rest options read never waits.Why
The list was already requested from the right machine; the request was refused or answered "not yet", and nothing ever asked again.
Alternatives considered:
listingInProgressanswer first. Rejected: the picker could then only grey out on "a read is pending", which flickers on every normal open. Older servers would also refuse the unknown parameter, because the params schema is strict.Differences from the common pattern:
Not in this PR (follow-ups, terminal-backed chat only):
Compatibility (clients and servers update independently):
listingInProgress, so the desktop never sendswaitForListing(the server's strict schema would refuse it). Behaviour is as before: the built-in list stays until the chat attaches.Linked Issue
N/A (maintainer follow-up from the remote structured chat work).
Visual Proof
Live check on macOS: a paired server and a desktop, each a separate isolated Orca built from this branch (4256aed), with a stand-in
claudewhose model listing takes 8 s and returns two models the desktop's built-in list doesn't have ("QA Host Only", "QA Host Alt")./modeltyped during the wait opened nothing then or later. A later/modelopens the server's list:Testing
Each new or changed test was confirmed to fail with its part of the fix reverted (33 such revert checks across the rounds).
agent-model-catalog-service.test.ts: with no saved list, the first read answerslistingInProgressand starts one listing. A waiting read joins that same listing (one listing process) and answers with the list, orunknownon failure. No wait or flag while a recent failure is still in its retry window, or when there is no lister. A saved but aged list is served at once.agent-session-wire/structured-agent-session-options-read.test.ts(new): the at-rest options read answers even while a listing never finishes.structured-agent-session-options-read.test.ts: a read naming a chat builds the service and answers. A read naming no chat (terminal-backed discovery) doesn't build it.waitForListingis passed through.native-chat-session-option-enrichment.test.ts: a local terminal chat with a custom launch command lists through the CLI, not the saved list.use-host-model-catalog-upgrade.test.tsx:NativeChatSessionOptionPickers*.test.tsx: the model pill is disabled while the list is pending. With the real menu component: a/modelduring the wait never opens the menu later or steals focus, and a later/modelopens it.structured-agent-session-client.test.ts: model-list reads get the 90 s timeout; other methods keep the default.runtime-rpc-call-queue.test.ts: 8 in-flight model-list reads to one server don't block a send to it.Also ran every importer of the changed modules, all structured-session RPC method suites, and the cross-version agent-session wire suite (all pass).
pnpm tc:node,pnpm tc:webandpnpm run check:code-quality:changedpass.Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
unknown, the picker is never greyed, and behaviour is as before.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)