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 Enamakel7e7719431353
diff --git a/app/src/components/settings/panels/ai/RoutingModeCards.tsx b/app/src/components/settings/panels/ai/RoutingModeCards.tsx
index d565da6c4b..d6f01aae39 100644
--- a/app/src/components/settings/panels/ai/RoutingModeCards.tsx
+++ b/app/src/components/settings/panels/ai/RoutingModeCards.tsx
@@ -1,11 +1,67 @@
/*
- * Top-level routing-mode picker: three large selectable cards (Managed / Use
- * Your Own / Advanced) plus the "managed" confirmation banner.
+ * Top-level routing-mode picker: three selectable cards (Managed / Use Your
+ * Own / Advanced) plus the "managed" confirmation banner.
+ *
+ * TWO THINGS CHANGED HERE, both deliberate.
+ *
+ * 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.
*/
import { useT } from '../../../../lib/i18n/I18nContext';
-import Button from '../../../ui/Button';
+import { cn } from '../../../../lib/cn';
+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 = ({
+ value,
+ selected,
+ tone,
+ title,
+ description,
+}: {
+ value: RoutingMode;
+ selected: boolean;
+ /** `sage` marks the recommended managed default; the rest read as primary. */
+ tone: 'sage' | 'primary';
+ title: string;
+ description: string;
+}) => (
+ <label
+ data-slot="routing-mode-card"
+ 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',
+ 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'
+ )}>
+ <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>
+ </label>
+);
+
export const RoutingModeCards = ({
effectiveRoutingMode,
onSelectManaged,
@@ -19,66 +75,43 @@ export const RoutingModeCards = ({
}) => {
const { t } = useT();
return (
- <>
- <div className="grid gap-3 md:grid-cols-3">
- <Button
- type="button"
- variant="secondary"
- onClick={onSelectManaged}
- className={`h-full min-h-[152px] flex-col items-start justify-start rounded-2xl p-4 text-left font-normal normal-case ${
- effectiveRoutingMode === 'managed'
- ? 'border-sage-300 bg-sage-50 dark:border-sage-500/40 dark:bg-sage-500/10'
- : 'bg-surface hover:bg-surface-hover'
- }`}>
- <div className="text-sm font-semibold text-content">
- {t('settings.ai.routing.managed')}
- </div>
- <p className="mt-2 text-xs leading-5 text-content-secondary">
- {t('settings.ai.routing.managedDesc')}
- </p>
- </Button>
-
- <Button
- type="button"
- variant="secondary"
- onClick={onSelectOwn}
- className={`h-full min-h-[152px] flex-col items-start justify-start rounded-2xl p-4 text-left font-normal normal-case ${
- effectiveRoutingMode === 'own'
- ? 'border-primary-300 bg-primary-50 dark:border-primary-500/40 dark:bg-primary-500/10'
- : 'bg-surface hover:bg-surface-hover'
- }`}>
- <div className="text-sm font-semibold text-content">
- {t('settings.ai.routing.useYourOwn')}
- </div>
- <p className="mt-2 text-xs leading-5 text-content-secondary">
- {t('settings.ai.routing.useYourOwnDesc')}
- </p>
- </Button>
-
- <Button
- type="button"
- variant="secondary"
- onClick={onSelectCustom}
- className={`h-full min-h-[152px] flex-col items-start justify-start rounded-2xl p-4 text-left font-normal normal-case ${
- effectiveRoutingMode === 'custom'
- ? 'border-primary-300 bg-primary-50 dark:border-primary-500/40 dark:bg-primary-500/10'
- : 'bg-surface hover:bg-surface-hover'
- }`}>
- <div className="text-sm font-semibold text-content">
- {t('settings.ai.routing.advanced')}
- </div>
- <p className="mt-2 text-xs leading-5 text-content-secondary">
- {t('settings.ai.routing.advancedDesc')}
- </p>
- </Button>
- </div>
+ <div className="flex w-full flex-col gap-3">
+ <RadioGroupRoot
+ aria-label={t('settings.ai.routing')}
+ value={effectiveRoutingMode}
+ onValueChange={next => {
+ if (next === 'managed') onSelectManaged();
+ else if (next === 'own') onSelectOwn();
+ else if (next === 'custom') onSelectCustom();
+ }}
+ className="flex w-full flex-col items-stretch gap-3 lg:flex-row">
+ <ModeCard
+ value="managed"
+ selected={effectiveRoutingMode === 'managed'}
+ tone="sage"
+ title={t('settings.ai.routing.managed')}
+ description={t('settings.ai.routing.managedDesc')}
+ />
+ <ModeCard
+ value="own"
+ selected={effectiveRoutingMode === 'own'}
+ tone="primary"
+ title={t('settings.ai.routing.useYourOwn')}
+ description={t('settings.ai.routing.useYourOwnDesc')}
+ />
+ <ModeCard
+ value="custom"
+ selected={effectiveRoutingMode === 'custom'}
+ tone="primary"
+ title={t('settings.ai.routing.advanced')}
+ description={t('settings.ai.routing.advancedDesc')}
+ />
+ </RadioGroupRoot>
{effectiveRoutingMode === 'managed' ? (
- <div className="rounded-xl border border-sage-200 bg-sage-50/70 px-4 py-3 text-sm text-sage-900 dark:border-sage-500/30 dark:bg-sage-500/10 dark:text-sage-100">
- {t('settings.ai.routing.managedMsg')}
- </div>
+ <Alert variant="success">{t('settings.ai.routing.managedMsg')}</Alert>
) : null}
- </>
+ </div>
);
};