From b18ee6f1a1e63152bcac0c4d7eb67c0eae1faccb Mon Sep 17 00:00:00 2001 From: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com> Date: Thu, 20 Aug 2026 18:10:06 +0800 Subject: [PATCH] fix(spend): notify shared dashboard on independent token pubs Independent spend-dashboard providers (Claude/Cursor/etc, usesSpendDashboardIndependentTokenSnapshot) published to spendDashboardTokenPublications but never triggered sharedSpendDashboardController update, so background token refreshes completed without updating the Usage & Spend pane or Overview spend until the next config change or pane re-open. Add synchronizeSharedSpendDashboardAfterTokenPublication call in publishSpendDashboardTokenSnapshotState and widen guard to include independent providers, matching the Codex path that already drove the shared dashboard. Background token cost imports now silently refresh the shared publication. --- Sources/CodexBar/UsageStore+SpendDashboardPublication.swift | 6 ++++-- Sources/CodexBar/UsageStore+SpendDashboardTokenCost.swift | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/CodexBar/UsageStore+SpendDashboardPublication.swift b/Sources/CodexBar/UsageStore+SpendDashboardPublication.swift index 4c1bfb3ab7..9b653e1296 100644 --- a/Sources/CodexBar/UsageStore+SpendDashboardPublication.swift +++ b/Sources/CodexBar/UsageStore+SpendDashboardPublication.swift @@ -62,8 +62,10 @@ extension UsageStore { } func synchronizeSharedSpendDashboardAfterTokenPublication(for provider: UsageProvider) { - // Provider-specific by design: regular Codex publication triggers the account-scoped spend producer. - guard provider == .codex, self.sharedSpendDashboardObservationStarted else { return } + guard self.sharedSpendDashboardObservationStarted else { return } + // Codex and independent spend-dashboard token publications both drive the shared dashboard. + let isIndependent = Self.usesSpendDashboardIndependentTokenSnapshot(provider) + guard provider == .codex || isIndependent else { return } self.applySharedSpendDashboardConfiguration( SpendDashboardSource.configuration(settings: self.settings, store: self)) } diff --git a/Sources/CodexBar/UsageStore+SpendDashboardTokenCost.swift b/Sources/CodexBar/UsageStore+SpendDashboardTokenCost.swift index 5103b7749c..6b55bc227c 100644 --- a/Sources/CodexBar/UsageStore+SpendDashboardTokenCost.swift +++ b/Sources/CodexBar/UsageStore+SpendDashboardTokenCost.swift @@ -178,6 +178,7 @@ extension UsageStore { publicationRevision: self.spendDashboardTokenSnapshotPublicationRevision(for: provider), providerConfigRevision: self.settings.providerConfigRevision(for: provider), scopeSignature: self.spendDashboardTokenSnapshotScopeSignature(for: provider)) + self.synchronizeSharedSpendDashboardAfterTokenPublication(for: provider) } private func spendDashboardTokenRefreshPublicationIsCurrent(