Skip to content

Commit d814f27

Browse files
HduSyclaude
andcommitted
feat: color cost-by-model donut by cost rank, not model identity
The donut wedges are sized by cost but were colored by the backend's token-rank palette, so the biggest-cost model could get a non-prominent color. CostDonut now ranks models by cost (desc) and maps the palette by that rank, so the largest cost share always gets the leading color. Bump version to 0.1.10. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 579ded4 commit d814f27

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tokenscope"
3-
version = "0.1.9"
3+
version = "0.1.10"
44
description = "Claude CLI token usage dashboard"
55
authors = ["you"]
66
edition = "2021"

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "Tokenscope",
4-
"version": "0.1.9",
4+
"version": "0.1.10",
55
"identifier": "com.tokenscope.app",
66
"build": {
77
"beforeDevCommand": "pnpm dev",

src/charts.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,21 @@ export function Sparkline({ values, theme, width = 80, height = 24, accent, stro
119119
);
120120
}
121121

122+
// Cost-rank palette: darkest/most-prominent green for the biggest cost share,
123+
// fading down. Colors map to the *cost* ordering here (not the backend's
124+
// token-rank), so the largest wedge always gets the leading color.
125+
const DONUT_PALETTE = ["#1f9d63", "#34c27e", "#6ad0a0", "#a7e3c5", "#4b5a52"];
126+
const DONUT_OVERFLOW = "#79817b";
127+
122128
export function CostDonut({ models, theme, size = 104, thickness = 16 }:
123129
{ models: ModelStat[]; theme: Theme; size?: number; thickness?: number }) {
124130
const t = theme;
125131
const [hi, setHi] = useState(-1);
132+
// Rank by cost (desc) and recolor by that rank — usage from most to least.
133+
const ranked = [...models]
134+
.sort((a, b) => b.cost - a.cost)
135+
.map((m, i) => ({ ...m, color: i < DONUT_PALETTE.length ? DONUT_PALETTE[i] : DONUT_OVERFLOW }));
136+
models = ranked;
126137
const total = models.reduce((s, m) => s + m.cost, 0) || 1e-9;
127138
const cx = size / 2, cy = size / 2;
128139
const rOut = (size - 2) / 2, rIn = rOut - thickness;

0 commit comments

Comments
 (0)