Bug Description
The web dashboard (codeburn web -p 30days) shows incorrect values for the Cache read and Cache write stat cards. They display totals from the entire history.daily array (up to 365 days of backfill), rather than only the data within the user-selected period (e.g. 30 days).
Steps to Reproduce
- Run
codeburn report -p 30days in the terminal
- Run
codeburn web -p 30days and open the web dashboard
- Compare the "cached" value in the terminal with the "Cache read" card in the web UI
Expected Behavior
Both views should show the same Cache read value for the same period (30 days).
Actual Behavior
- Terminal (
report -p 30days): shows 1391.1M cached
- Web (
web -p 30days): shows Cache read: 2.07B
The web value is ~1.5x larger because it sums over ~365 days of history data.
Root Cause
In the web frontend (dist/dash/assets/index-*.js), the Cache read/write cards compute their values by reducing over the entire e.history.daily array:
l = (e?.history.daily) ?? []
o = l.reduce((b,x) => b + x.cacheWriteTokens, 0) // Cache write card
c = l.reduce((b,x) => b + x.cacheReadTokens, 0) // Cache read card
However, history.daily is populated from BACKFILL_DAYS = 365 days of cached data (for the trend chart), not limited to the current period. Meanwhile, other cards (Cost, Calls, Sessions, Tokens in/out) correctly use e.current which is properly scoped to the selected period.
Suggested Fix
The frontend should use e.current.tokens.cacheRead and e.current.tokens.cacheWrite (which are correctly scoped to the period in buildMenubarPayload) instead of summing history.daily.
Alternatively, filter history.daily to only include dates within the selected period before summing.
Environment
- codeburn version: 0.9.14
- OS: macOS (Darwin 25.3.0)
- Node: v24.13.0
Bug Description
The web dashboard (
codeburn web -p 30days) shows incorrect values for the Cache read and Cache write stat cards. They display totals from the entirehistory.dailyarray (up to 365 days of backfill), rather than only the data within the user-selected period (e.g. 30 days).Steps to Reproduce
codeburn report -p 30daysin the terminalcodeburn web -p 30daysand open the web dashboardExpected Behavior
Both views should show the same Cache read value for the same period (30 days).
Actual Behavior
report -p 30days): shows1391.1M cachedweb -p 30days): showsCache read: 2.07BThe web value is ~1.5x larger because it sums over ~365 days of history data.
Root Cause
In the web frontend (
dist/dash/assets/index-*.js), the Cache read/write cards compute their values by reducing over the entiree.history.dailyarray:However,
history.dailyis populated fromBACKFILL_DAYS = 365days of cached data (for the trend chart), not limited to the current period. Meanwhile, other cards (Cost, Calls, Sessions, Tokens in/out) correctly usee.currentwhich is properly scoped to the selected period.Suggested Fix
The frontend should use
e.current.tokens.cacheReadande.current.tokens.cacheWrite(which are correctly scoped to the period inbuildMenubarPayload) instead of summinghistory.daily.Alternatively, filter
history.dailyto only include dates within the selected period before summing.Environment