Skip to content

Commit 6df0885

Browse files
lurunziclaude
andcommitted
feat(native-chat): split CLI-listed effort tiers into model and effort pickers
Antigravity lists every effort tier as its own model id ("Gemini 3.1 Pro (High)"), so the model dropdown showed one row per tier. The picker now collapses tier siblings that share a base label into one model row and adds an effort pill listing only that model's tiers. The ids stay the switch values, so launch, persistence and `/model <id>` are unchanged. Switching models keeps the current tier when the target offers it, else takes its first listed tier. Single-tier models keep their full label. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 4f457a9 commit 6df0885

6 files changed

Lines changed: 389 additions & 95 deletions
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import {
2+
DropdownMenu,
3+
DropdownMenuContent,
4+
DropdownMenuLabel,
5+
DropdownMenuRadioGroup,
6+
DropdownMenuRadioItem
7+
} from '@/components/ui/dropdown-menu'
8+
import { translate } from '@/i18n/i18n'
9+
import type { SessionOptionDescriptor } from '../../../../shared/native-chat-session-options'
10+
import { ChoiceBody, PickerTrigger } from './NativeChatPickerTrigger'
11+
import {
12+
tieredRowTargetValue,
13+
type ModelPickerRow,
14+
type ModelTierChoice
15+
} from './native-chat-model-tier-groups'
16+
import { nativeChatSessionChoiceLabel } from './native-chat-session-option-labels'
17+
18+
type TieredRow = Extract<ModelPickerRow, { kind: 'tiered' }>
19+
20+
function tierChoiceLabel(tier: ModelTierChoice): string {
21+
return nativeChatSessionChoiceLabel({ value: tier.tier, label: tier.tierLabel })
22+
}
23+
24+
/** Model rows where tier siblings collapse into one row; the tier pill picks among them. */
25+
export function ModelTierMenuRows(props: {
26+
rows: readonly ModelPickerRow[]
27+
currentValue: string | undefined
28+
currentTier: string | null
29+
disabled: boolean
30+
setValue: (value: string) => void
31+
}): React.JSX.Element {
32+
return (
33+
<DropdownMenuRadioGroup
34+
aria-label={translate('components.native-chat.composer.model', 'Model')}
35+
value={props.currentValue}
36+
onValueChange={props.setValue}
37+
>
38+
{props.rows.map((row) => {
39+
const value =
40+
row.kind === 'model' ? row.choice.value : tieredRowTargetValue(row, props.currentTier)
41+
return (
42+
<DropdownMenuRadioItem key={value} value={value} disabled={props.disabled}>
43+
<ChoiceBody
44+
label={
45+
row.kind === 'model' ? nativeChatSessionChoiceLabel(row.choice) : row.baseLabel
46+
}
47+
description={row.kind === 'model' ? row.choice.description : undefined}
48+
/>
49+
</DropdownMenuRadioItem>
50+
)
51+
})}
52+
</DropdownMenuRadioGroup>
53+
)
54+
}
55+
56+
export function ModelTierPicker(props: {
57+
model: SessionOptionDescriptor
58+
row: TieredRow
59+
currentValue: string
60+
pending: boolean
61+
queued: boolean
62+
disabledReason: string | null
63+
dispatched: boolean
64+
setValue: (value: string) => void
65+
}): React.JSX.Element {
66+
const current = props.row.tiers.find((tier) => tier.value === props.currentValue)
67+
const title = translate('components.native-chat.composer.effort', 'Effort')
68+
return (
69+
<DropdownMenu>
70+
<PickerTrigger
71+
label={current ? tierChoiceLabel(current) : title}
72+
tooltipLabel={title}
73+
disabled={props.pending}
74+
disabledReason={props.disabledReason}
75+
dispatched={props.dispatched}
76+
queued={props.queued}
77+
/>
78+
<DropdownMenuContent align="start" side="top" collisionPadding={8} className="w-60">
79+
<DropdownMenuLabel>{title}</DropdownMenuLabel>
80+
<DropdownMenuRadioGroup
81+
aria-label={title}
82+
value={props.currentValue}
83+
onValueChange={props.setValue}
84+
>
85+
{props.row.tiers.map((tier) => (
86+
<DropdownMenuRadioItem
87+
key={tier.value}
88+
value={tier.value}
89+
disabled={!props.model.settable || props.pending}
90+
>
91+
<ChoiceBody label={tierChoiceLabel(tier)} />
92+
</DropdownMenuRadioItem>
93+
))}
94+
</DropdownMenuRadioGroup>
95+
</DropdownMenuContent>
96+
</DropdownMenu>
97+
)
98+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { ChevronDown } from 'lucide-react'
2+
import { Button } from '@/components/ui/button'
3+
import { DropdownMenuTrigger } from '@/components/ui/dropdown-menu'
4+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
5+
import { translate } from '@/i18n/i18n'
6+
7+
function PickerTooltipContent(props: {
8+
label: string
9+
disabledReason?: string | null
10+
dispatched: boolean
11+
queued: boolean
12+
}): React.JSX.Element {
13+
return (
14+
<div className="space-y-0.5">
15+
<div>{props.disabledReason ?? props.label}</div>
16+
{props.queued ? (
17+
<div>
18+
{translate('components.native-chat.composer.appliesNextTurn', 'Applies after this turn')}
19+
</div>
20+
) : null}
21+
{props.dispatched ? (
22+
<div>
23+
{translate(
24+
'components.native-chat.composer.sentNotConfirmed',
25+
'Sent to the agent — not confirmed'
26+
)}
27+
</div>
28+
) : null}
29+
</div>
30+
)
31+
}
32+
33+
export function PickerTrigger(props: {
34+
label: string
35+
tooltipLabel: string
36+
disabled: boolean
37+
disabledReason?: string | null
38+
dispatched: boolean
39+
queued: boolean
40+
}): React.JSX.Element {
41+
// Why: value-only visible text must still include the category in the
42+
// accessible name (WCAG 2.5.3 Label in Name / voice control).
43+
const accessibleName =
44+
props.label === props.tooltipLabel
45+
? props.tooltipLabel
46+
: translate('components.native-chat.composer.pillAccessibleName', '{{value0}} {{value1}}', {
47+
value0: props.tooltipLabel,
48+
value1: props.label
49+
})
50+
return (
51+
<Tooltip>
52+
<TooltipTrigger asChild>
53+
<DropdownMenuTrigger asChild disabled={props.disabled}>
54+
<Button
55+
type="button"
56+
variant="ghost"
57+
size="xs"
58+
aria-label={accessibleName}
59+
className="max-w-48 text-muted-foreground"
60+
>
61+
<span className="truncate">{props.label}</span>
62+
<ChevronDown className="size-3" />
63+
</Button>
64+
</DropdownMenuTrigger>
65+
</TooltipTrigger>
66+
<TooltipContent side="top" sideOffset={4}>
67+
<PickerTooltipContent
68+
label={props.tooltipLabel}
69+
disabledReason={props.disabledReason}
70+
dispatched={props.dispatched}
71+
queued={props.queued}
72+
/>
73+
</TooltipContent>
74+
</Tooltip>
75+
)
76+
}
77+
78+
export function ChoiceBody(props: { label: string; description?: string }): React.JSX.Element {
79+
return (
80+
<div className="min-w-0 py-0.5">
81+
<div>{props.label}</div>
82+
{props.description ? (
83+
<div className="text-xs font-normal text-muted-foreground">{props.description}</div>
84+
) : null}
85+
</div>
86+
)
87+
}

‎src/renderer/src/components/native-chat/NativeChatSessionOptionPickers.test.tsx‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,4 +637,44 @@ describe('NativeChatSessionOptionPickers', () => {
637637
expect(screen.getAllByText('Thinking').length).toBeGreaterThan(0)
638638
expect(screen.getAllByText('Sent to the agent — not confirmed').length).toBeGreaterThan(0)
639639
})
640+
641+
it('splits CLI-listed effort tiers into a model row and a tier pill', async () => {
642+
const setOption = vi.fn().mockResolvedValue({ snapshot: [] })
643+
const tiered = model({
644+
kind: {
645+
type: 'select',
646+
currentValue: 'flash-medium',
647+
choices: [
648+
{ value: 'flash-high', label: 'Flash (High)' },
649+
{ value: 'flash-medium', label: 'Flash (Medium)' },
650+
{ value: 'pro-high', label: 'Pro (High)' },
651+
{ value: 'pro-low', label: 'Pro (Low)' },
652+
{ value: 'sonnet', label: 'Sonnet (Thinking)' }
653+
]
654+
}
655+
})
656+
render(
657+
<NativeChatSessionOptionPickers
658+
surface={{ ...surface, setOption }}
659+
snapshot={[tiered]}
660+
isWorking={false}
661+
/>
662+
)
663+
664+
expect(screen.getByRole('button', { name: 'Model Flash' })).not.toBeNull()
665+
expect(screen.getByRole('button', { name: 'Effort Medium' })).not.toBeNull()
666+
const models = screen.getByRole('radiogroup', { name: 'Model' })
667+
expect(
668+
[...models.querySelectorAll('[role="radio"]')].map((radio) => radio.textContent)
669+
).toEqual(['Flash', 'Pro', 'Sonnet (Thinking)'])
670+
const tiers = screen.getByRole('radiogroup', { name: 'Effort' })
671+
expect([...tiers.querySelectorAll('[role="radio"]')].map((r) => r.textContent)).toEqual([
672+
'High',
673+
'Medium'
674+
])
675+
676+
// Pro has no Medium tier, so switching to it falls back to its first listed tier.
677+
screen.getByRole('radio', { name: 'Pro' }).click()
678+
await waitFor(() => expect(setOption).toHaveBeenCalledWith('model', 'pro-high'))
679+
})
640680
})

0 commit comments

Comments
 (0)