Skip to content

[Phase 5.2] Cost analytics page: total spend and time range #557

@frankbria

Description

@frankbria

Goal

Create a /costs page (or Costs section in Settings) that surfaces total AI spend from the existing token_usage DB table.

Background

Token usage is already recorded per task. It is not surfaced anywhere in the web UI. Users need to know what they are spending.

Scope

  • New route /costs linked from sidebar
  • Summary cards: total spend in the selected period, total tasks run, average cost per task
  • Time range selector: Last 7 days / 30 days / 90 days (default 30)
  • Spend-over-time chart: daily bar chart using Recharts or similar already used in the codebase
  • Backend: add GET /api/v2/costs/summary?days=30 that aggregates token_usage rows into daily buckets with cost calculated from model pricing table (hardcode sensible defaults per model, allow override via env)

Out of scope

  • Per-task or per-agent breakdown (separate issue)
  • Budget alerts

Acceptance criteria

  • /costs renders with summary cards and chart
  • Time range selector updates the chart
  • Empty state shown when no data
  • npm test and npm run build pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestphase-5Phase 5: Advanced Features & Polish

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions