Skip to content

fix(savings): show only ledger-resident models with actual costs; consistent TTY styling#111

Closed
ztkent wants to merge 3 commits into
zzet:mainfrom
ztkent:main
Closed

fix(savings): show only ledger-resident models with actual costs; consistent TTY styling#111
ztkent wants to merge 3 commits into
zzet:mainfrom
ztkent:main

Conversation

@ztkent

@ztkent ztkent commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What

Replaces the counterfactual per-model cost table with actual attribution from ModelTotals, applies consistent TTY styling across all dashboard sections, and removes the top-level $ cost avoided headline.

Before — 26 models shown regardless of usage, all priced against the same token count:

Cost avoided per model (all time):
  claude-haiku-4-5      $0.4732
  claude-mythos-preview $4.73
  claude-opus-4-6       $2.37
  claude-opus-4-7       $2.37
  claude-opus-4-8       $2.37
  claude-sonnet-4-6     $1.42
  deepseek-chat         $0.1278
  ...19 more rows...

Cost avoided per model (actual — attributed via host model hint):
  claude-sonnet-4-6 $0.2586   (10 calls · 86,214 tokens saved)

After — only models present in the ledger, costs from real usage:

cost avoided per model (all time)
  claude-sonnet-4-6   $0.2586   11 calls · 86,214 tokens saved

savings by client (all time)
  claude-code         $0.3193   11 calls · 63,862 tokens saved

per-repo totals (all time)
  a-repo        $0.2921   58,424 tokens saved   7 calls
  b-repo        $0.0213    4,267 tokens saved   1 calls
  c-repo        $0.0059    1,171 tokens saved   2 calls

per-language totals (all time)
  go               $0.3193   63,862 tokens saved   11 calls

Why this shape

CostAvoidedAll iterates the full pricing table and applies one shared token count to every entry — it answers "what would these tokens have cost on each model?" rather than "what did this model actually cost?". That counterfactual table is useful in the JSON output (consumers can pick any model for their own calculations) but wrong for the human-facing dashboard, where every row looked like a real figure.

ModelTotals already provides the correct data: per-model token counts from the ledger, each rescaled through its own tokenizer. The two sections were shown in the wrong order under confusing labels.

The TTY-path styling now mirrors the existing headline throughout: progress.Heading for section titles, StatGood (green) for dollar amounts, StatNeutral (bold) for counts.

Tests

  • Updated TestEmitSavingsDashboard_RendersThreeBuckets — assertion changed from "Cost avoided:" (removed headline) to "Cost avoided per model (all time):".
  • go test ./internal/savings/... ./cmd/gortex/... passes.

Notes

  • CostAvoidedAll is retained for the JSON output path (cost_avoided_usd on bucket entries) where it remains useful for downstream consumers.
  • The --model flag still controls the model used for per-bucket bar-chart costs.
  • A (none — no model hint captured yet) fallback renders when no session has written a model hint yet.

ztkent added 3 commits June 18, 2026 10:18
Remove the counterfactual per-model table (CostAvoidedAll over the full
pricing table) and replace it with actual attribution from ModelTotals.
Only models present in the ledger are shown; each model's cost is derived
from its real token usage scaled to its own tokenizer.

Apply consistent TTY styling (Heading, Stat/StatGood/StatNeutral,
StatStrip) to all dashboard sections: cost avoided per model, savings by
client, per-repo totals, and per-language totals. Each row now shows a
green price alongside the bold counts.

Remove the top-level "$ cost avoided" headline (a counterfactual guess);
actual cost is authoritative in the per-model section.
@ztkent

ztkent commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Reopening from a dedicated feature branch (feature/savings-actual-model-costs) rebased on current upstream main — this PR was inadvertently based on my fork's main while it was stale.

@ztkent ztkent closed this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant