fix(app): Models — unpriced = no cost AND no savings (stop dimming Codex + local rows)

Critical review fix: the unpriced predicate misclassified every Codex row (all have credits)
and every local saved-only model, hiding real cost/savings. Now unpriced = costUSD===0 &&
savingsUSD===0. Fixtures made realistic (codex priced, local saved-only priced, genuine proxy
dimmed); proxy token cols show "—"; sub-1M tokens use the wireframe's "0.4M" style.

Implemented by Codex gpt-5.5 (high); committed by Fable (git blocked in Codex sandbox).
This commit is contained in:
iamtoruk 2026-07-10 18:56:48 -07:00
parent 18b4b728ff
commit fe54d9f352
2 changed files with 52 additions and 9 deletions

View file

@ -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(<Models period="30days" provider="all" />)
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(<Models period="30days" provider="all" />)
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(<Models period="30days" provider="all" />)
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()
})

View file

@ -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}
</td>
<td className={cellClass}>{fmtInt(row.calls)}</td>
<td className={cellClass}>{fmtCompact(row.inputTokens)}</td>
<td className={cellClass}>{fmtCompact(row.outputTokens)}</td>
<td className={cellClass}>{fmtCompact(row.cacheReadTokens)}</td>
<td className={cellClass}>{tokenValue(row.inputTokens)}</td>
<td className={cellClass}>{tokenValue(row.outputTokens)}</td>
<td className={cellClass}>{tokenValue(row.cacheReadTokens)}</td>
<td className={cellClass}>{unpriced ? '—' : fmtUsd(row.costUSD)}</td>
<td className={unpriced ? 'dim' : row.savingsUSD > 0 ? 'pos' : undefined}>{unpriced ? '—' : fmtUsd(row.savingsUSD)}</td>
</tr>