CodexBar 是一个 macOS 菜单栏应用,用于查看本机 Codex 账号状态、额度、Token 用量、详细统计信息
Swift appkitcodexcodex-clideveloper-toolsmacosmacos-appmenu-bar-appopenai-codexproductivityswiftswiftuiusage-tracker
fix: 标记补充数据不可信状态
Bob6c16aa79de0b
diff --git a/CodexBar.xcodeproj/project.pbxproj b/CodexBar.xcodeproj/project.pbxprojindex 36b46bf..0619432 100644--- a/CodexBar.xcodeproj/project.pbxproj+++ b/CodexBar.xcodeproj/project.pbxproj@@ -275,7 +275,7 @@"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;- CURRENT_PROJECT_VERSION = 11;+ CURRENT_PROJECT_VERSION = 12;DEVELOPMENT_TEAM = 4KJ362VJW5;ENABLE_APP_INTENTS_METADATA_GENERATION = NO;ENABLE_APP_SANDBOX = NO;@@ -290,7 +290,7 @@"$(inherited)","@executable_path/../Frameworks",);- MARKETING_VERSION = 2.1.0;+ MARKETING_VERSION = 2.2.0;PRODUCT_BUNDLE_IDENTIFIER = app.zabrian.codexbar;PRODUCT_NAME = "$(TARGET_NAME)";REGISTER_APP_GROUPS = YES;@@ -312,7 +312,7 @@"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;- CURRENT_PROJECT_VERSION = 11;+ CURRENT_PROJECT_VERSION = 12;DEVELOPMENT_TEAM = 4KJ362VJW5;ENABLE_APP_INTENTS_METADATA_GENERATION = NO;ENABLE_APP_SANDBOX = NO;@@ -327,7 +327,7 @@"$(inherited)","@executable_path/../Frameworks",);- MARKETING_VERSION = 2.1.0;+ MARKETING_VERSION = 2.2.0;PRODUCT_BUNDLE_IDENTIFIER = app.zabrian.codexbar;PRODUCT_NAME = "$(TARGET_NAME)";PROVISIONING_PROFILE_SPECIFIER = "";diff --git a/CodexBar/Controllers/StatusItemController.swift b/CodexBar/Controllers/StatusItemController.swiftindex dab8ae1..7461d6a 100644--- a/CodexBar/Controllers/StatusItemController.swift+++ b/CodexBar/Controllers/StatusItemController.swift@@ -44,7 +44,7 @@ private final class StatusItemController: NSObject {private var deferredRefreshTask: Task<Void, Never>?private var popoverState = PopoverState.hiddenprivate var cancellables = Set<AnyCancellable>()- private var lastHasError: Bool?+ private var isShowingErrorImage: Bool?private static let normalImage = makeStatusImage("person.fill.checkmark")private static let errorImage = makeStatusImage("person.fill.xmark")@@ -110,26 +110,28 @@ private final class StatusItemController: NSObject {}private func observeViewModel() {- viewModel.$loadState- .map(\.isError)+ Publishers.CombineLatest(viewModel.$loadState, viewModel.$snapshot)+ .map { loadState, snapshot in+ loadState.isError || snapshot?.hasTrustedData == false+ }.removeDuplicates()- .sink { [weak self] hasError in- self?.updateStatusImage(hasError: hasError)+ .sink { [weak self] usesErrorImage in+ self?.updateStatusImage(usesErrorImage: usesErrorImage)}.store(in: &cancellables)}private func updateStatusImage() {- updateStatusImage(hasError: viewModel.hasError)+ updateStatusImage(usesErrorImage: viewModel.usesErrorImage)}- private func updateStatusImage(hasError: Bool) {- guard hasError != lastHasError else {+ private func updateStatusImage(usesErrorImage: Bool) {+ guard usesErrorImage != isShowingErrorImage else {return}- lastHasError = hasError- statusItem.button?.image = hasError ? Self.errorImage : Self.normalImage+ isShowingErrorImage = usesErrorImage+ statusItem.button?.image = usesErrorImage ? Self.errorImage : Self.normalImage}@objc private func statusItemClicked(_ sender: NSStatusBarButton) {diff --git a/CodexBar/Models/CodexQuotaModels.swift b/CodexBar/Models/CodexQuotaModels.swiftindex 33c17fc..20ad8ea 100644--- a/CodexBar/Models/CodexQuotaModels.swift+++ b/CodexBar/Models/CodexQuotaModels.swift@@ -16,6 +16,18 @@ nonisolated struct CodexQuotaSnapshot: Equatable {var planLabel: String? {account.planType ?? planType}++ var hasTrustedData: Bool {+ hasTrustedRateLimitsData || hasTrustedUsageData+ }++ private var hasTrustedRateLimitsData: Bool {+ !limits.isEmpty && !isRateLimitsStale+ }++ private var hasTrustedUsageData: Bool {+ usage != nil && !isUsageStale+ }}nonisolated struct CodexQuotaLimitSnapshot: Equatable, Identifiable {diff --git a/CodexBar/Services/CodexStatus/CodexStatusViewModel.swift b/CodexBar/Services/CodexStatus/CodexStatusViewModel.swiftindex 47d729b..63c6645 100644--- a/CodexBar/Services/CodexStatus/CodexStatusViewModel.swift+++ b/CodexBar/Services/CodexStatus/CodexStatusViewModel.swift@@ -25,6 +25,10 @@ final class CodexStatusViewModel: ObservableObject {@Published private(set) var autoRefreshCountdownStartedAt: Date?var hasError: Bool { loadState.isError }+ var hasUntrustedData: Bool {+ snapshot?.hasTrustedData == false+ }+ var usesErrorImage: Bool { hasError || hasUntrustedData }var autoRefreshInterval: TimeInterval { Self.refreshInterval }private static let refreshInterval: TimeInterval = 60diff --git a/appcast.xml b/appcast.xmlindex c013191..e8a2bfe 100644--- a/appcast.xml+++ b/appcast.xml@@ -7,6 +7,15 @@<link>https://codexbar.zabrian.app/appcast.xml</link><description>CodexBar appcast feed</description><language>zh-CN</language>+ <item>+ <title>CodexBar.app 2.2.0</title>+ <sparkle:version>12</sparkle:version>+ <sparkle:shortVersionString>2.2.0</sparkle:shortVersionString>+ <sparkle:minimumSystemVersion>15.0</sparkle:minimumSystemVersion>+ <sparkle:releaseNotesLink>https://codexbar.zabrian.app/notes/2.2.0.html</sparkle:releaseNotesLink>+ <pubDate>Fri, 19 Jun 2026 15:36:20 +0800</pubDate>+ <enclosure url="https://codexbar.zabrian.app/download/CodexBar-v2.2.0.dmg" sparkle:edSignature="L/6jFdturq7Mz31UItkx5aO6uPu7uOKfFdHEvov44W+PZVLD1BDf/jiSujDED9xuBnvXk8GoIg5mRAFnoIo5Dw==" length="2681727" type="application/octet-stream"/>+ </item><item><title>CodexBar.app 2.1.0</title><sparkle:version>11</sparkle:version>