Skip to content

feat: add daily cost charts to dashboard#17

Merged
sleipi merged 13 commits into
mainfrom
feat/daily-cost-charts
Jun 25, 2026
Merged

feat: add daily cost charts to dashboard#17
sleipi merged 13 commits into
mainfrom
feat/daily-cost-charts

Conversation

@sleipi

@sleipi sleipi commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add Daily Cost (last 60 days) bar chart with 5-day moving average line, rendered directly below the existing Daily Token Usage chart
  • Add Daily Cost by Model (last 60 days) stacked bar chart, rendered directly below the existing Daily Token Usage by Model chart
  • No DB migrations needed — reads from existing daily_usage.cost_total and messages.cost columns

Changes

Data layer

  • DailyUsageRepo + SqliteDailyUsageRepo: getHistoryUntilCost() reads rolled-up cost history
  • MessageRepo + SqliteMessageRepo: getTodayCost() + getDailyModelCost() for live cost data
  • DailyTokensService: getDailyCost() + getDailyModelCost() merge history with live today

Templates

  • daily-chart.ts: renderDailyCostChart() — mirrors token chart, uses fmtCost() for labels/tooltips
  • model-chart.ts: renderDailyModelCostChart() — mirrors model chart, uses fmtCost() in tooltips

Wiring

  • sessions-fragment, page-template, stats-route, page-route updated to thread new data arrays through

Test plan

  • 164 unit tests pass (bun test tests/unit)
  • bun x tsc --noEmit clean
  • Biome check passes
  • Dashboard shows cost charts below token charts in left panel
  • Tooltips show $X.XX formatted values on hover
  • Cost by model chart shows correct color-coded stacked bars per model

🤖 Generated with Claude Code

sleipi and others added 13 commits June 25, 2026 14:04
- Add getDailyCost() method that merges today's cost with 60-day history
- Add getDailyModelCost() method that delegates to message repo
- Update stub repos in tests with new cost methods (getTodayCost, getDailyModelCost, getHistoryUntilCost)
- Add 3 new tests: getDailyCost gap filling, cost merging, and model cost delegation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds getDailyCost/getDailyModelCost calls through routes and templates,
rendering cost charts in the left panel alongside token usage charts.
Also fixes missing getTodayCost/getDailyModelCost/getHistoryUntilCost
stubs in four test files to satisfy the updated MessageRepo/DailyUsageRepo interfaces.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
OpenCode expects plugins in ~/.config/opencode/plugins/ to have a
default export of shape { server: Plugin } (PluginModule type).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sleipi sleipi merged commit 4e0ed8c into main Jun 25, 2026
6 checks passed
@sleipi sleipi deleted the feat/daily-cost-charts branch June 25, 2026 14:17
@sleipi sleipi added the enhancement New feature or request label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant