Fix provider tabs showing wrong costs when period changes

The AgentTabStrip was using allProvidersToday for cost display, which
meant tabs always showed today's per-provider costs regardless of
which period was selected. This caused the hero to show e.g. $209 for
30 Days but the Claude tab to show $59 (today's Claude cost).

Fix: cost(for:) now reads from store.payload (selected period) instead
of allProvidersToday. Tab VISIBILITY still uses todayPayload so tabs
don't disappear when switching periods.

Bug existed since the original menubar app commit (495a254, Apr 17).
This commit is contained in:
iamtoruk 2026-04-25 01:33:24 +02:00 committed by AgentSeal
parent d54e88fdbb
commit bfcae0f84e

View file

@ -25,9 +25,9 @@ struct AgentTabStrip: View {
}
}
/// Drive tab visibility and per-tab cost labels from the *all-provider* payload (today),
/// not the currently selected provider's payload. Without this, switching to Codex (which
/// has no data) would hide every other tab including Claude.
/// Drive tab VISIBILITY from the all-provider today payload so tabs don't disappear
/// when switching periods or to a provider with no data. Cost values come from
/// store.payload (the selected period) via cost(for:).
private var allProvidersToday: MenubarPayload {
store.todayPayload ?? store.payload
}
@ -46,13 +46,16 @@ struct AgentTabStrip: View {
}
}
/// Cost for the selected period, not pinned to today. The hero shows payload.current.cost,
/// so these tabs must match. Tab VISIBILITY is still driven by todayPayload (via
/// visibleFilters) so that tabs don't disappear when switching periods.
private func cost(for filter: ProviderFilter) -> Double? {
switch filter {
case .all:
return allProvidersToday.current.cost
return store.payload.current.cost
default:
let key = filter.rawValue.lowercased()
return allProvidersToday.current.providers[key]
return store.payload.current.providers[key]
}
}
}