From 94240f53410311b7a3a5d3af24ec5e08d22aa5f4 Mon Sep 17 00:00:00 2001 From: AgentSeal Date: Sat, 18 Apr 2026 13:18:11 -0700 Subject: [PATCH] fix(mac): show correct cost in trend tooltip for per-provider views The trend chart tooltip always displayed `bar.tokens` in its header, which is zero for provider-filtered history (the CLI only carries per-provider cost+calls in the daily cache, not tokens). Result: when you selected Claude/Codex/Cursor/Pi, hovering a bar showed $0.00 even on days with real spend. The trend chart's main metric already falls back to cost when tokens are zero. Pass that same metric value through to the tooltip so both stay consistent. Also removed the misleading "No model breakdown available" fallback line. For provider-filtered views the per-model breakdown legitimately doesn't exist in the payload, so the tooltip now just shows date + cost without the error-sounding message. --- .../CodeBurnMenubar/Views/HeatmapSection.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mac/Sources/CodeBurnMenubar/Views/HeatmapSection.swift b/mac/Sources/CodeBurnMenubar/Views/HeatmapSection.swift index ed9a03b..8b64e2b 100644 --- a/mac/Sources/CodeBurnMenubar/Views/HeatmapSection.swift +++ b/mac/Sources/CodeBurnMenubar/Views/HeatmapSection.swift @@ -209,7 +209,7 @@ private struct TrendChart: View { // Floats below the chart without taking layout space. Opaque dark card hides // whatever sits beneath it (mini stats, activity rows). if let hoveredBar { - BarTooltipCard(bar: hoveredBar, formatValue: formatValue) + BarTooltipCard(bar: hoveredBar, value: metric(hoveredBar), formatValue: formatValue) .padding(.top, 6) .offset(y: 92) .transition(.opacity) @@ -260,6 +260,12 @@ private struct BarColumn: View { private struct BarTooltipCard: View { let bar: TrendBar + /// Value to display in the tooltip header. Matches the metric the trend chart + /// is currently using (tokens when the .all-providers view has token data, + /// cost when provider-filtered views force a $ fallback). Passing this in keeps + /// the tooltip in sync with the chart instead of always reading bar.tokens, + /// which is zero for provider-filtered days. + let value: Double let formatValue: (Double) -> String @Environment(\.colorScheme) private var colorScheme @@ -290,7 +296,7 @@ private struct BarTooltipCard: View { .font(.system(size: 11, weight: .semibold)) .foregroundStyle(primaryText) Spacer() - Text("\(formatValue(bar.tokens))") + Text("\(formatValue(value))") .font(.codeMono(size: 10.5, weight: .semibold)) .foregroundStyle(Theme.brandAccent) } @@ -313,10 +319,6 @@ private struct BarTooltipCard: View { } } } - } else { - Text("No model breakdown available") - .font(.system(size: 10)) - .foregroundStyle(tertiaryText) } } .padding(11)