Repository navigation
fix(native-chat): honor structured routing with saved options - #19040
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughStructured native-chat routing no longer falls back to legacy routing when Merge Risk: ⚪ Minimal · up to Structured Codex and Claude chats now retain supported saved model and effort preferences through session creation without falling back to terminal-backed routing. The covered routing, persistence, acquisition, and retry paths show no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the change, motivation, testing, scope, and regression coverage. However, it does not provide the required linked issue and includes only one visual attachment despite the template requiring before-and-after proof for UI or behavior changes.
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: bc1df21d-2072-424f-84b7-61f310b241fd
📒 Files selected for processing (3)
src/renderer/src/lib/agent-launch-routing.test.tssrc/renderer/src/lib/agent-launch-routing.tssrc/renderer/src/lib/launch-agent-structured-chat-guard.test.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/lib/agent-launch-routing.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
Important
Removing the hasInitialSessionOptions guard routes launches with a saved model/effort to the structured path, but the structured path never reads nativeChatSessionOptions — the saved preference is silently dropped instead of applied.
Reviewed changes
- Routing guard removal —
resolveAgentLaunchRoutestops forcinglegacy-native-chatwheninitialSessionOptionsis present, so Codex/Claude launches with a saved model or effort keep the structured route. - Routing unit test —
agent-launch-routing.test.tsnow asserts a saved model still resolves tostructured-native-chatand drops the old legacy-routing assertion. - Launch-path guard test —
launch-agent-structured-chat-guard.test.tsadds an end-to-end case that saved Codex options keep the launch on the structured path.
⚠️ Saved model and effort are not applied on the structured path
The guard this PR removes was the only thing routing a launch with nativeChatSessionOptions to the legacy TUI path, where resolveAgentLaunchCommand emits the saved model/effort as -m / --effort / -c model_reasoning_effort= flags. On the structured path nothing reads that setting: startStructuredAgentLaunch(worktreeId, agent, { prompt, promptDelivery, onPromptDelivered }) drops startupPlan.sessionOptions, and the host resolves the provider model from agentDefaultArgs (resolveConfiguredCodexStructuredArgs / resolveConfiguredClaudeStructuredArgs), not nativeChatSessionOptions. A user who saved gpt-5.6-sol with medium effort now opens a structured chat on the default model with no effort override, silently. The new test asserts only routing (focusAfterMenuClose: 'structured-session', mockCreateTab not called), so it passes whether or not the model/effort is applied.
Technical details
# Saved model/effort dropped on the structured route
## Affected sites
- src/renderer/src/lib/launch-agent-in-new-tab.ts:231 — `startStructuredAgentLaunch` carries no `sessionOptions`; `StructuredAgentLaunchOptions` is only `{ prompt, promptDelivery, onPromptDelivered }`.
- src/renderer/src/lib/structured-agent-session-launch-callers.ts:13 — `StructuredAgentLaunchOptions` has no option fields.
- src/renderer/src/lib/launch-structured-agent-session.ts:95 — the `agentSession.create` intent sends only `{ worktree, agent }`.
- src/main/runtime/orca-runtime-get-worktree-ps.ts:191-201 — the structured provider launch args come from `agentDefaultArgs`, not `nativeChatSessionOptions`.
- src/renderer/src/components/native-chat/native-chat-launch-session-options.ts — `resolveInitialNativeChatSessionOptions` (the source of `startupPlan.sessionOptions`) is only consumed by the legacy TUI branch.
## Required outcome
- The saved model/effort reaches the structured session (apply it to the structured launch args or an initial `agentSession.setOption`), or the guard is retained.
- The new test asserts the model/effort actually reaches the structured session, not only that routing changed.
## Open questions for the human
- Is the structured chat meant to seed its initial model from `nativeChatSessionOptions`, or is that setting intentionally legacy-only?ℹ️ Nitpicks
initialSessionOptionsis no longer read anywhere inresolveAgentLaunchRoute— it is now dead input that every caller still computes and passes. Consider removing it fromAgentLaunchRoutingInput(and thelaunch-agent-in-new-tab.tscall site) or documenting why it is retained.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the follow-up commit (94d402b) on top of the previously reviewed guard removal. It closes the gap the prior review flagged: the saved model/effort now reaches the structured session instead of being silently dropped.
optionsthreaded through the attach/reservation path —AgentSessionAttachParams,AgentSessionReserveRequest, andcreateAgentSessionRecordnow carry a host-resolvedoptionsmap, validated by the exportedisAgentSessionOptions.- Seed resolved on the executing host —
resolveStructuredAgentSessionIntentderives{ model, effort }fromresolveNativeChatSessionOptionDefaults(settings.nativeChatSessionOptions, agent), mirroring the-m/--effort/-c model_reasoning_effort=flags the legacy TUI path used to emit. - Fingerprint computation unified —
agentSession.createreusesattachFingerprintFieldsinstead of a hand-rolled field list, so the attach fingerprint includesoptionsand stays consistent withadmitAttachOrRefuse. Canonicalization dropsundefinedkeys, so this is wire-neutral. - Coverage added — new tests assert the create intent carries
{ model, effort }, the reservation persists options before the first acquisition, and the RPC forwards them tohost.attach.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
One follow-up commit landed mid-review, tightening the create-path fingerprint so it provably matches the attach-time recomputation.
- Fingerprint now hashes the client envelope —
agentSession.createcomputes the attach fingerprint fromattachFingerprintFields({ ...resolved, envelope: params.envelope })rather thanattachFingerprintFields(resolved), so the hashedexpectedRuntimeFenceisparams.envelope.expectedRuntimeFence(validatednullfor create) instead of the resolver's hardcoded-null envelope. The two values are equal today, so this is behavior-preserving, but it removes the one place the create-time andadmitAttachOrRefuserecomputations could drift apart.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Seeding host-resolved options into the attach fingerprint put a mutable value into the durable operation identity. A create whose outcome was unknown, retried under the same operation id after the user reselected a model, re-resolved different options and hashed to a different fingerprint — so the ledger refused it as a conflict instead of replaying. That refusal is not definitive, so no legacy fallback fires and the launch has no recovery. Options are the session's initial state, not its identity, and the reservation still carries them to the record. Excluding them also makes the digest byte-identical to the pre-change one in every case, not just when no options resolve.
The create-intent resolver narrowed saved options to model/effort with an inline key literal, inside a file carrying @ts-nocheck — so neither the key list nor the string narrowing had a typechecked or testable home, and the repo already expresses this concept as a named shared shape. Move it to resolveStructuredLaunchSeedOptions beside the persisted settings it reads, where it is typechecked and unit-tested, and document why the seed is exactly model and effort: they are the only ids the picker persists that both providers also accept as strings. No behavior change. Adds coverage for a non-string persisted effort, which settings.json can hold and the durable record must not carry.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the follow-up commit (52c78c30) on top of the previously approved 94d402b and 5d72c80. It removes options from the attach fingerprint so a create retried after the host re-resolves different options replays instead of conflicting.
optionsexcluded from the attach fingerprint —attachFingerprintFieldsnow hashes only session identity (location,provider,agent,accountHome,runtimeKind,providerHandle,expectedRuntimeFence), treatingoptionsas initial state rather than identity. A create retried after the user reselects a model/effort computes the same fingerprint and replays the original record instead of being refused withagent_session_operation_conflict.- Replay regression test —
structured-agent-session-acquisition-options.test.tsasserts a retry with different options still replays and preserves the first attempt's options.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the follow-up commit (eb33ee6) on top of the previously approved 52c78c30. It extracts the inline ['model','effort'] filter into a named, documented helper and adds dedicated tests.
resolveStructuredLaunchSeedOptionsextracted — the host-side seed narrowing moves from an inlineObject.fromEntriesin the create-intent resolver intosrc/shared/native-chat-session-option-defaults.ts, with a doc comment explaining why onlymodel/effortare seedable.- Whitespace hardening — the helper drops blank values via
.trim(), so a user-writable non-string or blankeffortcannot reach the durableRecord<string, string>record. - Coverage added —
native-chat-session-option-defaults.test.tsasserts seeding, mid-session-only id exclusion, and blank/non-string value exclusion.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
The case drives a saved Codex model and effort through the launch path, but the structured create intent it asserts on carries no options, so it pins the route and not the preservation its name claimed. Preservation is pinned host-side, where the seeding actually happens.
valuesByModel is merged over the resolved model, so a stored `model` key
can blank it — the seed then empties out and must resolve to undefined.
Nothing covered that branch, so returning the empty map unguarded stayed
green.
It matters because emitting `{ model: '' }` fails the record's
bounded-string guard, and agent_session_options_invalid is not a wire
refusal code: classifyStoreFailure rethrows it, the client reads the raw
error as an unknown outcome, and the launch strands with no fallback.
Corrects eb33ee6, whose message claimed no behavior change. That
extraction also stopped emitting empty and whitespace-only values, which
is a fix on six input shapes, not a pure move.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the final follow-up commit (b1b9256) on top of the previously reviewed seed-narrowing work. It is test-only, with no production change.
- Empty-model edge case pinned —
native-chat-session-option-defaults.test.tsadds a case assertingresolveStructuredLaunchSeedOptionsreturnsundefinedwhen a storedvaluesByModelmodel: ''blanks the resolved model, rather than emitting{ model: '' }that would fail the durable record's bounded-string guard.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Independent Grok Electron validation — PR #19040Validated remote head: No code was modified. No merge was performed. No defect requiring a fix loop was found. ScenariosIsolated
Added a throwaway local git worktree, then exercised the visible New Tab menu.
Credentials: Visible evidenceNew Tab menu with Claude and Codex entries: Codex: structured chat UI titled Codex Chat, empty-state copy “Start a chat with Codex”, composer showing Medium and GPT-5.6-Sol. Not a terminal-backed legacy session. Claude: structured chat UI titled Claude Chat, empty-state copy “Start a chat with Claude”, composer showing opus. Not a terminal-backed legacy session. After Claude launch, Codex Chat still shows structured Medium / GPT-5.6-Sol with both tabs present: Screenshots are uncropped full-window CDP captures (1728×1007). A Playwright inspector overlay is visible at the bottom of the window; it is not product UI. Backing evidenceRenderer store after both launches:
Durable
Both records are in Unverified gaps
|
Final review and validation statusAll requested review and QA loops are complete at
Remaining manual gaps: folder/SSH/WSL/Windows hosts and a first prompt were not exercised in the Electron run. CI covers Windows packaging and the automated suites cover the host-side path. Merged: squash commit |
Carries main's #19040 through this branch's two extractions, which would otherwise have silently reverted it: both conflicts are the same shape, where main fixed code this branch had already moved elsewhere. - resolveStructuredNativeChatSupport no longer refuses a launch that has saved session options. Main removed that term from resolveAgentLaunchRoute directly; this branch had lifted the whole predicate into the shared module, so taking either conflict side kept the refusal alive. The blocker member, the unused input field, the orchestration blocker-to-reason entry and the case pinning it are removed with it. Main's own routing test failed on this merge before the port and passes after, which is what proves the port is load-bearing rather than cosmetic. - The structured create fingerprint now goes through attachFingerprintFields. Same shape again: main replaced the inline field list in structured-agent-session.ts, but this branch had moved that computation into structured-agent-session-create.ts. Options stay out of the digest, which is main's point: they are the session's initial state, not its identity, so a retry after the user reselects a model replays instead of conflicting.
…placement (#19431) * fix(orchestration): let worker-start actually produce a structured chat `orchestration.workerStart` reads the user's "open agent tabs in chat" default, but two placement checks downgraded a structured-preferring worker to a PTY terminal agent for the two flags a routine dispatch always passes: --worktree new-child / new-top-level -> worktree_creation --model / --effort -> launch_preferences so in practice a structured worker never happened. launch_preferences was stale. PR #19040 gave AgentSessionAttachParams `options` and added resolveStructuredLaunchSeedOptions, which narrows a saved selection to exactly `model` and `effort` — the two ids both structured providers accept as strings. --model/--effort now go through that same narrowing (extracted as narrowStructuredLaunchSeedOptions) and seed the worker's session instead of forcing a terminal. An option set that narrows to nothing resolves to undefined, never `{}`, which would fail the record's bounded-string guard under a code that is not a wire refusal and strand the launch with no fallback. worktree_creation was a consequence of createWorkerWorktree creating agent-first: its startup terminal WAS the worker, so the structured branch below it was unreachable for any new worktree. A structured worker now creates the worktree with no startup agent and creates its session for the worktree afterwards — the order the renderer's own structured worktree create already uses. Because the executing host can only answer agentSession.createSupport for a workspace that exists, that verdict moved after creation: a refusal (WSL, and the rest) becomes a terminal agent in the worktree just created, never a failed start. --on and --terminal still downgrade, with their reasons intact, and every remaining downgrade still states itself in the mode receipt. The wait-for-setup gate is preserved explicitly. A PTY worker got it for free — agent-first creation sequences the agent's startup command behind the setup runner, so tui-idle could not arrive until setup exited. A structured session has no startup command to sequence, so the gate is now awaited directly, bounded by the start's own timeout. Split out worker-worktree-creation.ts and worker-start-agent-placement.ts rather than growing two files that were both pinned at the max-lines cap. * refactor(native-chat): make shared feasibility authoritative for launch routing * Type the structured setup gate's absent blocked reason so the wait union stays property-typed The type-aware audit rejected the blocked-reason template literal: narrowing the wait union with an 'in' check left the field typed unknown. Declaring that a structured setup gate never carries a blocked reason restores the direct read. --------- Co-authored-by: Merge Sim <sim@local>
…ai#19040) * fix(native-chat): keep saved options on structured route * fix(native-chat): seed structured session options * fix(native-chat): preserve create wire compatibility * fix(native-chat): keep create replayable across an option change Seeding host-resolved options into the attach fingerprint put a mutable value into the durable operation identity. A create whose outcome was unknown, retried under the same operation id after the user reselected a model, re-resolved different options and hashed to a different fingerprint — so the ledger refused it as a conflict instead of replaying. That refusal is not definitive, so no legacy fallback fires and the launch has no recovery. Options are the session's initial state, not its identity, and the reservation still carries them to the record. Excluding them also makes the digest byte-identical to the pre-change one in every case, not just when no options resolve. * refactor(native-chat): name the structured launch option seed The create-intent resolver narrowed saved options to model/effort with an inline key literal, inside a file carrying @ts-nocheck — so neither the key list nor the string narrowing had a typechecked or testable home, and the repo already expresses this concept as a named shared shape. Move it to resolveStructuredLaunchSeedOptions beside the persisted settings it reads, where it is typechecked and unit-tested, and document why the seed is exactly model and effort: they are the only ids the picker persists that both providers also accept as strings. No behavior change. Adds coverage for a non-string persisted effort, which settings.json can hold and the durable record must not carry. * test(native-chat): name the structured routing pin for what it asserts The case drives a saved Codex model and effort through the launch path, but the structured create intent it asserts on carries no options, so it pins the route and not the preservation its name claimed. Preservation is pinned host-side, where the seeding actually happens. * test(native-chat): pin the empty seed the record cannot carry valuesByModel is merged over the resolved model, so a stored `model` key can blank it — the seed then empties out and must resolve to undefined. Nothing covered that branch, so returning the empty map unguarded stayed green. It matters because emitting `{ model: '' }` fails the record's bounded-string guard, and agent_session_options_invalid is not a wire refusal code: classifyStoreFailure rethrows it, the client reads the raw error as an unknown outcome, and the launch strands with no fallback. Corrects eb33ee6, whose message claimed no behavior change. That extraction also stopped emitting empty and whitespace-only values, which is a fix on six input shapes, not a pure move. --------- Co-authored-by: Merge Sim <sim@local>





ELI5
Turning on structured chat now reliably opens structured Codex/Claude chats even when a model or effort was previously selected, and that selection is applied to the new chat.
What Changed
Why
A recent routing guard treated any saved model/effort as a reason to fall back to legacy native chat. Removing that guard exposed a second gap: the structured path did not seed those saved values. Persisting them during reservation preserves the selected behavior without a post-create race.
Regression Point
Introduced by #18248 — feat(native-chat): unify local agent entrypoint routing, commit
c4f335b49d.Linked Issue
Reported directly; no linked tracker issue.
Visual Proof
Before: New tab → Codex opened a terminal-backed legacy chat when saved options existed.
After: the same flow renders a structured Codex Chat with the saved Medium / GPT-5.6-Sol selection.
Testing
Local macOS verification:
agent-sessiontab state, no terminal-backed tab, and durable{ model: "gpt-5.6-sol", effort: "medium" }session recordCI covers the full test matrix and macOS/Windows packaging.
AI Disclosure
Review
Please focus on structured create idempotency and ensuring initial options are durable before provider acquisition.
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
The option seeding is host-side and does not change the remote RPC schema. Location resolution remains shared across local, SSH, WSL, git worktree, and folder workspace flows.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)