From bfcae0f84e8c41369c8796fa7c010d8c1eb59b2d Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Sat, 25 Apr 2026 01:33:24 +0200 Subject: [PATCH] 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). --- .../CodeBurnMenubar/Views/AgentTabStrip.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mac/Sources/CodeBurnMenubar/Views/AgentTabStrip.swift b/mac/Sources/CodeBurnMenubar/Views/AgentTabStrip.swift index e4522dd..cb0ad1c 100644 --- a/mac/Sources/CodeBurnMenubar/Views/AgentTabStrip.swift +++ b/mac/Sources/CodeBurnMenubar/Views/AgentTabStrip.swift @@ -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] } } }