Skip to content

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

fix(settings): correct AI settings panel layout and interaction

Steven Enamakel46591c0f6d91
diff --git a/app/src/components/dashboard/CostDashboardPanel.tsx b/app/src/components/dashboard/CostDashboardPanel.tsx
index 2db90fb72c..adc969b8ca 100644
--- a/app/src/components/dashboard/CostDashboardPanel.tsx
+++ b/app/src/components/dashboard/CostDashboardPanel.tsx
@@ -1,10 +1,11 @@
+import { RefreshCw } from 'lucide-react';
import { useEffect, useMemo, useState } from 'react';
import { useCostDashboard } from '../../hooks/useCostDashboard';
import { useT } from '../../lib/i18n/I18nContext';
import { SettingsStatusLine } from '../settings/controls';
import SettingsPanel from '../settings/layout/SettingsPanel';
-import { Alert, AlertDescription, Button, Card } from '../ui';
+import { Alert, AlertDescription, Button, Card, EmptyState } from '../ui';
import CostBarChart from './CostBarChart';
import CostSummary from './CostSummary';
import DashboardSkeleton from './DashboardSkeleton';
@@ -37,8 +38,8 @@ const CostDashboardPanel = ({ embedded = false }: CostDashboardPanelProps) => {
const body = (
<>
- <div className="flex items-start justify-between gap-3">
- <p className="text-xs text-content-muted max-w-prose">
+ <div className="flex flex-wrap items-center justify-between gap-3">
+ <p className="max-w-prose text-xs text-content-muted">
{t('settings.costDashboard.subtitle')}
</p>
<div className="flex items-center gap-2 shrink-0">
@@ -62,7 +63,10 @@ const CostDashboardPanel = ({ embedded = false }: CostDashboardPanelProps) => {
disabled={isFetching}
aria-label={t('settings.costDashboard.refresh')}
leadingIcon={
- <RefreshIcon className={`h-3.5 w-3.5 ${isFetching ? 'animate-spin' : ''}`} />
+ <RefreshCw
+ className={`h-3.5 w-3.5 ${isFetching ? 'animate-spin' : ''}`}
+ aria-hidden
+ />
}>
{t('settings.costDashboard.refresh')}
</Button>
@@ -96,52 +100,48 @@ const CostDashboardPanel = ({ embedded = false }: CostDashboardPanelProps) => {
monthlyPaceUsd={data.monthly_pace_usd}
monthToDateUsd={data.month_to_date_usd}
/>
- <Card
- data-testid="cost-dashboard-cost-chart"
- padded
- divided={false}
- className="bg-surface/40"
- title={t('settings.costDashboard.sevenDayCost')}
- headerRight={
- <span className="text-[11px] text-content-muted">
- {t('settings.costDashboard.utcNote')}
- </span>
- }>
- <CostBarChart days={data.days} currency={data.currency} />
- </Card>
- <Card
- data-testid="cost-dashboard-token-chart"
- padded
- divided={false}
- className="bg-surface/40"
- title={t('settings.costDashboard.sevenDayTokens')}
- headerRight={
- <span className="text-[11px] text-content-muted">
- {t('settings.costDashboard.stackedNote')}
- </span>
- }>
- <TokenUsageChart days={data.days} />
- </Card>
+ {/* The two 7-day charts sit side by side once there is room. */}
+ <div className="grid gap-4 xl:grid-cols-2">
+ <Card
+ data-testid="cost-dashboard-cost-chart"
+ padded
+ divided={false}
+ title={t('settings.costDashboard.sevenDayCost')}
+ headerRight={
+ <span className="text-xs text-content-muted">
+ {t('settings.costDashboard.utcNote')}
+ </span>
+ }>
+ <CostBarChart days={data.days} currency={data.currency} />
+ </Card>
+ <Card
+ data-testid="cost-dashboard-token-chart"
+ padded
+ divided={false}
+ title={t('settings.costDashboard.sevenDayTokens')}
+ headerRight={
+ <span className="text-xs text-content-muted">
+ {t('settings.costDashboard.stackedNote')}
+ </span>
+ }>
+ <TokenUsageChart days={data.days} />
+ </Card>
+ </div>
<Card
data-testid="cost-dashboard-model-table"
- padded
- divided={false}
- className="bg-surface/40"
title={t('settings.costDashboard.modelBreakdown')}
description={t('settings.costDashboard.modelBreakdownHint')}>
<ModelCostTable models={data.by_model} currency={data.currency} />
</Card>
{!hasAnyUsage && (
- <div
- data-testid="cost-dashboard-empty"
- className="rounded-xl border border-dashed border-line-strong px-4 py-6 text-center">
- <div className="text-sm font-medium text-content-secondary">
- {t('settings.costDashboard.noData')}
- </div>
- <div className="text-[11px] text-content-muted mt-1">
- {t('settings.costDashboard.noDataHint')}
+ <Card data-testid="cost-dashboard-empty">
+ <div className="space-y-1 px-4 py-6 text-center">
+ <EmptyState label={t('settings.costDashboard.noData')} />
+ <p className="text-xs text-content-faint">
+ {t('settings.costDashboard.noDataHint')}
+ </p>
</div>
- </div>
+ </Card>
)}
</>
)}
@@ -152,7 +152,7 @@ const CostDashboardPanel = ({ embedded = false }: CostDashboardPanelProps) => {
// so render just the padded body.
if (embedded)
return (
- <div className="p-4 space-y-4" data-testid="cost-dashboard-panel">
+ <div className="space-y-4" data-testid="cost-dashboard-panel">
{body}
</div>
);
@@ -160,25 +160,4 @@ const CostDashboardPanel = ({ embedded = false }: CostDashboardPanelProps) => {
return <SettingsPanel testId="cost-dashboard-panel">{body}</SettingsPanel>;
};
-interface IconProps {
- className?: string;
-}
-
-const RefreshIcon = ({ className }: IconProps) => (
- <svg
- className={className}
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- aria-hidden>
- <polyline points="23 4 23 10 17 10" />
- <polyline points="1 20 1 14 7 14" />
- <path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10" />
- <path d="M20.49 15a9 9 0 0 1-14.85 3.36L1 14" />
- </svg>
-);
-
export default CostDashboardPanel;
diff --git a/app/src/components/settings/panels/ai/DefaultModelRow.tsx b/app/src/components/settings/panels/ai/DefaultModelRow.tsx
index 85c81d6a88..a706e4a2e7 100644
--- a/app/src/components/settings/panels/ai/DefaultModelRow.tsx
+++ b/app/src/components/settings/panels/ai/DefaultModelRow.tsx
@@ -10,10 +10,9 @@
import { useState } from 'react';
import { useT } from '../../../../lib/i18n/I18nContext';
-import Button from '../../../ui/Button';
-import { slugTone } from './aiPanelTypes';
-import { ProviderSwatch } from './ProviderListRow';
+import { TableCell, TableRow } from '../../../ui/Table';
import { ProviderModelPickerDialog } from './ProviderModelPickerDialog';
+import { RouteButton } from './RouteButton';
/** What the picker opens on when nothing is pinned yet. */
export const RECOMMENDED_DEFAULT_MODEL = 'openrouter/deepseek/deepseek-v4-flash';
@@ -41,42 +40,25 @@ export const DefaultModelRow = ({
const pinned = isPinnedManagedModel(value) ? value : null;
return (
- <li
- data-slot="workload-row"
- data-testid="default-model-row"
- className="flex flex-wrap items-center gap-3 px-4 py-3">
- <div className="min-w-0 flex-1">
+ <TableRow data-slot="workload-row" data-testid="default-model-row">
+ <TableCell className="py-3 pl-4">
<div className="flex min-w-0 flex-col gap-0.5">
<span className="text-sm font-medium text-content">
{t('settings.ai.routing.defaultModel')}
</span>
- <span className="text-xs leading-5 text-content-muted">
+ <span className="text-xs text-content-muted">
{t('settings.ai.routing.defaultModelDesc')}
</span>
</div>
- </div>
-
- <Button
- type="button"
- variant="secondary"
- size="xs"
- data-testid="default-model-change"
- onClick={() => setPickerOpen(true)}
- className="h-auto min-w-52 max-w-60 justify-start gap-2 px-3 py-2 text-left">
- <ProviderSwatch
- slug="openhuman"
- label={t('settings.ai.managedSourceLabel')}
- tone={slugTone('openhuman')}
+ </TableCell>
+ <TableCell className="py-3 pr-4">
+ <RouteButton
+ providerSlug="openhuman"
+ provider={t('settings.ai.managedSourceLabel')}
+ model={pinned ?? t('settings.ai.routing.defaultModelUnset')}
+ onClick={() => setPickerOpen(true)}
+ data-testid="default-model-change"
/>
- <span className="flex min-w-0 flex-col gap-0.5">
- <span className="truncate text-[10px] font-medium text-content-muted">
- {t('settings.ai.managedSourceLabel')}
- </span>
- <span className="max-w-full truncate font-mono text-xs text-content">
- {pinned ?? t('settings.ai.routing.defaultModelUnset')}
- </span>
- </span>
- </Button>
{pickerOpen && (
<ProviderModelPickerDialog
@@ -92,7 +74,8 @@ export const DefaultModelRow = ({
}}
/>
)}
- </li>
+ </TableCell>
+ </TableRow>
);
};
diff --git a/app/src/components/settings/panels/ai/RouteButton.tsx b/app/src/components/settings/panels/ai/RouteButton.tsx
new file mode 100644
index 0000000000..11126fa740
--- /dev/null
+++ b/app/src/components/settings/panels/ai/RouteButton.tsx
@@ -0,0 +1,46 @@
+/*
+ * The route cell of a routing-table row: one button showing where the task
+ * runs (provider mark + name over the model id) that opens the picker. It is a
+ * single button on purpose — tests and assistive tech reach the route through
+ * the model text's enclosing button.
+ */
+import { ChevronRight } from 'lucide-react';
+
+import Button from '../../../ui/Button';
+import { slugTone } from './aiPanelTypes';
+import { ProviderSwatch } from './ProviderListRow';
+
+export const RouteButton = ({
+ providerSlug,
+ provider,
+ model,
+ onClick,
+ 'data-testid': testId,
+}: {
+ providerSlug: string | null;
+ provider: string;
+ model: string;
+ onClick: () => void;
+ 'data-testid'?: string;
+}) => (
+ <Button
+ type="button"
+ variant="secondary"
+ size="sm"
+ onClick={onClick}
+ data-testid={testId}
+ className="h-auto w-64 justify-start gap-2.5 px-2.5 py-1.5 text-left">
+ {providerSlug ? (
+ <ProviderSwatch slug={providerSlug} label={provider} tone={slugTone(providerSlug)} />
+ ) : null}
+ <span className="flex min-w-0 flex-1 flex-col">
+ <span className="truncate text-xs font-medium text-content">{provider}</span>
+ <span className="truncate font-mono text-[11px] font-normal text-content-muted">
+ {model}
+ </span>
+ </span>
+ <ChevronRight className="h-4 w-4 shrink-0 text-content-faint" aria-hidden />
+ </Button>
+);
+
+export default RouteButton;
diff --git a/app/src/components/settings/panels/ai/WorkloadRow.tsx b/app/src/components/settings/panels/ai/WorkloadRow.tsx
index 5343c743ad..35ee15f7ed 100644
--- a/app/src/components/settings/panels/ai/WorkloadRow.tsx
+++ b/app/src/components/settings/panels/ai/WorkloadRow.tsx
@@ -13,15 +13,14 @@
* writes its own `data-slot` before spreading props, so ours wins.
*/
import { useT } from '../../../../lib/i18n/I18nContext';
-import Button from '../../../ui/Button';
+import { TableCell, TableRow } from '../../../ui/Table';
import {
type CloudProvider,
type ProviderRef,
- slugTone,
type Workload,
WORKLOAD_MODEL_HINT_KEYS,
} from './aiPanelTypes';
-import { ProviderSwatch } from './ProviderListRow';
+import { RouteButton } from './RouteButton';
export type WorkloadRowProps = {
workload: Workload;
@@ -88,39 +87,25 @@ export const WorkloadRow = ({
const { provider, providerSlug, model } = resolveTarget(ref_, cloudProviders, t);
return (
- <li
- data-slot="workload-row"
- data-pinned={isPinned}
- className="flex flex-wrap items-center gap-3 px-4 py-3">
- <div className="min-w-0 flex-1">
+ <TableRow data-slot="workload-row" data-pinned={isPinned}>
+ <TableCell className="py-3 pl-4">
<div className="flex min-w-0 flex-col gap-0.5">
<span className="text-sm font-medium text-content">{t(workload.labelKey)}</span>
- <span className="text-xs leading-5 text-content-muted">{t(workload.descriptionKey)}</span>
- <span className="text-[11px] leading-5 text-content-faint">
+ <span className="text-xs text-content-muted">{t(workload.descriptionKey)}</span>
+ <span className="text-[11px] text-content-faint">
{t(WORKLOAD_MODEL_HINT_KEYS[workload.id])}
</span>
</div>
- </div>
-
- <Button
- type="button"
- variant="secondary"
- size="xs"
- onClick={onCustomClick}
- className="h-auto min-w-52 max-w-60 justify-start gap-2 px-3 py-2 text-left">
- {provider && providerSlug ? (
- <ProviderSwatch slug={providerSlug} label={provider} tone={slugTone(providerSlug)} />
- ) : null}
- <span className="flex min-w-0 flex-col gap-0.5">
- <span className="truncate text-[10px] font-medium text-content-muted">
- {provider ?? 'Select provider and model'}
- </span>
- <span className="max-w-full truncate font-mono text-xs text-content">
- {model || 'Choose a model'}
- </span>
- </span>
- </Button>
- </li>
+ </TableCell>
+ <TableCell className="py-3 pr-4">
+ <RouteButton
+ providerSlug={provider ? providerSlug : null}
+ provider={provider ?? t('settings.ai.routing.selectProvider')}
+ model={model || t('settings.ai.routing.chooseModel')}
+ onClick={onCustomClick}
+ />
+ </TableCell>
+ </TableRow>
);
};
diff --git a/app/src/components/settings/panels/ai/WorkloadTable.tsx b/app/src/components/settings/panels/ai/WorkloadTable.tsx
index 69a62af144..de29e7318f 100644
--- a/app/src/components/settings/panels/ai/WorkloadTable.tsx
+++ b/app/src/components/settings/panels/ai/WorkloadTable.tsx
@@ -1,35 +1,41 @@
/*
- * One titled group of workload rows (chat, or background) rendered as a real
- * table.
- *
- * The two groups were byte-identical markup differing only in copy and row
- * array, so they share one component. `Table` brings the piece that matters
- * beyond semantics: it wraps the table in its own `overflow-x-auto`, so a
- * narrow settings pane scrolls the matrix rather than the whole page.
- *
- * The action column has a deliberately empty header. It holds a control, not
- * data, and a visible label for it would be read out on every row; the buttons
- * name themselves ("Change Model" / "Choose Model").
+ * One titled group of workload rows (chat, or background) rendered as a Card
+ * holding a real table: the task on the left, the route it resolves to on the
+ * right. `Table` wraps itself in `overflow-x-auto`, so a narrow settings pane
+ * scrolls the matrix rather than the whole page.
*/
import { type ReactNode } from 'react';
+import { useT } from '../../../../lib/i18n/I18nContext';
+import Card from '../../../ui/Card';
+import { Table, TableBody, TableHead, TableHeader, TableRow } from '../../../ui/Table';
+
export const WorkloadTable = ({
title,
description,
children,
+ 'data-testid': testId,
}: {
title: string;
description: string;
children: ReactNode;
+ 'data-testid'?: string;
}) => {
+ const { t } = useT();
return (
- <div className="flex w-full flex-col">
- <div className="flex flex-col gap-0.5 px-4 py-3">
- <h4 className="text-sm font-semibold text-content">{title}</h4>
- <p className="text-xs text-content-muted">{description}</p>
- </div>
- <ul className="divide-y divide-line-subtle border-t border-line-subtle">{children}</ul>
- </div>
+ <Card title={title} description={description} className="w-full" data-testid={testId}>
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="pl-4">{t('settings.ai.routing.columnTask')}</TableHead>
+ <TableHead className="w-px whitespace-nowrap pr-4">
+ {t('settings.ai.routing.columnRoute')}
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>{children}</TableBody>
+ </Table>
+ </Card>
);
};