Skip to content

feat(native-chat): add per-model session option pickers with verified Claude switch - #9085

Merged
AmethystLiang merged 3 commits into
mainfrom
add-model-picker-effort-picker-for-native-chat
Jul 17, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
add-model-picker-effort-picker-for-native-chat

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

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

Decision Why
Shared session-option catalog One source of truth for which options each agent supports, so launch-time flags and mid-session commands stay aligned
Persist defaults per model family Reopening the composer restores the last choice without re-picking every session
Thread sessionOptions through all startup-plan builders New worktrees, onboarding, source-control actions, folder workspaces, and direct work-item launches all start with the same selected options
Verified Claude model switch Claude’s cached-history confirmation can accept or reject a model change; the picker writes the command, classifies the PTY prompt as applied/rejected/needs interaction, and only falls back to the terminal when manual input is required
Closed enum for disabled reasons Producer code and localized copy can’t drift when a picker is disabled

Validation

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

  • Open native chat with Claude/Codex/Gemini/Cursor and confirm model/effort (and fast-mode where supported) pickers appear with correct options
  • Change options before launch and verify the agent starts with the selected model/effort
  • Mid-session: change model/effort on a running session; for Claude, confirm silent apply when history confirmation auto-resolves, and terminal fallback only when interaction is required
  • Confirm persisted defaults restore after closing/reopening the composer
  • Smoke worktree create, onboarding folder start, source-control agent action, and direct work-item launch all honor session options

Compound Engineering
Grok

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.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and validation, but it misses the required Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, including screenshots or no visual change, the testing checklist, AI review report, security audit, and notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 4.17% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: per-model session option pickers and verified Claude model switching.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- 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
@AmethystLiang
AmethystLiang merged commit 5b75a87 into main Jul 17, 2026
1 check failed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Keep 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

📥 Commits

Reviewing files that changed from the base of the PR and between dd0f4c3 and 1a69b66.

📒 Files selected for processing (70)
  • src/main/persistence.test.ts
  • src/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsx
  • src/renderer/src/components/native-chat/NativeChatComposer.test.tsx
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx
  • src/renderer/src/components/native-chat/NativeChatComposerActions.tsx
  • src/renderer/src/components/native-chat/NativeChatComposerField.tsx
  • src/renderer/src/components/native-chat/NativeChatSessionOptionPickers.test.tsx
  • src/renderer/src/components/native-chat/NativeChatSessionOptionPickers.tsx
  • src/renderer/src/components/native-chat/NativeChatView.tsx
  • src/renderer/src/components/native-chat/claude-model-switch-confirmation.test.ts
  • src/renderer/src/components/native-chat/claude-model-switch-confirmation.ts
  • src/renderer/src/components/native-chat/claude-terminal-session-options.test.ts
  • src/renderer/src/components/native-chat/claude-terminal-session-options.ts
  • src/renderer/src/components/native-chat/native-chat-pty-session-options.test.ts
  • src/renderer/src/components/native-chat/native-chat-pty-session-options.ts
  • src/renderer/src/components/native-chat/native-chat-runtime-send.test.ts
  • src/renderer/src/components/native-chat/native-chat-runtime-send.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-cache.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-command-builder.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-command-dispatch.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-command-matching.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-command-recording.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-discovery.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-labels.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-reporting.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-snapshot.ts
  • src/renderer/src/components/native-chat/use-native-chat-dictation-actions.ts
  • src/renderer/src/components/native-chat/use-native-chat-file-attachment-actions.ts
  • src/renderer/src/components/native-chat/use-native-chat-file-link-click.ts
  • src/renderer/src/components/native-chat/use-native-chat-session-option-command.ts
  • src/renderer/src/components/native-chat/use-native-chat-session-options.ts
  • src/renderer/src/components/onboarding/onboarding-folder-agent-startup.test.ts
  • src/renderer/src/components/right-sidebar/buildSourceControlAgentDeliveryPlan.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/native-chat-locales.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/lib/launch-work-item-direct-agent.ts
  • src/renderer/src/lib/launch-work-item-direct.test.ts
  • src/renderer/src/lib/onboarding-folder-agent-startup.ts
  • src/renderer/src/lib/source-control-agent-action-plan.ts
  • src/renderer/src/lib/worktree-activation-created-agent.test.ts
  • src/renderer/src/lib/worktree-activation.ts
  • src/renderer/src/lib/worktree-creation-flow.ts
  • src/renderer/src/runtime/runtime-terminal-stream.test.ts
  • src/renderer/src/runtime/runtime-terminal-stream.ts
  • src/renderer/src/store/slices/repos-onboarding-folder-startup.test.ts
  • src/shared/agent-session-option-catalog-claude-codex.ts
  • src/shared/agent-session-option-catalog-gemini-cursor.ts
  • src/shared/agent-session-option-catalog-types.ts
  • src/shared/agent-session-option-catalog.test.ts
  • src/shared/agent-session-option-catalog.ts
  • src/shared/agent-session-option-launch.ts
  • src/shared/constants.ts
  • src/shared/native-chat-session-option-defaults.ts
  • src/shared/native-chat-session-options.ts
  • src/shared/tui-agent-launch-command.ts
  • src/shared/tui-agent-startup-session-options.test.ts
  • src/shared/tui-agent-startup.ts
  • src/shared/types.ts

Comment on lines +126 to +129
const persist = (modelId: string | null, optionId: string, value: SessionOptionValue): void => {
if (modelId) {
void args.persistSelection?.({ modelId, optionId, value })
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.

Comment on lines +22 to +25
const worktreeId =
Object.entries(state.tabsByWorktree ?? {}).find(([, tabs]) =>
tabs.some((tab) => tab.id === terminalTabId)
)?.[0] ?? null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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] ?? null

Based 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.

Suggested change
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

Comment on lines +42 to +61
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
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

Suggested change
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
}
}

Comment on lines 273 to +284
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
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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 -S

Repository: 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 -S

Repository: 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.

Comment on lines +17 to +23
const pickAttachment = useCallback(() => {
void (async () => {
const filePath = await window.api.shell.pickAttachment()
if (filePath) {
attachExternalPaths([filePath])
}
})()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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])

Comment on lines +50 to +78
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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.

Comment on lines +45 to +46
for (const key of ['fast', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'] as const) {
expect(composer.optionValue[key]).not.toBe(englishComposer.optionValue[key])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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])

Comment on lines +18 to +24
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: [] }
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.ts

Repository: 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:


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.

Comment on lines +44 to +60
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 } } : {})
   }

brennanb2025 added a commit that referenced this pull request Jul 17, 2026
…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.
Lunivo pushed a commit to Lunivo/orca that referenced this pull request Aug 3, 2026
…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
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… 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
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant