Repository navigation
Add unpriced filter to models report - #985
Conversation
ozymandiashh
left a comment
There was a problem hiding this comment.
Nice, focused change — and thank you for reusing findUnpricedModels rather than re-deriving the predicate. That keeps the alias / price-override / local-savings exclusions in one place, so the filter and the dashboard warning can never drift apart. Passing row.model rather than the display name is also the right call; it's a better pricing key than what dashboard.tsx and overview.ts currently hand the same helper.
Two things before this can go in.
1. --unpriced combined with --top returns nothing.
--top is applied inside aggregateModels (src/models-report.ts:234-236), after the sort by costUSD + savingsUSD descending. Unpriced rows are $0 cost by definition, and rows carrying a local-savings baseline are excluded by findUnpricedModels, so they're $0 savings too — which puts them last in that sort, every time. The new filter in src/main.ts runs afterwards, so --top has already sliced away exactly the rows --unpriced exists to show:
codeburn models --unpriced --format json # -> the unpriced row
codeburn models --unpriced --top 2 --format json # -> []
codeburn models --unpriced --top 2 # -> "No model usage found for the selected period."
That last line is the part I'd like to avoid shipping: a user with unpriced models is told they have none. Both flags are documented on models, so it's a combination people will land on.
The straightforward fix is to stop letting aggregateModels do the slicing when --unpriced is set — pass topN: undefined, then slice to opts.top after the filter. Worth a test pinning --unpriced --top 1 against a fixture where a priced model outranks the unpriced one, since that's the case that's silently wrong today.
2. The flag needs a line in the README table and the changelog.
Every other models flag is listed in the Models table in README.md, and user-visible flags land in ## Unreleased in CHANGELOG.md. A filter nobody can discover doesn't do much for #969, which is the point of adding it.
On your note about npm test -- tests/models-report.test.ts running the broad suite: that's a real rough edge, not you. The script doesn't forward the positional path. npx vitest run tests/models-report.test.ts is the working form, and it's what CONTRIBUTING should probably say.
Everything else looks good to me — the end-to-end spawn test with an isolated HOME/CODEBURN_CACHE_DIR and a fixed TZ is the right shape, and defaulting that mode's min-cost to 0 is the correct call rather than a special case. Ping me when the --top interaction is handled and I'll take another pass.
ozymandiashh
left a comment
There was a problem hiding this comment.
Taking the two items myself rather than holding this — the feature is right and the remaining work is small enough that it shouldn't sit in your queue.
To be clear about what's going in: --unpriced on its own works correctly, and reusing findUnpricedModels rather than re-deriving the predicate is the part that matters long-term, since the alias / price-override / local-savings exclusions stay in one place and the filter heals on its own when pricing data arrives. Passing row.model instead of the display name is also strictly better than what dashboard.tsx and overview.ts currently hand the same helper.
Merging, and I'll follow up with:
- the
--topinteraction —aggregateModelsslices before the filter runs, so--unpriced --top Nreturns nothing whenever N is smaller than the number of priced rows - the README Models table row and the changelog entry
Also worth fixing separately: npm test -- <path> not forwarding the positional argument, which is what sent you into the broad suite. That's a real rough edge in the repo, not something you did wrong.
Thanks for a clean, well-scoped first contribution.
`--top` is applied inside `aggregateModels`, before the unpriced filter runs, on rows sorted by cost + savings descending. Unpriced rows are $0 on both -- `findUnpricedModels` excludes anything carrying a local-savings baseline -- so they always sort last, and any `--top N` smaller than the number of priced models removed exactly the rows `--unpriced` exists to show. In table form the user then read "No model usage found for the selected period", which is the wrong answer twice over: they do have unpriced models, and nothing tells them the two flags fought. The slice now happens after the filter when `--unpriced` is set. Also adds the flag to the README models table and a changelog entry -- it was added for #969, and a filter nobody can discover does not help anyone find their unpriced models. Follow-up to #985.
Why
Related to #969.
The TUI warning for unpriced models points users at
codeburn model-alias, but the detailed model list is still hard to reach/copy from the dashboard.codeburn modelsis already the plain-stdout escape hatch, so this adds a focused filter for the affected rows.What
codeburn models --unpriced.0.findUnpricedModelslogic so local/free/aliased/overridden models are treated the same as the dashboard warning.Validation
npx vitest run tests/models-report.test.tsnpm run build:clinode dist/cli.js models --unpriced --from 2026-05-09 --to 2026-05-09 --provider claude --format jsonNote
I also tried
npm test -- tests/models-report.test.ts, but the script ignores the positional file argument and ran the broad suite. That broad run failed in unrelated cache/history CLI tests due the local environment picking up existing usage data; the targeted suite above passes.