diff --git a/app/renderer/sections/Models.test.tsx b/app/renderer/sections/Models.test.tsx index cb5fb566..02eed528 100644 --- a/app/renderer/sections/Models.test.tsx +++ b/app/renderer/sections/Models.test.tsx @@ -34,8 +34,8 @@ const rows: ModelReportRow[] = [ credits: null, }, { - provider: 'openai', - providerDisplayName: 'OpenAI', + provider: 'codex', + providerDisplayName: 'Codex', model: 'gpt-5.5-codex', modelDisplayName: 'GPT-5.5 Codex', category: null, @@ -50,6 +50,23 @@ const rows: ModelReportRow[] = [ costUSD: 137.9, savingsUSD: 35.1, savingsBaselineModel: 'GPT-5.5 Codex', + credits: 173, + }, + { + provider: 'local', + providerDisplayName: 'Local', + model: 'llama-local', + modelDisplayName: 'Llama Local', + category: null, + inputTokens: 750_000, + outputTokens: 400_000, + cacheWriteTokens: 0, + cacheReadTokens: 0, + totalTokens: 1_150_000, + calls: 82, + costUSD: 0, + savingsUSD: 12.34, + savingsBaselineModel: 'Claude Opus 4.8', credits: null, }, { @@ -111,14 +128,38 @@ describe('Models', () => { expect(dots[1]).toHaveAttribute('style', expect.stringContaining('var(--cyan)')) }) - it('renders unpriced proxy rows as dim with alias affordance and cost dashes', async () => { - getModels.mockResolvedValue(rows) + it('renders codex rows with credits and real cost as priced', async () => { + getModels.mockResolvedValue([rows[1]]) + + render() + + expect(await screen.findByText('GPT-5.5 Codex')).not.toHaveClass('dim') + expect(screen.getByText('$137.90')).not.toHaveClass('dim') + expect(screen.getByText('$35.10')).toHaveClass('pos') + expect(screen.queryByText('add alias ›')).not.toBeInTheDocument() + }) + + it('renders local saved-only rows as priced with real savings', async () => { + getModels.mockResolvedValue([rows[2]]) + + render() + + expect(await screen.findByText('Llama Local')).not.toHaveClass('dim') + expect(screen.getByText('0.8M')).toBeInTheDocument() + expect(screen.getByText('0.4M')).toBeInTheDocument() + expect(screen.getByText('$0.00')).not.toHaveClass('dim') + expect(screen.getByText('$12.34')).toHaveClass('pos') + expect(screen.queryByText('add alias ›')).not.toBeInTheDocument() + }) + + it('renders unpriced proxy rows as dim with alias affordance and dashes', async () => { + getModels.mockResolvedValue([rows[3]]) render() expect(await screen.findByText('my-proxy-model')).toHaveClass('dim') expect(screen.getByText('add alias ›')).toHaveClass('alias') - expect(screen.getAllByText('—')).toHaveLength(2) + expect(screen.getAllByText('—')).toHaveLength(5) expect(screen.queryByText('$0.00')).not.toBeInTheDocument() }) diff --git a/app/renderer/sections/Models.tsx b/app/renderer/sections/Models.tsx index 20e7bf23..01e03689 100644 --- a/app/renderer/sections/Models.tsx +++ b/app/renderer/sections/Models.tsx @@ -24,6 +24,7 @@ function fmtInt(n: number): string { function fmtCompact(n: number): string { if (n === 0) return '0' + if (n < 1_000_000) return `${(n / 1_000_000).toFixed(1)}M` return new Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: n >= 10_000_000 ? 1 : 2, @@ -115,8 +116,9 @@ function ModelsTable({ rows, byTask }: { rows: ModelReportRow[]; byTask: boolean } function ModelTableRow({ row, byTask }: { row: ModelReportRow; byTask: boolean }) { - const unpriced = (row.costUSD === 0 && row.calls > 0) || row.credits !== null + const unpriced = row.costUSD === 0 && row.savingsUSD === 0 const cellClass = unpriced ? 'dim' : undefined + const tokenValue = (value: number) => (unpriced ? '—' : fmtCompact(value)) const dotStyle = { display: 'inline-block', background: seriesColorForModel(row.modelDisplayName || row.model), @@ -142,9 +144,9 @@ function ModelTableRow({ row, byTask }: { row: ModelReportRow; byTask: boolean } ) : null} {fmtInt(row.calls)} - {fmtCompact(row.inputTokens)} - {fmtCompact(row.outputTokens)} - {fmtCompact(row.cacheReadTokens)} + {tokenValue(row.inputTokens)} + {tokenValue(row.outputTokens)} + {tokenValue(row.cacheReadTokens)} {unpriced ? '—' : fmtUsd(row.costUSD)} 0 ? 'pos' : undefined}>{unpriced ? '—' : fmtUsd(row.savingsUSD)}