Show agent speed as one button instead of a Standard/Fast switcher

Codex's Speed row used a segmented Standard | Fast switcher while Claude and
Cursor used a single Fast chip. Speed is now always one button: one faster
tier toggles it, several (Fast and Ultrafast, or a configured Flex) open a
list from the button.
This commit is contained in:
Brennan Benson
2026-11-08 16:54:30 -08:00
parent 651f656c77
commit cc13fd7eef
3 changed files with 123 additions and 5 deletions
@@ -71,11 +71,7 @@ it.each(['claude', 'codex'] as const)(
fireEvent.click(panel().querySelector('[cmdk-item]')!)
fireEvent.click(getByRole(document.body, 'radio', { name: 'High' }))
// A speed edit copies the current Arguments into the draft; later settings must still win.
fireEvent.click(
agent === 'claude'
? getByRole(document.body, 'button', { name: 'Fast' })
: getByRole(document.body, 'radio', { name: 'Fast' })
)
fireEvent.click(getByRole(document.body, 'button', { name: 'Fast' }))
changePrompt(
panel().querySelector<HTMLElement>('[contenteditable]')!,
'keep @/repo/exact-file.ts'
@@ -22,6 +22,7 @@ import {
} from '../../../../../../../shared/native-chat/input/native-chat-session-option-labels'
import { sayNativeChatSessionOptionTranslated as say } from './native-chat-session-option-labels-text'
import { NativeChatSessionOptionWriteGroup } from './NativeChatSessionOptionWriteGroup'
import { NativeChatSessionSpeedButton, speedButtonTiers } from './NativeChatSessionSpeedButton'
type NativeChatSessionOptionRowsProps = {
/** The current model's options, in display order. */
@@ -138,6 +139,32 @@ function OptionRow(props: {
</Toggle>
)
}
const speed = speedButtonTiers(descriptor)
if (speed && descriptor.kind.type === 'select') {
const button = (
<NativeChatSessionSpeedButton
label={label}
standard={speed.standard}
faster={speed.faster}
current={gone ? undefined : descriptor.kind.currentValue}
disabled={off}
onSet={onSet}
/>
)
return layout === 'inline' ? (
button
) : (
<div
className={cn(
'flex min-h-7 items-center justify-between gap-3 text-xs text-muted-foreground',
layout === 'menu' && 'px-2'
)}
>
{label}
{button}
</div>
)
}
if (descriptor.kind.type === 'boolean') {
return (
<label
@@ -0,0 +1,95 @@
import { ChevronDown, Zap } from 'lucide-react'
import { cn } from '@/lib/utils'
import { Toggle, toggleVariants } from '@/components/ui/toggle'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import type {
SessionOptionDescriptor,
SessionOptionSelectChoice,
SessionOptionValue
} from '../../../../../../../shared/native-chat/input/native-chat-session-options'
import { nativeChatSessionChoiceLabel } from '../../../../../../../shared/native-chat/input/native-chat-session-option-labels'
import { sayNativeChatSessionOptionTranslated as say } from './native-chat-session-option-labels-text'
const STANDARD_TIER = 'default'
/** Standard plus the faster tiers, or null when the select is not a speed choice with any. */
export function speedButtonTiers(
descriptor: SessionOptionDescriptor
): { standard: SessionOptionSelectChoice; faster: SessionOptionSelectChoice[] } | null {
if (descriptor.id !== 'serviceTier' || descriptor.kind.type !== 'select') {
return null
}
const standard = descriptor.kind.choices.find((choice) => choice.value === STANDARD_TIER)
const faster = descriptor.kind.choices.filter((choice) => choice.value !== STANDARD_TIER)
return standard && faster.length > 0 ? { standard, faster } : null
}
/** One faster tier toggles like Claude's Fast; several open a list instead of a segmented switcher. */
export function NativeChatSessionSpeedButton(props: {
label: string
standard: SessionOptionSelectChoice
faster: SessionOptionSelectChoice[]
current: string | undefined
disabled: boolean
onSet: (value: SessionOptionValue) => void
}): React.JSX.Element {
const { label, standard, faster, current, disabled, onSet } = props
const picked = faster.find((choice) => choice.value === current)
const nameOf = (choice: SessionOptionSelectChoice) =>
nativeChatSessionChoiceLabel(choice, say, 'serviceTier')
if (faster.length === 1) {
const only = faster[0]
return (
<Toggle
variant="chip"
size="xs"
pressed={Boolean(picked)}
disabled={disabled}
onPressedChange={(pressed) => onSet(pressed ? only.value : standard.value)}
>
<Zap className="size-3" />
{nameOf(only)}
</Toggle>
)
}
return (
<DropdownMenu>
<DropdownMenuTrigger asChild disabled={disabled}>
<button
type="button"
aria-label={`${label}: ${nameOf(picked ?? standard)}`}
// Mirrors the chip's pressed fill; a menu trigger's data-state names open, not on.
className={cn(
toggleVariants({ variant: 'chip', size: 'xs' }),
'gap-1',
picked && 'border-transparent bg-foreground/12 text-foreground dark:bg-accent'
)}
>
<Zap className="size-3" />
{nameOf(picked ?? standard)}
<ChevronDown className="size-3 opacity-70" />
</button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" collisionPadding={8} className="min-w-56">
<DropdownMenuRadioGroup value={picked?.value ?? standard.value} onValueChange={onSet}>
{[standard, ...faster].map((choice) => (
<DropdownMenuRadioItem key={choice.value} value={choice.value}>
<span className="flex min-w-0 flex-col gap-0.5">
<span>{nameOf(choice)}</span>
{choice.description ? (
<span className="text-xs text-muted-foreground">{choice.description}</span>
) : null}
</span>
</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
)
}