Skip to content

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

fix(dashboard): handle missing cost data in ModelCostTable

Steven Enamakel78597b45f288
diff --git a/app/src/components/dashboard/CostDashboardPanel.tsx b/app/src/components/dashboard/CostDashboardPanel.tsx
index 8eb07fac0f..a2a5cdb564 100644
--- a/app/src/components/dashboard/CostDashboardPanel.tsx
+++ b/app/src/components/dashboard/CostDashboardPanel.tsx
@@ -127,12 +127,14 @@ const CostDashboardPanel = ({ embedded = false }: CostDashboardPanelProps) => {
<TokenUsageChart days={data.days} />
</Card>
</div>
- <Card
- data-testid="cost-dashboard-model-table"
- title={t('settings.costDashboard.modelBreakdown')}
- description={t('settings.costDashboard.modelBreakdownHint')}>
- <ModelCostTable models={data.by_model} currency={data.currency} />
- </Card>
+ <div data-testid="cost-dashboard-model-table">
+ <ModelCostTable
+ models={data.by_model}
+ currency={data.currency}
+ title={t('settings.costDashboard.modelBreakdown')}
+ description={t('settings.costDashboard.modelBreakdownHint')}
+ />
+ </div>
{!hasAnyUsage && (
<Card data-testid="cost-dashboard-empty">
<div className="space-y-1 px-4 py-6 text-center">
diff --git a/app/src/components/dashboard/ModelCostTable.tsx b/app/src/components/dashboard/ModelCostTable.tsx
index 50d946d705..45a8814563 100644
--- a/app/src/components/dashboard/ModelCostTable.tsx
+++ b/app/src/components/dashboard/ModelCostTable.tsx
@@ -2,7 +2,16 @@ import type { ReactNode } from 'react';
import type { CostDashboardModelStats } from '../../hooks/useCostDashboard';
import { useT } from '../../lib/i18n/I18nContext';
-import { Badge, DataTable, type DataTableColumn, EmptyState, Progress } from '../ui';
+import {
+ Badge,
+ DataTable,
+ type DataTableColumn,
+ EmptyState,
+ Progress,
+ TableCell,
+ TableRow,
+} from '../ui';
+import { cn } from '../../lib/cn';
import { formatCurrency, formatTokens } from './formatCurrency';
interface ModelCostTableProps {
@@ -90,8 +99,18 @@ const ModelCostTable = ({ models, currency, title, description }: ModelCostTable
columns={columns}
rows={models}
rowKey={row => row.model}
- rowTestId={undefined}
- renderRow={undefined}
+ // Custom rows only to keep the per-model `model-row-*` test id.
+ renderRow={row => (
+ <TableRow key={row.model} data-testid={`model-row-${row.model}`}>
+ {columns.map(column => (
+ <TableCell
+ key={column.id}
+ className={cn(column.align === 'right' && 'text-right', column.className)}>
+ {column.cell?.(row)}
+ </TableCell>
+ ))}
+ </TableRow>
+ )}
ariaLabel={t('settings.costDashboard.modelBreakdown')}
testId="model-cost-table"
empty={
@@ -100,7 +119,6 @@ const ModelCostTable = ({ models, currency, title, description }: ModelCostTable
label={t('settings.costDashboard.noModels')}
/>
}
- rowClassName={() => undefined}
/>
);
};