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.
This commit is contained in:
AgentSeal 2026-04-18 13:18:11 -07:00
parent 70f47f8d9e
commit 94240f5341

View file

@ -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)