mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 19:34:29 +00:00
feat(agent-picker): fold legacy models the same way in every model picker
Claude aliases whose versioned model is listed, and Codex models superseded in their family or by a newer major line, fold under Legacy models in the agent launch picker, text-generation pickers, and native chat on desktop and mobile. The default and current model always stay listed.
This commit is contained in:
@@ -222,9 +222,9 @@ export function descriptorRowElements(
|
||||
/>
|
||||
)
|
||||
// No search here: search-only aliases follow a More models toggle, as compact pickers show them.
|
||||
const more = moreChoices ? choices.filter((choice) => choice.searchOnly) : []
|
||||
const more = moreChoices ? choices.filter((choice) => choice.legacy) : []
|
||||
return [
|
||||
...choices.filter((choice) => !choice.searchOnly).map(choiceRow),
|
||||
...choices.filter((choice) => !choice.legacy).map(choiceRow),
|
||||
...(more.length > 0 && moreChoices
|
||||
? [
|
||||
<ListRow
|
||||
|
||||
@@ -34,6 +34,7 @@ it('uses the shared AI-author picker without saving on cancel and preserves Cust
|
||||
ctrlKey: false
|
||||
})
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Configure Codex' }))
|
||||
fireEvent.click(screen.getByRole('option', { name: /^Legacy models/ }))
|
||||
fireEvent.click(screen.getByRole('option', { name: 'GPT-5.4' }))
|
||||
fireEvent.keyDown(screen.getByLabelText('Search models'), { key: 'Escape' })
|
||||
fireEvent.keyDown(screen.getByPlaceholderText('Search, e.g. Opus 5.5…'), {
|
||||
@@ -48,6 +49,7 @@ it('uses the shared AI-author picker without saving on cancel and preserves Cust
|
||||
ctrlKey: false
|
||||
})
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Configure Codex' }))
|
||||
fireEvent.click(screen.getByRole('option', { name: /^Legacy models/ }))
|
||||
fireEvent.click(screen.getByRole('option', { name: 'GPT-5.4' }))
|
||||
fireEvent.click(screen.getByRole('radio', { name: 'Low' }))
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Use$/ }))
|
||||
|
||||
+25
-2
@@ -1,5 +1,5 @@
|
||||
import { useRef, useState } from 'react'
|
||||
import { Check } from 'lucide-react'
|
||||
import { Check, ChevronLeft, ChevronRight } from 'lucide-react'
|
||||
import {
|
||||
Command,
|
||||
CommandEmpty,
|
||||
@@ -47,6 +47,9 @@ 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 searching = Boolean(query.trim())
|
||||
const legacyCount = choices.filter((choice) => choice.legacy).length
|
||||
return (
|
||||
<Command
|
||||
surface="inline"
|
||||
@@ -75,8 +78,17 @@ 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) => !choice.searchOnly || query.trim())
|
||||
.filter(
|
||||
(choice) =>
|
||||
searching || choice.value === currentValue || Boolean(choice.legacy) === legacy
|
||||
)
|
||||
.map((choice) => {
|
||||
const label = nativeChatSessionChoiceLabel(choice, say)
|
||||
const current = choice.value === currentValue
|
||||
@@ -105,6 +117,17 @@ export function NativeChatModelCombobox({
|
||||
</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}
|
||||
</CommandGroup>
|
||||
</NativeChatSessionOptionWriteGroup>
|
||||
</CommandList>
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
} from '../permissions/tui-agent-permission-choice'
|
||||
import type { TuiAgent } from '../catalog/tui-agent'
|
||||
import type { AgentPickerEntry, AgentPickerModel, AgentPickerSurface } from './agent-launch-picker'
|
||||
import { legacyAgentModelIds } from '../../legacy-agent-models'
|
||||
|
||||
type ModelMenuEntry = Pick<AgentPickerEntry, 'agent' | 'catalog'> &
|
||||
Partial<
|
||||
@@ -142,13 +143,16 @@ export function agentPickerModels(
|
||||
): AgentPickerModel[] {
|
||||
if (!agentPickerUsesComposerModelMenu(entry, surface)) {
|
||||
if (entry.catalog.origin !== 'unknown') {
|
||||
return entry.catalog.models
|
||||
return withLegacyModels(entry.agent, entry.catalog.models)
|
||||
}
|
||||
return (getAgentSessionOptionLaunchCatalog(entry.agent)?.models ?? []).map(
|
||||
agentPickerModelFromCatalogModel
|
||||
return withLegacyModels(
|
||||
entry.agent,
|
||||
(getAgentSessionOptionLaunchCatalog(entry.agent)?.models ?? []).map(
|
||||
agentPickerModelFromCatalogModel
|
||||
)
|
||||
)
|
||||
}
|
||||
return agentPickerModelMenu(entry, surface).rows
|
||||
return withLegacyModels(entry.agent, agentPickerModelMenu(entry, surface).rows)
|
||||
}
|
||||
|
||||
/** Terminal discovery is a separate change; these menus keep their existing catalog policy. */
|
||||
@@ -170,3 +174,10 @@ export function agentPickerModelFromCatalogModel(model: CatalogModel): AgentPick
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function withLegacyModels(agent: TuiAgent, models: AgentPickerModel[]): AgentPickerModel[] {
|
||||
const legacy = legacyAgentModelIds(agent, models)
|
||||
return legacy.size
|
||||
? models.map((model) => (legacy.has(model.id) ? { ...model, isLegacy: true } : model))
|
||||
: models
|
||||
}
|
||||
|
||||
@@ -215,6 +215,7 @@ function modelOptionSnapshot(state: StructuredAgentSessionOptionState): SessionO
|
||||
models.length === 0
|
||||
? []
|
||||
: nativeChatSessionOptionDescriptors({
|
||||
agent: state.record.agent,
|
||||
catalog,
|
||||
models,
|
||||
mode: 'live',
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { legacyAgentModelIds } from './legacy-agent-models'
|
||||
|
||||
type Row = { id: string; isDefault?: boolean; resolvedModel?: string }
|
||||
const legacy = (agent: string, models: Row[]) => [...legacyAgentModelIds(agent, models)]
|
||||
|
||||
describe('legacyAgentModelIds', () => {
|
||||
it('folds Codex models superseded in their family or by a newer major line', () => {
|
||||
const models: Row[] = [
|
||||
{ id: 'gpt-6.1-sol' },
|
||||
{ id: 'gpt-6-astra' },
|
||||
{ id: 'gpt-6-sol' },
|
||||
{ id: 'gpt-6-luna' },
|
||||
{ id: 'gpt-5.6-sol' },
|
||||
{ id: 'gpt-5.6-terra', isDefault: true },
|
||||
{ id: 'gpt-daybreak-blue-latest' }
|
||||
]
|
||||
expect(legacy('codex', models)).toEqual(['gpt-6-sol', 'gpt-5.6-sol'])
|
||||
})
|
||||
|
||||
it('folds Claude aliases whose versioned model is listed', () => {
|
||||
const live: Row[] = [
|
||||
{ id: 'claude-fable-5', resolvedModel: 'claude-fable-5' },
|
||||
{ id: 'fable', resolvedModel: 'claude-fable-5' },
|
||||
{ id: 'opusplan', resolvedModel: 'claude-opus-5-5' }
|
||||
]
|
||||
expect(legacy('claude', live)).toEqual(['fable'])
|
||||
const saved: Row[] = [
|
||||
{ id: 'claude-opus-5-5[1m]' },
|
||||
{ id: 'opus[1m]' },
|
||||
{ id: 'opus' },
|
||||
{ id: 'sonnet' }
|
||||
]
|
||||
expect(legacy('claude', saved)).toEqual(['opus[1m]'])
|
||||
})
|
||||
|
||||
it('leaves other agents untouched', () => {
|
||||
expect(legacy('grok', [{ id: 'grok-4.5' }, { id: 'grok-4.6' }])).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,77 @@
|
||||
type ListedModel = { id: string; resolvedModel?: string | null; isDefault?: boolean }
|
||||
|
||||
const VERSIONED_MODEL_ID = /^([a-z]+)-(\d+(?:\.\d+)*)(?:-([a-z][a-z0-9-]*))?$/
|
||||
const CLAUDE_ALIAS_ID = /^([a-z]+)(\[1m\])?$/
|
||||
const CLAUDE_VERSIONED_ID = /^claude-([a-z]+)-\d[\d-]*(\[1m\])?$/
|
||||
|
||||
type VersionedModelId = { prefix: string; version: number[]; family: string }
|
||||
|
||||
function versionedModelId(id: string): VersionedModelId | null {
|
||||
const match = VERSIONED_MODEL_ID.exec(id)
|
||||
return match
|
||||
? { prefix: match[1], version: match[2].split('.').map(Number), family: match[3] ?? '' }
|
||||
: null
|
||||
}
|
||||
|
||||
function compareVersions(left: readonly number[], right: readonly number[]): number {
|
||||
for (let index = 0; index < Math.max(left.length, right.length); index++) {
|
||||
const difference = (left[index] ?? 0) - (right[index] ?? 0)
|
||||
if (difference !== 0) {
|
||||
return difference
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Superseded within its family (6-sol by 6.1-sol), or from an older major line than the newest listed.
|
||||
function isSupersededCodexModel(id: string, models: readonly ListedModel[]): boolean {
|
||||
const own = versionedModelId(id)
|
||||
if (!own) {
|
||||
return false
|
||||
}
|
||||
return models.some((row) => {
|
||||
const other = versionedModelId(row.id)
|
||||
if (!other || other.prefix !== own.prefix) {
|
||||
return false
|
||||
}
|
||||
return other.family === own.family
|
||||
? compareVersions(other.version, own.version) > 0
|
||||
: other.version[0] > own.version[0]
|
||||
})
|
||||
}
|
||||
|
||||
// Proven by the row naming the versioned model it runs, or, where a saved list or older host
|
||||
// dropped that, by a versioned row of the same family (opus beside claude-opus-5-5).
|
||||
function isCoveredClaudeAlias(model: ListedModel, models: readonly ListedModel[]): boolean {
|
||||
const resolved = model.resolvedModel
|
||||
if (resolved && resolved !== model.id) {
|
||||
return models.some((row) => row.id === resolved && row.resolvedModel === resolved)
|
||||
}
|
||||
const alias = CLAUDE_ALIAS_ID.exec(model.id)
|
||||
return (
|
||||
!!alias &&
|
||||
models.some((row) => {
|
||||
const versioned = CLAUDE_VERSIONED_ID.exec(row.id)
|
||||
return !!versioned && versioned[1] === alias[1] && versioned[2] === alias[2]
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/** Rows every model picker folds under Legacy models; the default and unrecognized ids stay listed. */
|
||||
export function legacyAgentModelIds(agent: string, models: readonly ListedModel[]): Set<string> {
|
||||
const legacy = new Set<string>()
|
||||
if (agent !== 'claude' && agent !== 'codex') {
|
||||
return legacy
|
||||
}
|
||||
for (const model of models) {
|
||||
if (
|
||||
!model.isDefault &&
|
||||
(agent === 'claude'
|
||||
? isCoveredClaudeAlias(model, models)
|
||||
: isSupersededCodexModel(model.id, models))
|
||||
) {
|
||||
legacy.add(model.id)
|
||||
}
|
||||
}
|
||||
return legacy
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
type ListedRow = { id: string; resolvedModel?: string | null }
|
||||
|
||||
/** An alias row whose versioned row the same list holds: reachable by search, not listed beside it.
|
||||
* Only a row naming itself as the model it runs counts; a chat's stand-in row for its own id does not. */
|
||||
export function isCoveredModelAlias(model: ListedRow, models: readonly ListedRow[]): boolean {
|
||||
const resolved = model.resolvedModel
|
||||
return (
|
||||
!!resolved &&
|
||||
resolved !== model.id &&
|
||||
models.some((row) => row.id === resolved && row.resolvedModel === resolved)
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AGENT_CHAT_PERMISSION_MODE_OPTION_ID } from '../../agent-launch/permissions/agent-chat-permission-mode'
|
||||
import { labelFromModelId } from '../../model-id-label'
|
||||
import { isCoveredModelAlias } from '../../model-alias-rows'
|
||||
import { legacyAgentModelIds } from '../../legacy-agent-models'
|
||||
import type {
|
||||
AgentSessionOptionCatalog,
|
||||
CatalogMidSessionApply,
|
||||
@@ -215,6 +215,7 @@ export type NativeChatShownModel = {
|
||||
/** The model descriptor, then the controls that apply, each showing the chat's value for it.
|
||||
* Values and controls arrive apart, so a caller decides which model's controls apply. */
|
||||
export function nativeChatSessionOptionDescriptors(args: {
|
||||
agent: string
|
||||
catalog: AgentSessionOptionCatalog
|
||||
models: readonly CatalogModel[]
|
||||
mode: NativeChatSessionOptionMode
|
||||
@@ -225,16 +226,15 @@ export function nativeChatSessionOptionDescriptors(args: {
|
||||
values: Readonly<Record<string, TrackedNativeChatSessionOption | undefined>>
|
||||
modelIsCliDefault: boolean
|
||||
}): SessionOptionDescriptor[] {
|
||||
const { catalog, models, mode, modelLabel, liveTransport, model } = args
|
||||
const { agent, catalog, models, mode, modelLabel, liveTransport, model } = args
|
||||
// Callers reconcile tracked models into choices first; the trigger must never show an unlisted selection.
|
||||
// An alias whose versioned row is listed stays reachable by search, unless the chat is on it.
|
||||
const modelChoices = models.map(({ id, label, description, resolvedModel }) => ({
|
||||
// Legacy rows fold away like the launch picker's, unless the chat is on one.
|
||||
const legacy = legacyAgentModelIds(agent, models)
|
||||
const modelChoices = models.map(({ id, label, description }) => ({
|
||||
value: id,
|
||||
label,
|
||||
...(description ? { description } : {}),
|
||||
...(id !== model.currentId && isCoveredModelAlias({ id, resolvedModel }, models)
|
||||
? { searchOnly: true as const }
|
||||
: {})
|
||||
...(id !== model.currentId && legacy.has(id) ? { legacy: true as const } : {})
|
||||
}))
|
||||
const modelAction = actionForApply(catalog.modelApply, model.tracked, mode, liveTransport)
|
||||
const snapshot: SessionOptionDescriptor[] = [
|
||||
@@ -289,6 +289,7 @@ export function buildNativeChatSessionOptionSnapshot(args: {
|
||||
const model = models.find((candidate) => candidate.id === effectiveModelId)
|
||||
return nativeChatSessionOptionDescriptors({
|
||||
...args,
|
||||
agent: record.agent,
|
||||
model: {
|
||||
currentId: effectiveModelId,
|
||||
valueSource: record.model?.source ?? (defaultModelId ? 'default' : 'unknown'),
|
||||
|
||||
@@ -6,8 +6,8 @@ export type SessionOptionSelectChoice = {
|
||||
value: string
|
||||
label: string
|
||||
description?: string
|
||||
/** An alias of a listed versioned row: listed only for a matching search. */
|
||||
searchOnly?: true
|
||||
/** Folded under Legacy models; a matching search still lists it. */
|
||||
legacy?: true
|
||||
}
|
||||
|
||||
/** default describes catalog display, never running-agent evidence. dispatched is sent but unread and may be corrected by reports.
|
||||
|
||||
Reference in New Issue
Block a user