Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(settings): correct routing mode card selection logic

Steven Enamakelb0ec20b61e64
diff --git a/app/src/components/settings/panels/ai/RoutingModeCards.tsx b/app/src/components/settings/panels/ai/RoutingModeCards.tsx
index 8437a21ff3..8e86ca4a25 100644
--- a/app/src/components/settings/panels/ai/RoutingModeCards.tsx
+++ b/app/src/components/settings/panels/ai/RoutingModeCards.tsx
@@ -1,25 +1,22 @@
/*
- * Top-level routing-mode picker: three selectable cards (Managed / Use Your
- * Own / Advanced) plus the "managed" confirmation banner.
+ * Top-level routing-mode picker: a segmented radio row (Managed / Use Your Own
+ * / Advanced) plus the "managed" confirmation banner.
*
- * TWO THINGS CHANGED HERE, both deliberate.
+ * IT IS A REAL RADIO GROUP. These three modes are mutually exclusive and one
+ * is always in force, but the old markup was three independent `<button>`s
+ * whose selected-ness lived only in a class string: a screen reader was told
+ * nothing about the choice, arrow keys did nothing, and there was no way to
+ * hear which mode was active. `RadioGroupRoot`/`RadioGroupItem` supply
+ * `role="radiogroup"`, roving focus and `aria-checked`. Each cell is a
+ * `<label>` wrapping its item, so the whole cell stays clickable and the
+ * accessible name is the title plus its description.
*
- * 1. It is a real radio group. These three modes are mutually exclusive — one
- * is always in force — and the old markup was three independent `<button>`s
- * whose selected-ness lived only in a class string. A screen reader was told
- * nothing about the choice, arrow keys did nothing, and there was no way to
- * hear which mode was active. `RadioGroupRoot`/`RadioGroupItem` supply
- * `role="radiogroup"`, roving focus, and `aria-checked` for free. Each card
- * is a `<label>` wrapping its item, so the whole card stays clickable and
- * the accessible name is the title plus its description.
- *
- * 2. The layout is flex, not `md:grid-cols-3`. A three-column grid forces
- * equal thirds at exactly one breakpoint and stacks below it; `flex-1
- * basis-0` fills whatever width the pane actually has and the `flex-col`
- * fallback handles the narrow case without a breakpoint at all. The
- * `min-h-[152px]` that padded the grid cells to a uniform height is gone
- * with it — `items-stretch` already equalises flex siblings, and a hard
- * pixel floor only clipped or over-padded once the copy was translated.
+ * IT IS SEGMENTED, NOT THREE CARDS. Three 152px-tall cards in a grid took a
+ * third of the page to express one choice, and the grid pinned them to equal
+ * thirds at exactly one breakpoint. One bordered strip divided into three
+ * flex cells says the same thing in a quarter of the height, fills whatever
+ * width the pane actually has, and folds to stacked rows on its own — the
+ * column is the flex default, not a breakpoint.
*/
import { cn } from '../../../../lib/cn';
import { useT } from '../../../../lib/i18n/I18nContext';
@@ -27,8 +24,9 @@ import Alert from '../../../ui/Alert';
import { RadioGroupItem, RadioGroupRoot } from '../../../ui/RadioGroup';
import type { RoutingMode } from './aiPanelTypes';
-/** One selectable mode card. Selected-ness is driven by the resolved mode. */
-const ModeCard = ({
+/** One cell of the segmented control. Selected-ness comes from the resolved
+ * mode rather than a `:has()` selector, so it works on the macOS 12 floor. */
+const ModeOption = ({
value,
selected,
tone,
@@ -43,22 +41,21 @@ const ModeCard = ({
description: string;
}) => (
<label
- data-slot="routing-mode-card"
+ data-slot="routing-mode-option"
data-selected={selected}
className={cn(
- 'flex min-w-0 flex-1 basis-0 cursor-pointer flex-col gap-2 rounded-2xl border p-4 text-left',
- 'transition-colors duration-150',
+ 'flex min-w-0 flex-1 cursor-pointer items-start gap-3 p-3 transition-colors duration-150',
selected
? tone === 'sage'
- ? 'border-sage-300 bg-sage-50 dark:border-sage-500/40 dark:bg-sage-500/10'
- : 'border-primary-300 bg-primary-50 dark:border-primary-500/40 dark:bg-primary-500/10'
- : 'border-line-strong bg-surface hover:bg-surface-hover'
+ ? 'bg-sage-50 dark:bg-sage-500/10'
+ : 'bg-primary-50 dark:bg-primary-500/10'
+ : 'bg-surface hover:bg-surface-hover'
)}>
- <div className="flex items-start justify-between gap-3">
- <span className="text-sm font-semibold text-content">{title}</span>
- <RadioGroupItem value={value} size="md" className="mt-0.5" />
- </div>
- <span className="text-xs leading-5 text-content-secondary">{description}</span>
+ <RadioGroupItem value={value} size="md" className="mt-0.5" />
+ <span className="flex min-w-0 flex-col gap-0.5">
+ <span className="text-sm font-medium text-content">{title}</span>
+ <span className="text-[11px] leading-4 text-content-muted">{description}</span>
+ </span>
</label>
);
@@ -84,22 +81,25 @@ export const RoutingModeCards = ({
else if (next === 'own') onSelectOwn();
else if (next === 'custom') onSelectCustom();
}}
- className="flex w-full flex-col items-stretch gap-3 lg:flex-row">
- <ModeCard
+ className={cn(
+ 'flex w-full flex-col items-stretch overflow-hidden rounded-xl border border-line',
+ 'divide-y divide-line md:flex-row md:divide-x md:divide-y-0'
+ )}>
+ <ModeOption
value="managed"
selected={effectiveRoutingMode === 'managed'}
tone="sage"
title={t('settings.ai.routing.managed')}
description={t('settings.ai.routing.managedDesc')}
/>
- <ModeCard
+ <ModeOption
value="own"
selected={effectiveRoutingMode === 'own'}
tone="primary"
title={t('settings.ai.routing.useYourOwn')}
description={t('settings.ai.routing.useYourOwnDesc')}
/>
- <ModeCard
+ <ModeOption
value="custom"
selected={effectiveRoutingMode === 'custom'}
tone="primary"