Skip to content

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

Merged
zzet merged 2 commits into
zzet:mainfrom
ztkent:feature/savings-actual-model-costs
Jun 18, 2026
Merged

fix(savings): show only ledger-resident models with actual costs; consistent TTY styling#112
zzet merged 2 commits into
zzet:mainfrom
ztkent:feature/savings-actual-model-costs

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):
  repo-a   $0.2921   58,424 tokens saved   7 calls
  repo-b   $0.0213    4,267 tokens saved   1 calls
  repo-c   $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 is now consistent across every section: bold section titles (capitalized, colon-terminated to match the non-TTY output), StatGood (green) for dollar amounts, and 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 2 commits June 18, 2026 10:34
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.
Match the non-TTY output: section titles are bold, capitalized, and
end with a colon instead of the lowercased no-colon progress.Heading
style.
@zzet zzet merged commit f1ab54a into zzet:main Jun 18, 2026
10 checks passed
@ztkent ztkent deleted the feature/savings-actual-model-costs branch June 18, 2026 16:14
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.

2 participants