Skip to content

feat(gain-web): cost / model-tier economics pane (depends #162) #175

Description

@thehoff

Background

Three-way brainstorm consensus (Claude + Codex + agy 2026-05-25): the dashboard surfaces tokens saved, but not dollars saved. ContextCrawler already has the math — `src/analytics/cc_economics.rs` and `src/analytics/ccusage.rs` carry per-tier pricing for Claude (Sonnet, Opus, Haiku). The dashboard just doesn't plug into it.

Problem

The Hoff's TRAIT is cost-efficiency-focused — "evaluates component pricing against alternatives before committing". Right now the cost story lives in `gain --quota --tier 20x` text-mode. Glanceable dollar value belongs on the dashboard.

Proposed scope

New endpoint

```
GET /api/economics?tier=sonnet-4.6&period=30d
```

Returns:

```json
{
"tier": "sonnet-4.6",
"period": "30d",
"input_price_per_mtok": 3.0,
"output_price_per_mtok": 15.0,
"tokens_saved": 76099018,
"dollars_saved": 228.30,
"by_command": [
{"cmd": "contextcrawler rg", "saved": 17482753, "dollars": 52.45},
...
],
"by_day": [{"date": "2026-05-24", "dollars": 12.18}, ...]
}
```

Backed by `cc_economics::price_for_tier()` + `Tracker::get_summary_filtered` / `get_all_days`.

New dashboard pane: Cost

  • Hero cards: lifetime dollars saved, last 30d dollars, dollars / day average
  • Tier picker dropdown (sonnet-4.6 / opus-4.7 / haiku-4.5 / custom)
  • Per-command leaderboard ranked by dollars saved (not just tokens)
  • By-day spend chart (savings as positive bars in neon green; could compare against an actual spend baseline if `ccusage` data present)

Frontend

Single new `cost: async()` loader in `assets/index.html`. Reuse existing card + table CSS, no new components.

Out of scope (v1)

  • Local-model pricing (Qwen / Gemma / Granite on BC-250 cluster) — own issue ([#TBD]). Needs amortised hardware cost + power model.
  • Cross-tier comparison view ("this command would cost X on Opus, Y on Sonnet") — could be a v2 add to the same pane.
  • Historical price changes (Anthropic price-cuts) — v2.

Effort

S - M. The math exists. Mostly endpoint + frontend pane.

  • Endpoint + tests: 1 day
  • Frontend pane: 1 day
  • Doc + screenshot: half day

Why now

Three-of-three brainstorm models picked this as a top-tier add. The dashboard surfaces ContextCrawler's value already — the dollar overlay is what makes that value executive-shareable, not just developer-glanceable.

Dependencies

#162 (the dashboard surface) — merged or about-to-be.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions