Repository navigation
feat(native-chat): add per-model session option pickers with verified Claude switch - #9085
Conversation
Introduces a shared agent session-option catalog (Claude/Codex/Gemini/Cursor) with model-scoped options, launch-command composition, mid-session dispatch via slash commands, and per-model persisted defaults. Wires the new NativeChatSessionOptionPickers UI into the composer, threads sessionOptions through every startup-plan builder (worktree creation, onboarding, source control actions, folder workspace, direct work-item launches), and adds localized strings and tests across the affected surfaces.
Native chat's model/effort picker now dispatches option commands through a body-then-verified-Enter write path and, for Claude, arms a PTY observer that classifies the cached-history confirmation prompt as applied/rejected/needs interaction before the picker returns — falling back to the terminal only when Claude genuinely requires manual input, and clearing stale truth otherwise. Also reorders the composer's model/effort pills, disambiguates their tooltip labels, and switches disabled-reason strings to a closed enum so producer and localized copy can't drift.
📝 WalkthroughWalkthroughThe change adds catalog-based native chat session options with per-agent and per-model defaults, persistence, launch-command composition, and startup-plan propagation. Native chat gains PTY-backed option state, model discovery, terminal parsing, Claude model-switch confirmation, verified command dispatch, and composer pickers. Worktree, workspace, onboarding, source-control, floating-terminal, and direct-launch flows seed applied options. Runtime terminal subscriptions support live-tail startup, while localization and tests cover the new behavior. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 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 |
- Reads the mounted xterm's main-buffer snapshot (falling back to the rendered screen when the alternate screen owns the buffer) to parse Claude's header for the currently active model and effort, so the native chat picker reflects reality instead of only dispatched state - Extracts command-apply recording and reported-value application into dedicated modules, and factors file-link click handling into a hook, to keep native-chat-pty-session-options.ts focused
There was a problem hiding this comment.
Actionable comments posted: 10
🧹 Nitpick comments (1)
src/renderer/src/components/native-chat/native-chat-runtime-send.test.ts (1)
90-105: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep body acceptance pending while asserting the Enter delay has not started.
The mock resolves immediately, so this test does not verify its stated ordering guarantee. Use a deferred body-acceptance promise, advance timers while it is unresolved, and assert that only the body write occurred before resolving it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: fb0d35aa-1677-4c31-a805-5e7cd57ee0a6
📒 Files selected for processing (70)
src/main/persistence.test.tssrc/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsxsrc/renderer/src/components/native-chat/NativeChatComposer.test.tsxsrc/renderer/src/components/native-chat/NativeChatComposer.tsxsrc/renderer/src/components/native-chat/NativeChatComposerActions.test.tsxsrc/renderer/src/components/native-chat/NativeChatComposerActions.tsxsrc/renderer/src/components/native-chat/NativeChatComposerField.tsxsrc/renderer/src/components/native-chat/NativeChatSessionOptionPickers.test.tsxsrc/renderer/src/components/native-chat/NativeChatSessionOptionPickers.tsxsrc/renderer/src/components/native-chat/NativeChatView.tsxsrc/renderer/src/components/native-chat/claude-model-switch-confirmation.test.tssrc/renderer/src/components/native-chat/claude-model-switch-confirmation.tssrc/renderer/src/components/native-chat/claude-terminal-session-options.test.tssrc/renderer/src/components/native-chat/claude-terminal-session-options.tssrc/renderer/src/components/native-chat/native-chat-pty-session-options.test.tssrc/renderer/src/components/native-chat/native-chat-pty-session-options.tssrc/renderer/src/components/native-chat/native-chat-runtime-send.test.tssrc/renderer/src/components/native-chat/native-chat-runtime-send.tssrc/renderer/src/components/native-chat/native-chat-session-option-cache.tssrc/renderer/src/components/native-chat/native-chat-session-option-command-builder.tssrc/renderer/src/components/native-chat/native-chat-session-option-command-dispatch.tssrc/renderer/src/components/native-chat/native-chat-session-option-command-matching.tssrc/renderer/src/components/native-chat/native-chat-session-option-command-recording.tssrc/renderer/src/components/native-chat/native-chat-session-option-discovery.tssrc/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.tssrc/renderer/src/components/native-chat/native-chat-session-option-enrichment.tssrc/renderer/src/components/native-chat/native-chat-session-option-labels.tssrc/renderer/src/components/native-chat/native-chat-session-option-reporting.tssrc/renderer/src/components/native-chat/native-chat-session-option-snapshot.tssrc/renderer/src/components/native-chat/use-native-chat-dictation-actions.tssrc/renderer/src/components/native-chat/use-native-chat-file-attachment-actions.tssrc/renderer/src/components/native-chat/use-native-chat-file-link-click.tssrc/renderer/src/components/native-chat/use-native-chat-session-option-command.tssrc/renderer/src/components/native-chat/use-native-chat-session-options.tssrc/renderer/src/components/onboarding/onboarding-folder-agent-startup.test.tssrc/renderer/src/components/right-sidebar/buildSourceControlAgentDeliveryPlan.tssrc/renderer/src/components/sidebar/folder-workspace-composer-submit.tssrc/renderer/src/components/terminal-pane/TerminalPane.tsxsrc/renderer/src/hooks/useComposerState.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/i18n/native-chat-locales.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-work-item-direct-agent.tssrc/renderer/src/lib/launch-work-item-direct.test.tssrc/renderer/src/lib/onboarding-folder-agent-startup.tssrc/renderer/src/lib/source-control-agent-action-plan.tssrc/renderer/src/lib/worktree-activation-created-agent.test.tssrc/renderer/src/lib/worktree-activation.tssrc/renderer/src/lib/worktree-creation-flow.tssrc/renderer/src/runtime/runtime-terminal-stream.test.tssrc/renderer/src/runtime/runtime-terminal-stream.tssrc/renderer/src/store/slices/repos-onboarding-folder-startup.test.tssrc/shared/agent-session-option-catalog-claude-codex.tssrc/shared/agent-session-option-catalog-gemini-cursor.tssrc/shared/agent-session-option-catalog-types.tssrc/shared/agent-session-option-catalog.test.tssrc/shared/agent-session-option-catalog.tssrc/shared/agent-session-option-launch.tssrc/shared/constants.tssrc/shared/native-chat-session-option-defaults.tssrc/shared/native-chat-session-options.tssrc/shared/tui-agent-launch-command.tssrc/shared/tui-agent-startup-session-options.test.tssrc/shared/tui-agent-startup.tssrc/shared/types.ts
| const persist = (modelId: string | null, optionId: string, value: SessionOptionValue): void => { | ||
| if (modelId) { | ||
| void args.persistSelection?.({ modelId, optionId, value }) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Serialize and handle asynchronous persistence writes.
PersistSelection may return a promise, but Line 128 discards it. Rapid changes can complete out of order and persist an older default; failures also become unhandled rejections. Queue these writes and report failures.
| const worktreeId = | ||
| Object.entries(state.tabsByWorktree ?? {}).find(([, tabs]) => | ||
| tabs.some((tab) => tab.id === terminalTabId) | ||
| )?.[0] ?? null |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Match the backing terminal through tab.entityId.
terminalTabId identifies the terminal entity, so comparing it with tab.id can miss the owning worktree and build discovery context for the wrong connection/host.
Proposed fix
const worktreeId =
Object.entries(state.tabsByWorktree ?? {}).find(([, tabs]) =>
- tabs.some((tab) => tab.id === terminalTabId)
+ tabs.some((tab) => tab.entityId === terminalTabId)
)?.[0] ?? nullBased on learnings, native-chat pane lookups must use the backing terminal tab id (entityId) rather than tab.id.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const worktreeId = | |
| Object.entries(state.tabsByWorktree ?? {}).find(([, tabs]) => | |
| tabs.some((tab) => tab.id === terminalTabId) | |
| )?.[0] ?? null | |
| const worktreeId = | |
| Object.entries(state.tabsByWorktree ?? {}).find(([, tabs]) => | |
| tabs.some((tab) => tab.entityId === terminalTabId) | |
| )?.[0] ?? null |
Source: Learnings
| export function nativeChatSessionOptionDisabledReason( | ||
| reason: SessionOptionDisabledReason | undefined | ||
| ): string | null { | ||
| // Exhaustive over SessionOptionDisabledReason: a new key is a compile error | ||
| // here, so the localized label can never silently drift from the producer. | ||
| switch (reason) { | ||
| case 'set-when-session-starts': | ||
| return translate( | ||
| 'components.native-chat.composer.setWhenSessionStarts', | ||
| 'Set when the session starts.' | ||
| ) | ||
| case 'available-after-session-start': | ||
| return translate( | ||
| 'components.native-chat.composer.availableAfterSessionStarts', | ||
| 'Available after the session starts.' | ||
| ) | ||
| default: | ||
| return null | ||
| } | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Enforce the intended compile-time exhaustiveness check.
The inline comment explicitly indicates that adding a new key to SessionOptionDisabledReason will cause a compile error, but the default case completely bypasses TypeScript's exhaustiveness check. If a new member is added to the upstream union, it will silently fall through to the default case and return null instead of failing to compile.
To achieve the intended compile-time safety, remove the default block and explicitly handle the undefined case. Assuming noImplicitReturns is enabled in your tsconfig.json, TypeScript will then flag an error if a future union member is unhandled.
♻️ Proposed fix
export function nativeChatSessionOptionDisabledReason(
reason: SessionOptionDisabledReason | undefined
): string | null {
// Exhaustive over SessionOptionDisabledReason: a new key is a compile error
// here, so the localized label can never silently drift from the producer.
switch (reason) {
case 'set-when-session-starts':
return translate(
'components.native-chat.composer.setWhenSessionStarts',
'Set when the session starts.'
)
case 'available-after-session-start':
return translate(
'components.native-chat.composer.availableAfterSessionStarts',
'Available after the session starts.'
)
- default:
+ case undefined:
return null
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export function nativeChatSessionOptionDisabledReason( | |
| reason: SessionOptionDisabledReason | undefined | |
| ): string | null { | |
| // Exhaustive over SessionOptionDisabledReason: a new key is a compile error | |
| // here, so the localized label can never silently drift from the producer. | |
| switch (reason) { | |
| case 'set-when-session-starts': | |
| return translate( | |
| 'components.native-chat.composer.setWhenSessionStarts', | |
| 'Set when the session starts.' | |
| ) | |
| case 'available-after-session-start': | |
| return translate( | |
| 'components.native-chat.composer.availableAfterSessionStarts', | |
| 'Available after the session starts.' | |
| ) | |
| default: | |
| return null | |
| } | |
| } | |
| export function nativeChatSessionOptionDisabledReason( | |
| reason: SessionOptionDisabledReason | undefined | |
| ): string | null { | |
| // Exhaustive over SessionOptionDisabledReason: a new key is a compile error | |
| // here, so the localized label can never silently drift from the producer. | |
| switch (reason) { | |
| case 'set-when-session-starts': | |
| return translate( | |
| 'components.native-chat.composer.setWhenSessionStarts', | |
| 'Set when the session starts.' | |
| ) | |
| case 'available-after-session-start': | |
| return translate( | |
| 'components.native-chat.composer.availableAfterSessionStarts', | |
| 'Available after the session starts.' | |
| ) | |
| case undefined: | |
| return null | |
| } | |
| } |
| const send = useCallback(() => { | ||
| const text = draft | ||
| const imagePaths = imageAttachments.map((attachment) => attachment.path) | ||
| if ((text.trim() === '' && imagePaths.length === 0) || disabled) { | ||
| return | ||
| } | ||
| // Why: block a normal send while a session-option command (e.g. /model) is | ||
| // still writing its body+delayed-Enter to the same pty, so the two write | ||
| // sequences can't interleave on one input line. | ||
| if (isDispatchingSessionOption) { | ||
| return | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the relevant file and related hook
git ls-files 'src/renderer/src/components/native-chat/NativeChatComposer.tsx' \
'src/renderer/src/components/native-chat/*' \
'src/renderer/src/hooks/*' \
'src/renderer/src/**/useNativeChatSessionOptionCommand*'
# Show the relevant ranges with line numbers
printf '\n## NativeChatComposer.tsx (around lines 240-420)\n'
sed -n '240,420p' src/renderer/src/components/native-chat/NativeChatComposer.tsx | cat -n
printf '\n## Search for dispatchSlash and isDispatchingSessionOption usages\n'
rg -n "dispatchSlash|isDispatchingSessionOption|useNativeChatSessionOptionCommand" src/renderer/src/components/native-chat src/renderer/src -SRepository: stablyai/orca
Length of output: 25365
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## use-native-chat-session-option-command.ts\n'
sed -n '1,260p' src/renderer/src/components/native-chat/use-native-chat-session-option-command.ts | cat -n
printf '\n## Related tests mentioning isDispatching or delayed Enter/session-option dispatch\n'
rg -n "isDispatching|delayed|session option|/model|dispatchSessionOptionCommand|dispatchSlash" src/renderer/src/components/native-chat/*.test.tsx src/renderer/src/components/native-chat/*.test.ts -SRepository: stablyai/orca
Length of output: 9865
Guard the slash-dispatch path and arm the busy flag earlier.
src/renderer/src/components/native-chat/NativeChatComposer.tsx still lets dispatchSlash write to the PTY without checking isDispatchingSessionOption, and src/renderer/src/components/native-chat/use-native-chat-session-option-command.ts doesn’t set isDispatching until after observer.ready. A /model autocomplete dispatch can still interleave with the delayed PTY write; set the flag before the first await and block dispatchSlash while dispatching.
| const pickAttachment = useCallback(() => { | ||
| void (async () => { | ||
| const filePath = await window.api.shell.pickAttachment() | ||
| if (filePath) { | ||
| attachExternalPaths([filePath]) | ||
| } | ||
| })() |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Handle attachment-picker rejection.
The detached async call has no rejection handler, so an IPC/dialog failure produces an unhandled promise rejection. Catch it and report the failure through the composer notice/error path.
Minimal containment
const pickAttachment = useCallback(() => {
void (async () => {
- const filePath = await window.api.shell.pickAttachment()
- if (filePath) {
- attachExternalPaths([filePath])
+ try {
+ const filePath = await window.api.shell.pickAttachment()
+ if (filePath) {
+ attachExternalPaths([filePath])
+ }
+ } catch {
+ // Report through the caller's composer error/notice mechanism.
}
})()
}, [attachExternalPaths])| const dispatch = useCallback( | ||
| async (command, options) => { | ||
| const target = resolveTarget() | ||
| if (!target || disabled) { | ||
| throw new Error('No live terminal is available.') | ||
| } | ||
| const detectClaudeConfirmation = | ||
| options?.detectAgentInteraction === 'claude-model-switch-confirmation' | ||
| let observer: ClaudeModelSwitchConfirmationObserver | null = null | ||
| if (detectClaudeConfirmation) { | ||
| observer = createClaudeModelSwitchConfirmationObserver({ | ||
| ptyId: target.ptyId, | ||
| settings: target.settings, | ||
| expectedModelLabel: options?.expectedChoiceLabel ?? null | ||
| }) | ||
| activeObserversRef.current.add(observer) | ||
| await observer.ready | ||
| if (!mountedRef.current) { | ||
| activeObserversRef.current.delete(observer) | ||
| observer.dispose() | ||
| throw new Error('Native chat command was canceled because the composer closed.') | ||
| } | ||
| // Why: arm only after the observer reaches the live PTY tail, then | ||
| // submit immediately so historical output cannot satisfy the match. | ||
| observer.arm() | ||
| } | ||
| const sendController = new AbortController() | ||
| activeSendsRef.current.add(sendController) | ||
| setIsDispatching(true) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Acquire the dispatch lock before awaiting observer readiness.
For Claude, isDispatching remains false during await observer.ready, which can take up to 10 seconds remotely. A normal send or second picker action can therefore start and interleave writes on the same PTY—the exact corruption this hook is intended to prevent.
Set the busy state before observer setup and add a synchronous ref guard so back-to-back dispatches cannot enter concurrently. Ensure the outer finally covers observer readiness too.
| for (const key of ['fast', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'] as const) { | ||
| expect(composer.optionValue[key]).not.toBe(englishComposer.optionValue[key]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reject empty localized option labels.
An empty string passes the current English-inequality assertion and can produce blank picker choices.
Proposed test fix
for (const key of ['fast', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'] as const) {
+ expect(composer.optionValue[key].trim()).not.toBe('')
expect(composer.optionValue[key]).not.toBe(englishComposer.optionValue[key])
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| for (const key of ['fast', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'] as const) { | |
| expect(composer.optionValue[key]).not.toBe(englishComposer.optionValue[key]) | |
| for (const key of ['fast', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'] as const) { | |
| expect(composer.optionValue[key].trim()).not.toBe('') | |
| expect(composer.optionValue[key]).not.toBe(englishComposer.optionValue[key]) |
| export const GEMINI_SESSION_OPTION_CATALOG: AgentSessionOptionCatalog = { | ||
| models: [ | ||
| { id: 'gemini-3-pro-preview', label: 'Gemini 3 Pro Preview', options: [] }, | ||
| { id: 'gemini-3-flash-preview', label: 'Gemini 3 Flash Preview', options: [] }, | ||
| { id: 'gemini-2.5-pro', label: 'Gemini 2.5 Pro', options: [] }, | ||
| { id: 'gemini-2.5-flash', label: 'Gemini 2.5 Flash', options: [] } | ||
| ], |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== relevant files ==\n'
git ls-files 'src/shared/*agent-session-option-catalog*' 'src/shared/*catalog*' 'src/**/agent-session-option-catalog*' 'src/**/catalog*' 'docs/**' | sed -n '1,200p'
printf '\n== grep for catalogDefaultModel and isDefault ==\n'
rg -n "catalogDefaultModel|isDefault|GEMINI_SESSION_OPTION_CATALOG|auto" src docs --glob '!**/dist/**' --glob '!**/build/**'
printf '\n== file outline: src/shared/agent-session-option-catalog-gemini-cursor.ts ==\n'
ast-grep outline src/shared/agent-session-option-catalog-gemini-cursor.ts --view expanded
printf '\n== file outline: any file defining catalogDefaultModel ==\n'
fd -a ".*" src | rg "catalog.*default|default.*catalog|session-option-catalog" | sed -n '1,200p'Repository: stablyai/orca
Length of output: 5382
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== outlines ==\n'
ast-grep outline src/shared/agent-session-option-catalog.ts --view expanded
printf '\n---\n'
ast-grep outline src/shared/agent-session-option-catalog-types.ts --view expanded
printf '\n---\n'
ast-grep outline src/shared/agent-session-option-catalog.test.ts --view expanded
printf '\n---\n'
ast-grep outline src/shared/agent-session-option-catalog-gemini-cursor.ts --view expanded
printf '\n== line counts ==\n'
wc -l src/shared/agent-session-option-catalog.ts src/shared/agent-session-option-catalog-types.ts src/shared/agent-session-option-catalog.test.ts src/shared/agent-session-option-catalog-gemini-cursor.ts
printf '\n== relevant slices ==\n'
sed -n '1,260p' src/shared/agent-session-option-catalog.ts
printf '\n--- types ---\n'
sed -n '1,240p' src/shared/agent-session-option-catalog-types.ts
printf '\n--- tests ---\n'
sed -n '1,260p' src/shared/agent-session-option-catalog.test.ts
printf '\n--- gemini catalog ---\n'
sed -n '1,200p' src/shared/agent-session-option-catalog-gemini-cursor.tsRepository: stablyai/orca
Length of output: 13756
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== outlines ==\n'
ast-grep outline src/shared/native-chat-session-option-defaults.ts --view expanded
printf '\n---\n'
ast-grep outline src/shared/agent-session-option-launch.ts --view expanded
printf '\n== slices ==\n'
sed -n '1,260p' src/shared/native-chat-session-option-defaults.ts
printf '\n--- launch ---\n'
sed -n '1,260p' src/shared/agent-session-option-launch.ts
printf '\n== search for Gemini-specific defaults or auto handling ==\n'
rg -n "gemini|auto|catalogDefaultModel|resolveNativeChatSessionOptionDefaults|updateNativeChatSessionOptionDefaults" src/shared src --glob '!**/dist/**'Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== native-chat-session-option-defaults ==\n'
sed -n '1,260p' src/shared/native-chat-session-option-defaults.ts
printf '\n== gemini launch references ==\n'
rg -n "getAgentSessionOptionCatalog\\('gemini'\\)|resolveNativeChatSessionOptionDefaults\\(|catalogDefaultModel\\(|GEMINI_SESSION_OPTION_CATALOG|agent: 'gemini'|model: 'gemini" src --glob '!**/dist/**' --glob '!**/build/**' | sed -n '1,200p'
printf '\n== launch-work-item-direct tests around gemini ==\n'
sed -n '500,560p' src/renderer/src/lib/launch-work-item-direct.test.ts
printf '\n== any gemini-specific docs in repo ==\n'
rg -n "Gemini.*auto|auto.*Gemini|model selection|default model|gemini.*model" docs src/shared --glob '!**/dist/**' --glob '!**/build/**' | sed -n '1,200p'Repository: stablyai/orca
Length of output: 10519
🌐 Web query:
Gemini CLI model docs auto default model selection
💡 Result:
The Gemini CLI model selection is determined by a hierarchical order of precedence, where flags and configuration files override default settings [1]. When no specific model is requested, the CLI defaults to the auto-routing behavior [1][2]. Order of Precedence for Model Selection The CLI determines which model to use based on the following precedence (from highest to lowest priority) [1]: 1. --model (or -m) Command-line Flag: Specifies the model for the current session and overrides all other settings [1][2][3]. 2. GEMINI_MODEL Environment Variable: Sets a default model for the environment, overriding configuration files and hardcoded defaults [1][3]. 3. settings.json Configuration: The model specified in the model.name property within your settings.json file [1][4]. This can be configured globally or at the project level (e.g., in a.gemini/settings.json file) [4][5]. 4. Local/Default Fallback: If none of the above are specified, the CLI defaults to the auto model [1]. Auto-Routing Behavior The auto model is the recommended default, as it dynamically selects the best model based on the complexity of the task [6]. Depending on the version and environment, the auto alias typically resolves to current standard models, such as gemini-2.5-pro or gemini-3-pro-preview, providing a balance between speed and performance [6][2]. Configuring Project-Specific Defaults You can set a project-specific model by creating a.gemini/settings.json file within your project directory with the following structure [4]: { "model": { "name": "gemini-2.5-flash" } } This allows the CLI to automatically use your preferred model whenever you run commands within that directory [4].
Citations:
- 1: https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/model-routing.md
- 2: https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/cli-reference.md
- 3: https://github.com/google-gemini/gemini-cli/blob/ecf8fba1/docs/get-started/configuration.md
- 4: How to set a default model for a particular project? google-gemini/gemini-cli#5032
- 5: https://gemini-cli-docs.pages.dev/cli/configuration
- 6: https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/model.md
Preserve Gemini’s auto default.
Fresh Gemini launches currently fall back to gemini-3-pro-preview, which overrides the CLI’s documented auto model routing. Add an auto model here and mark it as the default.
| for (const option of model.options) { | ||
| const value = modelValues[option.id] | ||
| if (value === undefined) { | ||
| continue | ||
| } | ||
| if (option.apply.composedIntoModel) { | ||
| if (catalog.modelApply.launchArgs && !modelOverridden) { | ||
| appliedValues[option.id] = value | ||
| } | ||
| continue | ||
| } | ||
| if (!option.apply.launchArgs) { | ||
| continue | ||
| } | ||
| args.push(...option.apply.launchArgs(value)) | ||
| if (!modelOverridden && !option.apply.agentArgsOverride?.(trailingAgentArgs)) { | ||
| appliedValues[option.id] = value |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not emit options for a model overridden by trailing arguments.
When modelOverridden is true, these options still come from the persisted model. For example, a trailing Claude --model haiku can retain the default model’s --effort high, despite that option being unsupported or semantically different. The code also omits it from appliedValues, leaving the cache inconsistent with the command.
Return before this loop when the model is overridden, and add coverage for a trailing model override.
Proposed fix
if (!model) {
return { args, appliedValues }
}
+ if (modelOverridden) {
+ return { args, appliedValues }
+ }
for (const option of model.options) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| for (const option of model.options) { | |
| const value = modelValues[option.id] | |
| if (value === undefined) { | |
| continue | |
| } | |
| if (option.apply.composedIntoModel) { | |
| if (catalog.modelApply.launchArgs && !modelOverridden) { | |
| appliedValues[option.id] = value | |
| } | |
| continue | |
| } | |
| if (!option.apply.launchArgs) { | |
| continue | |
| } | |
| args.push(...option.apply.launchArgs(value)) | |
| if (!modelOverridden && !option.apply.agentArgsOverride?.(trailingAgentArgs)) { | |
| appliedValues[option.id] = value | |
| if (modelOverridden) { | |
| return { args, appliedValues } | |
| } | |
| for (const option of model.options) { | |
| const value = modelValues[option.id] | |
| if (value === undefined) { | |
| continue | |
| } | |
| if (option.apply.composedIntoModel) { | |
| if (catalog.modelApply.launchArgs && !modelOverridden) { | |
| appliedValues[option.id] = value | |
| } | |
| continue | |
| } | |
| if (!option.apply.launchArgs) { | |
| continue | |
| } | |
| args.push(...option.apply.launchArgs(value)) | |
| if (!modelOverridden && !option.apply.agentArgsOverride?.(trailingAgentArgs)) { | |
| appliedValues[option.id] = value |
| agentArgs?: string | null | ||
| agentEnv?: Record<string, string> | null | ||
| agentCommand?: string | null | ||
| sessionOptions?: Record<string, SessionOptionValue> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Seed the resumed session with the provided session options.
The sessionOptions parameter is accepted and passed by callers but is entirely ignored when building the resumed AgentStartupPlan. Although resumed sessions intentionally omit session flags from the CLI args to let the provider restore its own state, omitting sessionOptions from the returned plan prevents the native chat UI from being seeded with its initial known state.
🐛 Proposed fix to thread the session options
return {
agent: args.agent,
launchCommand,
expectedProcess: config.expectedProcess,
followupPrompt: null,
launchConfig,
+ ...(args.sessionOptions ? appliedSessionOptionProps(args.sessionOptions) : {}),
...(args.agentEnv ? { env: { ...args.agentEnv } } : {})
}…9134) #9085 made resolveNativeChatSessionOptionDefaults fall back to the catalog default model (sonnet) and effort (high) whenever the user had not explicitly picked one, injecting `--model sonnet --effort high` (and codex `-m`/`-c` equivalents) onto every agent spawn: composer, worktree activation, source-control agents, onboarding, work-item launch, floating terminal, and new-tab launch. That silently overrode each user's own CLI-configured default model. Return undefined (spawn the agent exactly as its own CLI would) unless the user has explicitly selected a model, and carry only explicitly stored option values. An explicit model selection still applies that model and its catalog option defaults via resolveAgentSessionOptionLaunch.
…mily Orca's Claude picker was a static seed last written in stablyai#9085, so it still offered Opus 4.8 as the newest Opus and had no way to reach the 1M-context variant or the previous-generation models the CLI keeps under "More models". Claude spells 1M context as a `[1m]` suffix on the model id, so it composes into the selected model instead of doubling the list. Previous generations have no alias, so they use their full model ids. Refs stablyai#10812
… Claude switch (stablyai#9085) * Add per-model session-option pickers (model/effort/fast-mode) to native Introduces a shared agent session-option catalog (Claude/Codex/Gemini/Cursor) with model-scoped options, launch-command composition, mid-session dispatch via slash commands, and per-model persisted defaults. Wires the new NativeChatSessionOptionPickers UI into the composer, threads sessionOptions through every startup-plan builder (worktree creation, onboarding, source control actions, folder workspace, direct work-item launches), and adds localized strings and tests across the affected surfaces. * Add per-model session-option pickers with a verified Claude model switch Native chat's model/effort picker now dispatches option commands through a body-then-verified-Enter write path and, for Claude, arms a PTY observer that classifies the cached-history confirmation prompt as applied/rejected/needs interaction before the picker returns — falling back to the terminal only when Claude genuinely requires manual input, and clearing stale truth otherwise. Also reorders the composer's model/effort pills, disambiguates their tooltip labels, and switches disabled-reason strings to a closed enum so producer and localized copy can't drift. * Add live model/effort detection from Claude's TUI header - Reads the mounted xterm's main-buffer snapshot (falling back to the rendered screen when the alternate screen owns the buffer) to parse Claude's header for the currently active model and effort, so the native chat picker reflects reality instead of only dispatched state - Extracts command-apply recording and reported-value application into dedicated modules, and factors file-link click handling into a hook, to keep native-chat-pty-session-options.ts focused
…tablyai#9134) stablyai#9085 made resolveNativeChatSessionOptionDefaults fall back to the catalog default model (sonnet) and effort (high) whenever the user had not explicitly picked one, injecting `--model sonnet --effort high` (and codex `-m`/`-c` equivalents) onto every agent spawn: composer, worktree activation, source-control agents, onboarding, work-item launch, floating terminal, and new-tab launch. That silently overrode each user's own CLI-configured default model. Return undefined (spawn the agent exactly as its own CLI would) unless the user has explicitly selected a model, and carry only explicitly stored option values. An explicit model selection still applies that model and its catalog option defaults via resolveAgentSessionOptionLaunch.
Summary
Native chat can now pick model, effort, and fast-mode per agent session — at compose time and mid-session — instead of being stuck with whatever the agent launched with.
Before this, changing model or effort meant dropping into the terminal (or restarting the agent). The composer now shows per-agent option pickers for Claude, Codex, Gemini, and Cursor; choices persist as defaults, seed launch commands across worktree/onboarding/source-control/folder flows, and can be applied to a live session via slash commands.
Design decisions
sessionOptionsthrough all startup-plan buildersValidation
Unit/component coverage added for the option catalog, launch composition, PTY session-option dispatch, Claude confirmation classification, composer pickers, and locale keys. Manual UI walkthrough was not run in this PR-creation pass.
Test plan