Files
steipete--codexbar/Sources/CodexBar/MenuCardView+ModelInput.swift
Urda b2264c0c6e feat: add a Show pace setting for usage bars (#3055)
CodexBar always drew the green and red pace stripe inside usage
progress bars, and the forecast text below them ("32% in reserve -
Lasts until reset"). No preference controlled either one.

Add a single paceVisible setting, on by default. Turning it off hides
both together, everywhere the usage card renders.

- Gate once in UsageMenuCardView.Model.make through paceGatedMetrics.
  That covers both UsageProgressBar call sites and every metric lane,
  including the primary lane, which builds from
  PrimaryMetricPresentation rather than a PaceDetail.
- Guard the three plain-menu pace entries in MenuDescriptor, which
  renders from UsagePaceText directly rather than from the gated model.
- Sync the flag as an optional Bool, matching the workdayTickAppearance
  precedent, so payloads written by older builds still decode.
- Register the setting in menuObservationToken so an open menu redraws
  without a restart.

Hiding pace also clears provider text that shares the same row: Kiro
bonus credits, the Copilot and Zenmux reset description, and Synthetic
regen labels. That is deliberate. Separating them needs per-provider
provenance, which is out of scope here.

Re-anchor 17 ProviderArchitectureGatekeeperTests catalog entries whose
pinned line numbers shifted.
2026-08-18 16:56:34 -07:00

140 lines
6.2 KiB
Swift

import CodexBarCore
import Foundation
extension UsageMenuCardView.Model {
struct Input {
let provider: UsageProvider
let metadata: ProviderMetadata
let snapshot: UsageSnapshot?
let codexProjection: CodexConsumerProjection?
let credits: CreditsSnapshot?
let creditsError: String?
let dashboard: OpenAIDashboardSnapshot?
let dashboardError: String?
let tokenSnapshot: CostUsageTokenSnapshot?
let tokenError: String?
let account: AccountInfo
let accountIsAuthoritative: Bool
let planOverride: String?
let isRefreshing: Bool
let lastError: String?
let limitsAvailability: UsageLimitsAvailability?
let usageBarsShowUsed: Bool
let resetTimeDisplayStyle: ResetTimeDisplayStyle
let tokenCostUsageEnabled: Bool
let tokenCostIsRefreshing: Bool
let codexLocalSessionCostLedgerEnabled: Bool
let costSummaryInlineEnabled: Bool
let tokenCostMenuSectionEnabled: Bool
let costComparisonPeriodsEnabled: Bool
let showOptionalCreditsAndExtraUsage: Bool
let claudeDailyRoutinesUsageVisible: Bool
let codexSparkUsageVisible: Bool
let copilotBudgetExtrasEnabled: Bool
/// Provider details is the diagnostic surface and lists every usage lane a provider reports.
/// The menu and widgets stay curated and may drop lanes that carry no information.
let showsAllUsageLanes: Bool
let sourceLabel: String?
let subtitleOverride: String?
let kiloAutoMode: Bool
let hidePersonalInfo: Bool
let weeklyPace: UsagePace?
let sessionEquivalentForecast: SessionEquivalentForecast?
let quotaWarningThresholds: [QuotaWarningWindow: [Int]]
let workDaysPerWeek: Int?
let workdayTickAppearance: WorkdayTickAppearance
let paceVisible: Bool
let usesLiveSubtitle: Bool
let preferredCurrencyCode: String
let now: Date
init(
provider: UsageProvider,
metadata: ProviderMetadata,
snapshot: UsageSnapshot?,
codexProjection: CodexConsumerProjection? = nil,
credits: CreditsSnapshot?,
creditsError: String?,
dashboard: OpenAIDashboardSnapshot?,
dashboardError: String?,
tokenSnapshot: CostUsageTokenSnapshot?,
tokenError: String?,
account: AccountInfo,
accountIsAuthoritative: Bool = false,
planOverride: String? = nil,
isRefreshing: Bool,
lastError: String?,
limitsAvailability: UsageLimitsAvailability? = nil,
usageBarsShowUsed: Bool,
resetTimeDisplayStyle: ResetTimeDisplayStyle,
tokenCostUsageEnabled: Bool,
tokenCostIsRefreshing: Bool = false,
codexLocalSessionCostLedgerEnabled: Bool = false,
costSummaryInlineEnabled: Bool? = nil,
tokenCostMenuSectionEnabled: Bool? = nil,
costComparisonPeriodsEnabled: Bool = false,
showOptionalCreditsAndExtraUsage: Bool,
claudeDailyRoutinesUsageVisible: Bool = true,
codexSparkUsageVisible: Bool = true,
copilotBudgetExtrasEnabled: Bool = false,
showsAllUsageLanes: Bool = false,
sourceLabel: String? = nil,
subtitleOverride: String? = nil,
kiloAutoMode: Bool = false,
hidePersonalInfo: Bool,
weeklyPace: UsagePace? = nil,
sessionEquivalentForecast: SessionEquivalentForecast? = nil,
quotaWarningThresholds: [QuotaWarningWindow: [Int]] = [:],
workDaysPerWeek: Int? = nil,
workdayTickAppearance: WorkdayTickAppearance = .subtle,
paceVisible: Bool = true,
usesLiveSubtitle: Bool = false,
preferredCurrencyCode: String = "auto",
now: Date)
{
self.provider = provider
self.metadata = metadata
self.snapshot = snapshot
self.codexProjection = codexProjection
self.credits = credits
self.creditsError = creditsError
self.dashboard = dashboard
self.dashboardError = dashboardError
self.tokenSnapshot = tokenSnapshot
self.tokenError = tokenError
self.account = account
self.accountIsAuthoritative = accountIsAuthoritative
self.planOverride = planOverride
self.isRefreshing = isRefreshing
self.lastError = lastError
self.limitsAvailability = limitsAvailability
self.usageBarsShowUsed = usageBarsShowUsed
self.resetTimeDisplayStyle = resetTimeDisplayStyle
self.tokenCostUsageEnabled = tokenCostUsageEnabled
self.tokenCostIsRefreshing = tokenCostIsRefreshing
self.codexLocalSessionCostLedgerEnabled = codexLocalSessionCostLedgerEnabled
self.costSummaryInlineEnabled = costSummaryInlineEnabled ?? tokenCostUsageEnabled
self.tokenCostMenuSectionEnabled = tokenCostMenuSectionEnabled ?? tokenCostUsageEnabled
self.costComparisonPeriodsEnabled = costComparisonPeriodsEnabled
self.showOptionalCreditsAndExtraUsage = showOptionalCreditsAndExtraUsage
self.claudeDailyRoutinesUsageVisible = claudeDailyRoutinesUsageVisible
self.codexSparkUsageVisible = codexSparkUsageVisible
self.copilotBudgetExtrasEnabled = copilotBudgetExtrasEnabled
self.showsAllUsageLanes = showsAllUsageLanes
self.sourceLabel = sourceLabel
self.subtitleOverride = subtitleOverride
self.kiloAutoMode = kiloAutoMode
self.hidePersonalInfo = hidePersonalInfo
self.weeklyPace = weeklyPace
self.sessionEquivalentForecast = sessionEquivalentForecast
self.quotaWarningThresholds = quotaWarningThresholds
self.workDaysPerWeek = workDaysPerWeek
self.workdayTickAppearance = workdayTickAppearance
self.paceVisible = paceVisible
self.usesLiveSubtitle = usesLiveSubtitle
self.preferredCurrencyCode = preferredCurrencyCode
self.now = now
}
}
}