Desktop app "Total Tokens" stat is a truncated ~6-week window, not lifetime — mismatches CLI's own Stats screen on same machine
Environment
- Claude Desktop (macOS), Claude Code CLI v2.1.226
- stats-cache.json version 5
Symptom
The Desktop app's dashboard "Total Tokens" widget shows a much smaller number
than the CLI's own Stats screen (claude → Stats tab), reading from the same
local stats-cache.json on the same machine at the same time.
- Desktop widget: ~8.05B tokens
- CLI /stats screen: ~26.4B tokens (confirmed correct against a direct sum
of modelUsage in the cache file)
Root cause (traced locally)
stats-cache.json carries two structures that should agree but don't:
modelUsage: lifetime cumulative dict, correctly includes cacheRead/
cacheCreation tokens, full history back to first session.
dailyModelTokens: per-day breakdown array, versioned via
dailyModelTokensVersion. After a CLI reinstall bumped this to a new
schema (to include cache tokens per day), the array's history was not
backfilled — it only contains ~39 days, not the full session history.
dailyActivity (a structurally similar per-day array) was carried
forward with full history intact during the same migration, so this
truncation is specific to dailyModelTokens.
The Desktop widget's total (8.05B) matches the sum of the truncateddailyModelTokens array exactly. The CLI's Stats screen total (26.4B)
matches the sum of modelUsage, which has full history.
Suggested fix
Point the Desktop "Total Tokens" tile at modelUsage (like the CLI already
does) instead of summing dailyModelTokens, or backfill dailyModelTokens
fully during schema migration rather than only from local transcripts still
on disk.
Repro
Compare Desktop dashboard "Total Tokens" against claude → Stats tab
"Total tokens" on any account where the CLI has recently been reinstalled
or migrated across a stats-cache schema version bump.