feat(agent-picker): expand legacy models in place instead of a separate list

This commit is contained in:
Brennan Benson
2026-11-11 13:23:35 -08:00
parent 2766957327
commit cf3e922544
15 changed files with 137 additions and 127 deletions
@@ -9,7 +9,8 @@ import {
} from './agent-launch-setup-option-rows'
import { useRef, useState } from 'react'
import { useSetupModelHighlight } from './use-setup-model-highlight'
import { Check, ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react'
import { AgentPickerLegacyModelsToggle } from './AgentPickerLegacyModelsToggle'
import { Check, ChevronDown, ChevronRight } from 'lucide-react'
import { getAgentSessionOptionLaunchCatalog } from '../../../../shared/agent-session/options/agent-session-option-catalog'
import {
Command,
@@ -72,7 +73,7 @@ export function AgentLaunchSetupPanel({
}
}
const [modelQuery, setModelQuery] = useState('')
const [legacy, setLegacy] = useState(false)
const [legacyExpanded, setLegacyExpanded] = useState(false)
const [argumentsOpen, setArgumentsOpen] = useState(entry.defaultSurface === 'terminal')
const argumentsKnown = agentPickerArgumentsKnown(entry, draft)
const effective = agentPickerEffectiveChoices(entry, draft)
@@ -98,7 +99,7 @@ export function AgentLaunchSetupPanel({
models,
currentModel,
modelQuery,
legacy,
legacyExpanded,
modelInArguments
)
const modelList = useRef<HTMLDivElement>(null)
@@ -162,7 +163,28 @@ export function AgentLaunchSetupPanel({
// Launch leaves Permissions and Arguments to Agent settings; select mode edits a saved setup.
const editsDefaults = mode === 'select' && !entry.textGeneration
const note = agentLaunchSetupArgumentsNote(entry.label, options, !seed?.modelApply.cli?.length)
const legacyCount = models.filter((model) => model.isLegacy && !model.hidden).length
const renderModelRow = (model: (typeof modelRows.rows)[number]) => {
const current = model.unlisted || (currentModel === model.id && !modelInArguments)
return (
<CommandItem
key={model.id}
value={model.id}
keywords={[model.label]}
disabled={modelDisabled}
data-current={current}
onSelect={() => {
if (!model.unlisted) {
editDraft({ kind: 'choice', patch: { model: model.id } })
}
}}
>
{model.label}
<span className="ml-auto flex size-3.5 shrink-0 items-center justify-center">
{current ? <Check className="size-3.5 text-muted-foreground" /> : null}
</span>
</CommandItem>
)
}
return (
<div
className="flex w-full flex-col"
@@ -244,47 +266,14 @@ export function AgentLaunchSetupPanel({
modelInArguments={modelInArguments}
onSelect={editDraft}
/>
{legacy && !modelQuery ? (
<CommandItem value="__back__" disabled={disabled} onSelect={() => setLegacy(false)}>
<ChevronLeft className="size-3.5 text-muted-foreground" />
{t('agentPicker.legacyModels', 'Legacy models')}
</CommandItem>
) : null}
{modelRows.rows.map((model) => {
const current = model.unlisted || (currentModel === model.id && !modelInArguments)
return (
<CommandItem
key={model.id}
value={model.id}
keywords={[model.label]}
disabled={modelDisabled}
data-current={current}
onSelect={() => {
if (!model.unlisted) {
editDraft({ kind: 'choice', patch: { model: model.id } })
}
}}
>
{model.label}
<span className="ml-auto flex size-3.5 shrink-0 items-center justify-center">
{current ? <Check className="size-3.5 text-muted-foreground" /> : null}
</span>
</CommandItem>
)
})}
{!legacy && !modelQuery && legacyCount > 0 ? (
<CommandItem value="__legacy__" disabled={disabled} onSelect={() => setLegacy(true)}>
<span className="flex min-w-0 flex-col">
<span>{t('agentPicker.legacyModels', 'Legacy models')}</span>
<span className="text-muted-foreground">
{t('agentPicker.legacyModelCount', '{{total}} models', {
total: legacyCount
})}
</span>
</span>
<ChevronRight className="ml-auto size-3.5 text-muted-foreground" />
</CommandItem>
) : null}
{modelRows.rows.map(renderModelRow)}
<AgentPickerLegacyModelsToggle
total={modelRows.legacyCount}
expanded={legacyExpanded}
disabled={disabled}
onToggle={() => setLegacyExpanded((expanded) => !expanded)}
/>
{modelRows.legacyRows.map(renderModelRow)}
</CommandGroup>
</CommandList>
</Command>
@@ -0,0 +1,38 @@
import { ChevronRight } from 'lucide-react'
import { CommandItem } from '@/components/ui/command'
import { useTranslate } from '@/i18n/use-translate'
import { cn } from '@/lib/class-names'
/** Row that expands the folded legacy models in place, below itself. */
export function AgentPickerLegacyModelsToggle({
total,
expanded,
disabled,
onToggle
}: {
total: number
expanded: boolean
disabled?: boolean
onToggle: () => void
}): React.JSX.Element | null {
const t = useTranslate()
if (total === 0) {
return null
}
return (
<CommandItem
value="__legacy__"
disabled={disabled}
aria-expanded={expanded}
onSelect={onToggle}
>
{t('agentPicker.legacyModelsWithCount', 'Legacy models ({{total}})', { total })}
<ChevronRight
className={cn(
'ml-auto size-3.5 text-muted-foreground transition-transform',
expanded && 'rotate-90'
)}
/>
</CommandItem>
)
}
@@ -268,18 +268,19 @@ export function agentLaunchSetupCatalogState(
return { hasModels, catalogPending, catalogMessage }
}
/** Visible model rows, plus the model the list starts on. */
/** Visible model rows, the expanded legacy rows below their toggle, and the model the list starts on. */
export function agentLaunchSetupModelRows(
models: readonly AgentPickerModel[],
currentModel: string | undefined,
query: string,
legacy: boolean,
legacyExpanded: boolean,
modelInArguments: boolean
) {
const rows: { id: string; label: string; unlisted?: true }[] = models.filter(
(model) =>
!model.hidden && (model.id === currentModel || query || Boolean(model.isLegacy) === legacy)
)
type Row = { id: string; label: string; unlisted?: true }
const listed = models.filter((model) => !model.hidden)
const folded = (model: AgentPickerModel) => !query && model.isLegacy && model.id !== currentModel
const rows: Row[] = listed.filter((model) => !folded(model))
const legacyRows: Row[] = listed.filter(folded)
// Why one keyed list: when the catalog later lists an unlisted current model, its row keeps
// its identity, so the highlight stays on it instead of jumping to the first model.
if (currentModel && !models.some((model) => model.id === currentModel)) {
@@ -288,5 +289,10 @@ export function agentLaunchSetupModelRows(
// An Arguments-owned text action has no current model row, so it starts on its default as before.
const start =
!modelInArguments && rows.some((row) => row.id === currentModel) ? currentModel : undefined
return { rows, start }
return {
rows,
legacyRows: legacyExpanded ? legacyRows : [],
legacyCount: legacyRows.length,
start
}
}
@@ -1,5 +1,5 @@
import { useRef, useState } from 'react'
import { Check, ChevronLeft, ChevronRight } from 'lucide-react'
import { Check } from 'lucide-react'
import {
Command,
CommandEmpty,
@@ -15,6 +15,7 @@ import { nativeChatSessionChoiceLabel } from '../../../../../../../shared/native
import { sayNativeChatSessionOptionTranslated as say } from './native-chat-session-option-labels-text'
import { NativeChatSessionOptionChoiceBody } from './NativeChatSessionOptionChoiceBody'
import { NativeChatSessionOptionWriteGroup } from './NativeChatSessionOptionWriteGroup'
import { AgentPickerLegacyModelsToggle } from '../../../../agent/AgentPickerLegacyModelsToggle'
type NativeChatModelComboboxProps = {
choices: readonly SessionOptionSelectChoice[]
@@ -47,9 +48,39 @@ export function NativeChatModelCombobox({
const searchLabel = t('components.native-chat.composer.searchModels', 'Search models…')
const search = useRef<HTMLInputElement>(null)
const [query, setQuery] = useState('')
const [legacy, setLegacy] = useState(false)
const [legacyExpanded, setLegacyExpanded] = useState(false)
const searching = Boolean(query.trim())
const legacyCount = choices.filter((choice) => choice.legacy).length
const folded = (choice: SessionOptionSelectChoice) =>
!searching && Boolean(choice.legacy) && choice.value !== currentValue
const legacyChoices = choices.filter(folded)
const renderChoice = (choice: SessionOptionSelectChoice) => {
const label = nativeChatSessionChoiceLabel(choice, say)
const current = choice.value === currentValue
return (
<CommandItem
key={choice.value}
value={choice.value}
keywords={[label, choice.description ?? '']}
selection="palette"
disabled={readOnly}
aria-current={current || undefined}
onSelect={() => {
if (!current) {
onSelect(choice.value)
}
}}
>
<NativeChatSessionOptionChoiceBody
label={label}
description={nativeChatModelDescription(choice.value, choice.description, t)}
/>
{/* Reserve the check slot so selecting a model cannot rewrap its label. */}
<span className="ml-auto flex size-3.5 shrink-0 items-center justify-center">
{current ? <Check className="size-3.5 text-muted-foreground" /> : null}
</span>
</CommandItem>
)
}
return (
<Command
surface="inline"
@@ -78,56 +109,13 @@ export function NativeChatModelCombobox({
</CommandEmpty>
<NativeChatSessionOptionWriteGroup busy={busy}>
<CommandGroup>
{legacy && !searching ? (
<CommandItem value="__back__" onSelect={() => setLegacy(false)}>
<ChevronLeft className="size-3.5 text-muted-foreground" />
{t('agentPicker.legacyModels', 'Legacy models')}
</CommandItem>
) : null}
{choices
.filter(
(choice) =>
searching || choice.value === currentValue || Boolean(choice.legacy) === legacy
)
.map((choice) => {
const label = nativeChatSessionChoiceLabel(choice, say)
const current = choice.value === currentValue
return (
<CommandItem
key={choice.value}
value={choice.value}
keywords={[label, choice.description ?? '']}
selection="palette"
disabled={readOnly}
aria-current={current || undefined}
onSelect={() => {
if (!current) {
onSelect(choice.value)
}
}}
>
<NativeChatSessionOptionChoiceBody
label={label}
description={nativeChatModelDescription(choice.value, choice.description, t)}
/>
{/* Reserve the check slot so selecting a model cannot rewrap its label. */}
<span className="ml-auto flex size-3.5 shrink-0 items-center justify-center">
{current ? <Check className="size-3.5 text-muted-foreground" /> : null}
</span>
</CommandItem>
)
})}
{!legacy && !searching && legacyCount > 0 ? (
<CommandItem value="__legacy__" onSelect={() => setLegacy(true)}>
<span className="flex min-w-0 flex-col">
<span>{t('agentPicker.legacyModels', 'Legacy models')}</span>
<span className="text-muted-foreground">
{t('agentPicker.legacyModelCount', '{{total}} models', { total: legacyCount })}
</span>
</span>
<ChevronRight className="ml-auto size-3.5 text-muted-foreground" />
</CommandItem>
) : null}
{choices.filter((choice) => !folded(choice)).map(renderChoice)}
<AgentPickerLegacyModelsToggle
total={legacyChoices.length}
expanded={legacyExpanded}
onToggle={() => setLegacyExpanded((expanded) => !expanded)}
/>
{legacyExpanded ? legacyChoices.map(renderChoice) : null}
</CommandGroup>
</NativeChatSessionOptionWriteGroup>
</CommandList>
+1 -2
View File
@@ -23645,11 +23645,10 @@
"setByArguments": "Durch Argumente festgelegt",
"searchModels": "Modelle suchen",
"noModels": "Keine Modelle entsprechen deiner Suche.",
"legacyModels": "Ältere Modelle",
"toggleArguments": "Argumente ein-/ausblenden",
"argumentsTerminalHint": "Gilt nur für Terminalstarts (CLI)",
"searchAgentModels": "{{agent}}-Modelle suchen…",
"legacyModelCount": "{{total}} Modelle",
"legacyModelsWithCount": "Ältere Modelle ({{total}})",
"search": "Suchen, z. B. Opus 5.5…",
"configure": "{{agent}} konfigurieren",
"arguments": "Argumente",
+1 -2
View File
@@ -24726,13 +24726,12 @@
"setByArguments": "Set by your Arguments",
"searchModels": "Search models",
"noModels": "No models match your search.",
"legacyModels": "Legacy models",
"toggleArguments": "Toggle Arguments",
"argumentsTerminalHint": "Only applies to terminal (CLI) launches",
"chatChoicesNote": "{{agent}} model or effort choices without a CLI flag apply to chats.",
"composedChoicesNote": "{{agent}} effort and speed choices are included in the model argument.",
"searchAgentModels": "Search {{agent}} models…",
"legacyModelCount": "{{total}} models",
"legacyModelsWithCount": "Legacy models ({{total}})",
"use": "Use",
"select": "Select agent",
"promptPlaceholder": "Add a prompt (optional): / for skills, @ for files",
+1 -2
View File
@@ -23538,11 +23538,10 @@
"setByArguments": "Definido por tus argumentos",
"searchModels": "Buscar modelos",
"noModels": "Ningún modelo coincide con tu búsqueda.",
"legacyModels": "Modelos antiguos",
"toggleArguments": "Mostrar u ocultar argumentos",
"argumentsTerminalHint": "Solo se aplica a los lanzamientos en terminal (CLI)",
"searchAgentModels": "Buscar modelos de {{agent}}…",
"legacyModelCount": "{{total}} modelos",
"legacyModelsWithCount": "Modelos antiguos ({{total}})",
"use": "Usar",
"select": "Seleccionar agente",
"promptPlaceholder": "Agregar un prompt (opcional): / para skills, @ para archivos",
+1 -2
View File
@@ -23561,11 +23561,10 @@
"setByArguments": "Défini par vos arguments",
"searchModels": "Rechercher des modèles",
"noModels": "Aucun modèle ne correspond à votre recherche.",
"legacyModels": "Anciens modèles",
"toggleArguments": "Afficher ou masquer les arguments",
"argumentsTerminalHint": "S’applique uniquement aux lancements dans le terminal (CLI)",
"searchAgentModels": "Rechercher des modèles {{agent}}…",
"legacyModelCount": "{{total}} modèles",
"legacyModelsWithCount": "Anciens modèles ({{total}})",
"use": "Utiliser",
"select": "Choisir un agent",
"promptPlaceholder": "Ajouter un prompt (facultatif) : / pour les skills, @ pour les fichiers",
+1 -2
View File
@@ -22858,11 +22858,10 @@
"setByArguments": "引数で設定",
"searchModels": "モデルを検索",
"noModels": "検索に一致するモデルがありません。",
"legacyModels": "旧モデル",
"toggleArguments": "引数の表示を切り替え",
"argumentsTerminalHint": "ターミナル(CLI)からの起動にのみ適用",
"searchAgentModels": "{{agent}} のモデルを検索…",
"legacyModelCount": "{{total}} 個のモデル",
"legacyModelsWithCount": "旧モデル ({{total}})",
"use": "使用",
"select": "Agent を選択",
"promptPlaceholder": "プロンプトを追加 (オプション): / でスキル、@ でファイル",
+1 -2
View File
@@ -22850,11 +22850,10 @@
"setByArguments": "인수로 설정됨",
"searchModels": "모델 검색",
"noModels": "검색과 일치하는 모델이 없습니다.",
"legacyModels": "이전 모델",
"toggleArguments": "인수 표시 전환",
"argumentsTerminalHint": "터미널(CLI) 실행에만 적용",
"searchAgentModels": "{{agent}} 모델 검색…",
"legacyModelCount": "모델 {{total}}개",
"legacyModelsWithCount": "이전 모델 ({{total}})",
"use": "사용",
"select": "에이전트 선택",
"promptPlaceholder": "프롬프트 추가(선택사항): 스킬은 /, 파일은 @",
+1 -2
View File
@@ -24114,11 +24114,10 @@
"setByArguments": "Definido pelos seus argumentos",
"searchModels": "Pesquisar modelos",
"noModels": "Nenhum modelo corresponde à pesquisa.",
"legacyModels": "Modelos antigos",
"toggleArguments": "Mostrar ou ocultar argumentos",
"argumentsTerminalHint": "Aplica-se apenas a inicializações no terminal (CLI)",
"searchAgentModels": "Pesquisar modelos de {{agent}}…",
"legacyModelCount": "{{total}} modelos",
"legacyModelsWithCount": "Modelos antigos ({{total}})",
"use": "Usar",
"select": "Selecionar agente",
"promptPlaceholder": "Adicione um prompt (opcional): / para skills, @ para arquivos",
+1 -2
View File
@@ -24386,11 +24386,10 @@
"setByArguments": "Задано аргументами",
"searchModels": "Поиск моделей",
"noModels": "Нет моделей, соответствующих запросу.",
"legacyModels": "Устаревшие модели",
"toggleArguments": "Показать или скрыть аргументы",
"argumentsTerminalHint": "Применяется только при запуске в терминале (CLI)",
"searchAgentModels": "Поиск моделей {{agent}}…",
"legacyModelCount": "Моделей: {{total}}",
"legacyModelsWithCount": "Устаревшие модели ({{total}})",
"search": "Поиск, например Opus 5.5…",
"configure": "Настроить {{agent}}",
"arguments": "Аргументы",
+1 -2
View File
@@ -23615,11 +23615,10 @@
"setByArguments": "Argümanlarınızla ayarlandı",
"searchModels": "Modelleri ara",
"noModels": "Aramanızla eşleşen model yok.",
"legacyModels": "Eski modeller",
"toggleArguments": "Argümanları göster veya gizle",
"argumentsTerminalHint": "Yalnızca terminal (CLI) başlatmaları için geçerlidir",
"searchAgentModels": "{{agent}} modellerini ara…",
"legacyModelCount": "{{total}} model",
"legacyModelsWithCount": "Eski modeller ({{total}})",
"search": "Ara, ör. Opus 5.5…",
"configure": "{{agent}} yapılandır",
"arguments": "Argümanlar",
+1 -2
View File
@@ -23311,11 +23311,10 @@
"setByArguments": "由引數設定",
"searchModels": "搜尋模型",
"noModels": "沒有符合搜尋條件的模型。",
"legacyModels": "舊版模型",
"toggleArguments": "切換引數顯示",
"argumentsTerminalHint": "僅適用於終端機(CLI)啟動",
"searchAgentModels": "搜尋 {{agent}} 模型…",
"legacyModelCount": "{{total}} 個模型",
"legacyModelsWithCount": "舊版模型 ({{total}})",
"search": "搜尋,例如 Opus 5.5…",
"configure": "設定 {{agent}}",
"arguments": "引數",
+1 -2
View File
@@ -23198,11 +23198,10 @@
"setByArguments": "由参数设置",
"searchModels": "搜索模型",
"noModels": "没有与搜索匹配的模型。",
"legacyModels": "旧版模型",
"toggleArguments": "切换参数显示",
"argumentsTerminalHint": "仅适用于终端(CLI)启动",
"searchAgentModels": "搜索 {{agent}} 模型…",
"legacyModelCount": "{{total}} 个模型",
"legacyModelsWithCount": "旧版模型 ({{total}})",
"use": "使用",
"select": "选择智能体",
"promptPlaceholder": "添加提示词(可选):/ 选择技能,@ 选择文件",