Skip to content

fix(models): group Trend rows and the models command by the same display name - #1241

Merged
iamtoruk merged 1 commit into
mainfrom
fix/1239-model-grouping
Sep 2, 2026
Merged

iamtoruk merged 1 commit into
mainfrom
fix/1239-model-grouping

Conversation

@iamtoruk

@iamtoruk iamtoruk commented Sep 2, 2026

Copy link
Copy Markdown
Member

Fixes #1239

Problem

The desktop Trend/Spend view built its per-day model rows straight from the raw provider/model string (day.models[call.model] in day-aggregator.ts), while codeburn models already merges by alias-resolved canonical id. Same day, same data, two different ideas of what counts as "one model".

Fix

history.daily[].topModels (the payload backing the Trend/Spend charts) now merges by the same normalized display name codeburn models already uses (getShortModelName), via a new mergeDayModelsByDisplayName step in usage-aggregator.ts. Rows that fold two or more raw ids together carry a new optional rawModels field so a cached vs uncached route stays visible. codeburn models gets the same field (ModelReportRow.rawModels) so its JSON output shows the collapsed routes too. Both changes are additive to the CLI-app payload contract — no field renamed or removed.

The desktop StackedBars tooltip appends the route list when more than one raw id fed a segment.

Before / after (2026-08-26, real data)

Before (issue report):

  • Trend tooltip: minimax/MiniMax-M3 $6.99 / 23.1M tok, and MiniMaxAI/MiniMax-M3 as a separate row
  • codeburn models: one row "MiniMax M3", 415 calls, 27.25M tok, $7.36

After (this branch, node dist/cli.js status --format menubar-json --from 2026-08-26 --to 2026-08-26 and node dist/cli.js models --from 2026-08-26 --to 2026-08-26 --format json):

  • Trend (history.daily[].topModels): one row, "name": "MiniMax M3", "rawModels": ["minimax/MiniMax-M3", "MiniMaxAI/MiniMax-M3"]
  • codeburn models: unchanged single row (415 calls, 27.25M tok, $7.36), now also carrying "rawModels": ["minimax/MiniMax-M3", "MiniMaxAI/MiniMax-M3"]

Both surfaces now agree, and the route split is still visible on both.

Test plan

  • npx vitest run tests/models-report.test.ts tests/usage-aggregator.test.ts (root) — new tests cover the MiniMax merge + rawModels
  • npx vitest run (app/) — full app suite green except the 27 pre-existing unrelated usePolled.test.ts / overviewSnapshot.test.ts localStorage failures
  • npx tsc --noEmit at root and in app/ — clean
  • npm run build then verified against real session data for 2026-08-26 (see before/after above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trend view and codeburn models group the same model under different rows

1 participant