CodexBar 是一个 macOS 菜单栏应用,用于查看本机 Codex 账号状态、额度、Token 用量、详细统计信息
Swift appkitcodexcodex-clideveloper-toolsmacosmacos-appmenu-bar-appopenai-codexproductivityswiftswiftuiusage-tracker
feat: 支持自定义通知音效并发布 3.4.2
Bobd892b05dfb32
diff --git a/CodexBar.xcodeproj/project.pbxproj b/CodexBar.xcodeproj/project.pbxprojindex aa7f8db..66dd585 100644--- a/CodexBar.xcodeproj/project.pbxproj+++ b/CodexBar.xcodeproj/project.pbxproj@@ -274,7 +274,7 @@"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;- CURRENT_PROJECT_VERSION = 51;+ CURRENT_PROJECT_VERSION = 52;DEAD_CODE_STRIPPING = YES;DEVELOPMENT_TEAM = 4KJ362VJW5;ENABLE_APP_INTENTS_METADATA_GENERATION = NO;@@ -290,7 +290,7 @@"$(inherited)","@executable_path/../Frameworks",);- MARKETING_VERSION = 3.4.1;+ MARKETING_VERSION = 3.4.2;PRODUCT_BUNDLE_IDENTIFIER = app.zabrian.codexbar;PRODUCT_NAME = "$(TARGET_NAME)";REGISTER_APP_GROUPS = YES;@@ -313,7 +313,7 @@"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;- CURRENT_PROJECT_VERSION = 51;+ CURRENT_PROJECT_VERSION = 52;DEAD_CODE_STRIPPING = YES;DEVELOPMENT_TEAM = 4KJ362VJW5;ENABLE_APP_INTENTS_METADATA_GENERATION = NO;@@ -329,7 +329,7 @@"$(inherited)","@executable_path/../Frameworks",);- MARKETING_VERSION = 3.4.1;+ MARKETING_VERSION = 3.4.2;PRODUCT_BUNDLE_IDENTIFIER = app.zabrian.codexbar;PRODUCT_NAME = "$(TARGET_NAME)";PROVISIONING_PROFILE_SPECIFIER = "";diff --git a/CodexBar/Controllers/HostingWindowController.swift b/CodexBar/Controllers/HostingWindowController.swiftindex c7b7e1d..bbf3c3d 100644--- a/CodexBar/Controllers/HostingWindowController.swift+++ b/CodexBar/Controllers/HostingWindowController.swift@@ -1,12 +1,16 @@import AppKit-/// 可临时禁止成为 key window, 让菜单面板关闭动画期间不被辅助窗口抢焦点+/// 可临时忽略 key window 请求, 让菜单面板关闭动画期间不被辅助窗口抢焦点@MainActorfinal class AuxiliaryHostingWindow: NSWindow {var allowsKeyFocus = true- override var canBecomeKey: Bool {- allowsKeyFocus+ override func makeKey() {+ guard allowsKeyFocus else {+ return+ }++ super.makeKey()}override var canBecomeMain: Bool {diff --git a/CodexBar/Controllers/NotificationOptionsPanelController.swift b/CodexBar/Controllers/NotificationOptionsPanelController.swiftindex 159f25e..28139f7 100644--- a/CodexBar/Controllers/NotificationOptionsPanelController.swift+++ b/CodexBar/Controllers/NotificationOptionsPanelController.swift@@ -1,4 +1,5 @@import AppKit+import Combineimport SwiftUI/// 通知子选项面板动作, 由 AppSettingsView 发出并在 SettingsWindowController 中路由@@ -27,6 +28,8 @@ final class NotificationOptionsPanelController {private weak var settingsWindow: NSWindow?private var panelDismissObserver: NSObjectProtocol?private var settingsWindowDismissObservers: [NSObjectProtocol] = []+ private var cancellables = Set<AnyCancellable>()+ private var panelResizeTask: Task<Void, Never>?init(notificationSettings: NotificationSettings,@@ -36,6 +39,7 @@ final class NotificationOptionsPanelController {self.notificationSettings = notificationSettingsself.codexHookSettings = codexHookSettingsself.codexCLINotificationSettings = codexCLINotificationSettings+ observeContentHeightChanges()}var isVisible: Bool {@@ -190,7 +194,71 @@ final class NotificationOptionsPanelController {hostingController?.view.validFittingSize ?? NotificationOptionsView.initialPanelSize}+ private func observeContentHeightChanges() {+ Publishers.MergeMany([+ notificationSettings.$isLowQuotaEnabled.map { _ in () },+ notificationSettings.$isQuotaResetEnabled.map { _ in () },+ notificationSettings.$isLongTaskEnabled.map { _ in () },+ notificationSettings.$isTaskWaitingEnabled.map { _ in () },+ notificationSettings.$isCreditExpiryEnabled.map { _ in () },+ codexHookSettings.$isEnabled.map { _ in () }+ ])+ .sink { [weak self] in+ self?.schedulePanelResize()+ }+ .store(in: &cancellables)+ }++ private func schedulePanelResize() {+ guard panel != nil else {+ return+ }++ panelResizeTask?.cancel()+ panelResizeTask = Task { @MainActor [weak self] in+ // @Published 先于 SwiftUI 布局发出变更, 等待视图提交新的 fitting size+ await Task.yield()+ await Task.yield()+ guard let self,+ !Task.isCancelled,+ let panel,+ panel.isVisible,+ let size = hostingController?.view.validFittingSize else {+ return+ }++ resizePanel(panel, to: size)+ }+ }++ private func resizePanel(_ panel: NSPanel, to size: CGSize) {+ guard size != panel.frame.size else {+ return+ }++ let currentFrame = panel.frame+ var targetFrame = NSRect(+ x: currentFrame.minX,+ y: currentFrame.maxY - size.height,+ width: size.width,+ height: size.height+ )+ if let visibleFrame = panel.screen?.visibleFrame {+ targetFrame.origin.y = max(+ targetFrame.origin.y,+ visibleFrame.minY + SidePanelSupport.Metrics.screenPadding+ )+ }++ NSAnimationContext.runAnimationGroup { context in+ context.duration = Metrics.resizeDuration+ context.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)+ panel.animator().setFrame(targetFrame, display: true)+ }+ }+private enum Metrics {static let drawerTransformAnimationKey = "CodexBar.notificationOptionsDrawerTransform"+ static let resizeDuration: TimeInterval = 0.16}}diff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-Exclamation.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-Exclamation.wavnew file mode 100644index 0000000..eb8238eBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-Exclamation.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-HaHa.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-HaHa.wavnew file mode 100644index 0000000..3b7de31Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-HaHa.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-Heart.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-Heart.wavnew file mode 100644index 0000000..b9dffd3Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-Heart.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-QuestionMark.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-QuestionMark.wavnew file mode 100644index 0000000..34d087aBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-QuestionMark.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-ThumbsDown.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-ThumbsDown.wavnew file mode 100644index 0000000..2d0eaffBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-ThumbsDown.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-ThumbsUp.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-ThumbsUp.wavnew file mode 100644index 0000000..d56a1d9Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Acknowledgement-ThumbsUp.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Antic.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Antic.wavnew file mode 100644index 0000000..d46d8aeBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Antic.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Basso.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Basso.wavnew file mode 100644index 0000000..346efa5Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Basso.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Blow.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Blow.wavnew file mode 100644index 0000000..04dc759Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Blow.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Bottle.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Bottle.wavnew file mode 100644index 0000000..d8d1e42Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Bottle.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Cheers.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Cheers.wavnew file mode 100644index 0000000..42e4cb9Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Cheers.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Droplet.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Droplet.wavnew file mode 100644index 0000000..71819f8Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Droplet.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Frog.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Frog.wavnew file mode 100644index 0000000..044115bBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Frog.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Funk.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Funk.wavnew file mode 100644index 0000000..e467bd4Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Funk.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Glass.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Glass.wavnew file mode 100644index 0000000..45bce92Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Glass.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Handoff.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Handoff.wavnew file mode 100644index 0000000..6285d69Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Handoff.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Hero.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Hero.wavnew file mode 100644index 0000000..b650378Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Hero.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Milestone.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Milestone.wavnew file mode 100644index 0000000..d0ee552Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Milestone.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Morse.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Morse.wavnew file mode 100644index 0000000..de772b9Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Morse.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Passage.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Passage.wavnew file mode 100644index 0000000..370169fBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Passage.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Ping.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Ping.wavnew file mode 100644index 0000000..c7d7c2eBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Ping.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Pop.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Pop.wavnew file mode 100644index 0000000..3c2b27fBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Pop.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Portal.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Portal.wavnew file mode 100644index 0000000..2552760Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Portal.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Purr.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Purr.wavnew file mode 100644index 0000000..0e94a8aBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Purr.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Rattle.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Rattle.wavnew file mode 100644index 0000000..9be34acBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Rattle.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Rebound.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Rebound.wavnew file mode 100644index 0000000..a45be2cBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Rebound.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-ReceivedMessage.wav b/CodexBar/Resources/NotificationSounds/CodexBar-ReceivedMessage.wavnew file mode 100644index 0000000..2453842Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-ReceivedMessage.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Slide.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Slide.wavnew file mode 100644index 0000000..ce23b32Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Slide.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Sosumi.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Sosumi.wavnew file mode 100644index 0000000..6b9ef26Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Sosumi.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Submarine.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Submarine.wavnew file mode 100644index 0000000..4437639Binary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Submarine.wav differdiff --git a/CodexBar/Resources/NotificationSounds/CodexBar-Tink.wav b/CodexBar/Resources/NotificationSounds/CodexBar-Tink.wavnew file mode 100644index 0000000..d8e8e5eBinary files /dev/null and b/CodexBar/Resources/NotificationSounds/CodexBar-Tink.wav differdiff --git a/CodexBar/Services/Notifications/CodexNotificationService.swift b/CodexBar/Services/Notifications/CodexNotificationService.swiftindex c60d834..11a42e1 100644--- a/CodexBar/Services/Notifications/CodexNotificationService.swift+++ b/CodexBar/Services/Notifications/CodexNotificationService.swift@@ -110,6 +110,7 @@ final class CodexNotificationService: NSObject {taskWaitingNotificationIdentifiers.insert(identifier)send(.taskWaiting(project: task.projectName, toolName: task.toolName),+ sound: settings.taskWaitingSound,identifier: identifier,isStillRelevant: { [weak self] inself?.isTaskStillWaiting(@@ -127,7 +128,10 @@ final class CodexNotificationService: NSObject {duration >= TimeInterval(settings.longTaskThresholdSeconds) else {return}- send(.taskCompleted(project: completion.projectName, duration: duration))+ send(+ .taskCompleted(project: completion.projectName, duration: duration),+ sound: settings.longTaskSound+ )}}@@ -300,6 +304,7 @@ final class CodexNotificationService: NSObject {windowLabel: window.label,thresholdPercent: settings.lowQuotaThresholdPercent),+ sound: settings.lowQuotaSound,dedupKey: dedupKey,onSubmissionFailure: { [weak self] inself?.lastRemainingPercents.removeValue(forKey: stateKey)@@ -335,6 +340,7 @@ final class CodexNotificationService: NSObject {limitTitle: limit.title,windowLabel: window.label),+ sound: settings.quotaResetSound,dedupKey: dedupKey,onSubmissionFailure: { [weak self] inguard let self,@@ -373,6 +379,7 @@ final class CodexNotificationService: NSObject {let dedupKey = "credit|\(accountKey)|\(epochSecond)|\(reminderDay)d"send(.creditExpiry(count: groupedDates.count, expirationDate: date),+ sound: settings.creditExpirySound,dedupKey: dedupKey)}@@ -415,6 +422,7 @@ final class CodexNotificationService: NSObject {private func send(_ notification: CodexNotificationContent,+ sound: NotificationSoundOption,identifier: String = UUID().uuidString,dedupKey: String? = nil,isStillRelevant: (() -> Bool)? = nil,@@ -430,7 +438,7 @@ final class CodexNotificationService: NSObject {let content = UNMutableNotificationContent()content.title = notification.titlecontent.body = notification.body- content.sound = .default+ content.sound = sound.notificationSoundlet request = UNNotificationRequest(identifier: identifier,diff --git a/CodexBar/Services/Notifications/NotificationSoundOption.swift b/CodexBar/Services/Notifications/NotificationSoundOption.swiftnew file mode 100644index 0000000..5039de5--- /dev/null+++ b/CodexBar/Services/Notifications/NotificationSoundOption.swift@@ -0,0 +1,184 @@+import AppKit+import Foundation+import UserNotifications++/// CodexBar 可用于系统通知的声音, 自定义声音随 App 打包, 确保通知中心能够解析文件名+enum NotificationSoundOption: String, Identifiable {+ case silent+ case systemDefault+ case basso+ case blow+ case bottle+ case frog+ case funk+ case glass+ case hero+ case morse+ case ping+ case pop+ case purr+ case sosumi+ case submarine+ case tink+ case antic+ case cheers+ case droplet+ case handoff+ case milestone+ case passage+ case portal+ case rattle+ case rebound+ case slide+ case receivedMessage+ case acknowledgementExclamation+ case acknowledgementHaHa+ case acknowledgementHeart+ case acknowledgementQuestionMark+ case acknowledgementThumbsDown+ case acknowledgementThumbsUp++ static let classicSounds: [NotificationSoundOption] = [+ .basso, .blow, .bottle, .frog, .funk, .glass, .hero,+ .morse, .ping, .pop, .purr, .sosumi, .submarine, .tink+ ]++ static let modernSounds: [NotificationSoundOption] = [+ .antic, .cheers, .droplet, .handoff, .milestone, .passage,+ .portal, .rattle, .rebound, .slide, .receivedMessage,+ .acknowledgementExclamation, .acknowledgementHaHa,+ .acknowledgementHeart, .acknowledgementQuestionMark,+ .acknowledgementThumbsDown, .acknowledgementThumbsUp+ ]++ var id: String {+ rawValue+ }++ var title: String {+ switch self {+ case .silent:+ "静音"+ case .systemDefault:+ "系统提示音"+ case .basso:+ "Basso"+ case .blow:+ "Blow"+ case .bottle:+ "Bottle"+ case .frog:+ "Frog"+ case .funk:+ "Funk"+ case .glass:+ "Glass"+ case .hero:+ "Hero"+ case .morse:+ "Morse"+ case .ping:+ "Ping"+ case .pop:+ "Pop"+ case .purr:+ "Purr"+ case .sosumi:+ "Sosumi"+ case .submarine:+ "Submarine"+ case .tink:+ "Tink"+ case .antic:+ "Antic"+ case .cheers:+ "Cheers"+ case .droplet:+ "Droplet"+ case .handoff:+ "Handoff"+ case .milestone:+ "Milestone"+ case .passage:+ "Passage"+ case .portal:+ "Portal"+ case .rattle:+ "Rattle"+ case .rebound:+ "Rebound"+ case .slide:+ "Slide"+ case .receivedMessage:+ "Received Message"+ case .acknowledgementExclamation:+ "Exclamation"+ case .acknowledgementHaHa:+ "Ha Ha"+ case .acknowledgementHeart:+ "Heart"+ case .acknowledgementQuestionMark:+ "Question Mark"+ case .acknowledgementThumbsDown:+ "Thumbs Down"+ case .acknowledgementThumbsUp:+ "Thumbs Up"+ }+ }++ var notificationSound: UNNotificationSound? {+ guard self != .silent else {+ return nil+ }++ guard let resourceFileName else {+ return .default+ }++ return UNNotificationSound(+ named: UNNotificationSoundName(rawValue: resourceFileName)+ )+ }++ func makePreviewSound(bundle: Bundle = .main) -> NSSound? {+ guard let resourceBaseName,+ let url = bundle.url(forResource: resourceBaseName, withExtension: Self.resourceExtension) else {+ return nil+ }++ return NSSound(contentsOf: url, byReference: true)+ }++ private var resourceBaseName: String? {+ resourceName.map { "CodexBar-\($0)" }+ }++ private var resourceName: String? {+ switch self {+ case .silent, .systemDefault:+ nil+ case .receivedMessage:+ "ReceivedMessage"+ case .acknowledgementExclamation:+ "Acknowledgement-Exclamation"+ case .acknowledgementHaHa:+ "Acknowledgement-HaHa"+ case .acknowledgementHeart:+ "Acknowledgement-Heart"+ case .acknowledgementQuestionMark:+ "Acknowledgement-QuestionMark"+ case .acknowledgementThumbsDown:+ "Acknowledgement-ThumbsDown"+ case .acknowledgementThumbsUp:+ "Acknowledgement-ThumbsUp"+ default:+ title+ }+ }++ private var resourceFileName: String? {+ resourceBaseName.map { "\($0).\(Self.resourceExtension)" }+ }++ private static let resourceExtension = "wav"+}diff --git a/CodexBar/Services/Settings/NotificationSettings.swift b/CodexBar/Services/Settings/NotificationSettings.swiftindex 954812c..682483d 100644--- a/CodexBar/Services/Settings/NotificationSettings.swift+++ b/CodexBar/Services/Settings/NotificationSettings.swift@@ -3,7 +3,7 @@ import Combineimport Foundationimport UserNotifications-/// 通知偏好: 总开关; 五类通知子开关; 任务触觉开关; 两个阈值和系统授权状态镜像+/// 通知偏好: 总开关; 五类通知子开关及声音; 任务触觉开关; 两个阈值和系统授权状态镜像/// 授权请求/查询集中在这里, 通知与触觉反馈判定在 CodexNotificationService@MainActorfinal class NotificationSettings: ObservableObject {@@ -16,6 +16,11 @@ final class NotificationSettings: ObservableObject {@Published private(set) var isCreditExpiryEnabled: Bool@Published private(set) var lowQuotaThresholdPercent: Int@Published private(set) var longTaskThresholdSeconds: Int+ @Published private(set) var lowQuotaSound: NotificationSoundOption+ @Published private(set) var quotaResetSound: NotificationSoundOption+ @Published private(set) var longTaskSound: NotificationSoundOption+ @Published private(set) var taskWaitingSound: NotificationSoundOption+ @Published private(set) var creditExpirySound: NotificationSoundOption@Published private(set) var authorizationStatus: UNAuthorizationStatus = .notDetermined/// 系统授权被拒时设置页展示引导, 通知服务停发@@ -74,6 +79,11 @@ final class NotificationSettings: ObservableObject {in: Self.longTaskThresholdOptions,defaultValue: 60)+ lowQuotaSound = Self.sound(from: defaults, key: Self.lowQuotaSoundKey)+ quotaResetSound = Self.sound(from: defaults, key: Self.quotaResetSoundKey)+ longTaskSound = Self.sound(from: defaults, key: Self.longTaskSoundKey)+ taskWaitingSound = Self.sound(from: defaults, key: Self.taskWaitingSoundKey)+ creditExpirySound = Self.sound(from: defaults, key: Self.creditExpirySoundKey)}deinit {@@ -136,6 +146,26 @@ final class NotificationSettings: ObservableObject {defaults.set(seconds, forKey: Self.longTaskThresholdKey)}+ func setLowQuotaSound(_ sound: NotificationSoundOption) {+ setSound(sound, current: &lowQuotaSound, key: Self.lowQuotaSoundKey)+ }++ func setQuotaResetSound(_ sound: NotificationSoundOption) {+ setSound(sound, current: "aResetSound, key: Self.quotaResetSoundKey)+ }++ func setLongTaskSound(_ sound: NotificationSoundOption) {+ setSound(sound, current: &longTaskSound, key: Self.longTaskSoundKey)+ }++ func setTaskWaitingSound(_ sound: NotificationSoundOption) {+ setSound(sound, current: &taskWaitingSound, key: Self.taskWaitingSoundKey)+ }++ func setCreditExpirySound(_ sound: NotificationSoundOption) {+ setSound(sound, current: &creditExpirySound, key: Self.creditExpirySoundKey)+ }+/// 用户可能在系统设置里改过权限, 回到 App 时需要重新读取func refreshAuthorizationStatus() {authorizationTask?.cancel()@@ -193,6 +223,19 @@ final class NotificationSettings: ObservableObject {defaults.set(value, forKey: key)}+ private func setSound(+ _ sound: NotificationSoundOption,+ current: inout NotificationSoundOption,+ key: String+ ) {+ guard sound != current else {+ return+ }++ current = sound+ defaults.set(sound.rawValue, forKey: key)+ }+private static func bool(from defaults: UserDefaults, key: String, defaultValue: Bool) -> Bool {guard defaults.object(forKey: key) != nil else {return defaultValue@@ -209,6 +252,15 @@ final class NotificationSettings: ObservableObject {return value}+ private static func sound(from defaults: UserDefaults, key: String) -> NotificationSoundOption {+ guard let rawValue = defaults.string(forKey: key),+ let sound = NotificationSoundOption(rawValue: rawValue) else {+ return .systemDefault+ }++ return sound+ }+private static let enabledKey = "Notification.enabled"private static let lowQuotaEnabledKey = "Notification.lowQuotaEnabled"private static let quotaResetEnabledKey = "Notification.quotaResetEnabled"@@ -218,4 +270,9 @@ final class NotificationSettings: ObservableObject {private static let creditExpiryEnabledKey = "Notification.creditExpiryEnabled"private static let lowQuotaThresholdKey = "Notification.lowQuotaThresholdPercent"private static let longTaskThresholdKey = "Notification.longTaskThresholdSeconds"+ private static let lowQuotaSoundKey = "Notification.lowQuotaSound"+ private static let quotaResetSoundKey = "Notification.quotaResetSound"+ private static let longTaskSoundKey = "Notification.longTaskSound"+ private static let taskWaitingSoundKey = "Notification.taskWaitingSound"+ private static let creditExpirySoundKey = "Notification.creditExpirySound"}diff --git a/CodexBar/Views/Settings/AppSettingsView.swift b/CodexBar/Views/Settings/AppSettingsView.swiftindex 701dc8f..63d7f22 100644--- a/CodexBar/Views/Settings/AppSettingsView.swift+++ b/CodexBar/Views/Settings/AppSettingsView.swift@@ -33,21 +33,21 @@ struct AppSettingsView: View {LiquidGlassDivider()menuBarQuotaRowLiquidGlassDivider()+ hotKeyRow+ LiquidGlassDivider()codexHookRowLiquidGlassDivider()taskCenterRowLiquidGlassDivider()+ notificationRow+ LiquidGlassDivider()syncRowLiquidGlassDivider()rebuildWorkflowDataRowLiquidGlassDivider()- notificationRow- LiquidGlassDivider()- hotKeyRow+ versionRowLiquidGlassDivider()codexVersionSection- LiquidGlassDivider()- versionRow}.padding(Metrics.panelPadding).liquidGlassSurface(cornerRadius: Metrics.panelCornerRadius)@@ -123,6 +123,8 @@ private extension AppSettingsView {static let panelCornerRadius: CGFloat = 10static let notificationOptionsButtonSize: CGFloat = 22static let menuBarQuotaPickerWidth: CGFloat = 72+ static let syncStatusRowHeight: CGFloat = 16+ static let syncStatusValueWidth: CGFloat = 160static let statusAnimation = Animation.codexStatus}@@ -218,7 +220,7 @@ private extension AppSettingsView {return SettingsToggleRow(icon: "list.bullet.rectangle",- title: "任务中心",+ title: "主面板任务中心",isOn: Binding(get: { isDisplayedOn },set: { mainPanelSettings.setShowsTaskCenter($0) }@@ -231,7 +233,7 @@ private extension AppSettingsView {VStack(alignment: .leading, spacing: 4) {SettingsToggleRow(icon: "link",- title: "启用 Codex Hook",+ title: "CodexBar Hook",isOn: Binding(get: { codexHookSettings.isEnabled },set: { codexHookSettings.setEnabled($0) }@@ -267,7 +269,10 @@ private extension AppSettingsView {if let message = syncSettings.unavailableMessage {SettingsCaptionMessageRow(message: message)- } else if state.shouldShowSyncStatus(lastSyncText: lastSyncText) {+ .frame(minHeight: Metrics.syncStatusRowHeight, alignment: .top)+ } else if state.isActive {+ let showsSyncStatus = state.shouldShowSyncStatus(lastSyncText: lastSyncText)+SettingsIndentedRow {Text("最近同步").font(.caption)@@ -275,19 +280,34 @@ private extension AppSettingsView {Spacer(minLength: 8)- if syncSettings.isSyncing {- ProgressView()- .controlSize(.small)- .scaleEffect(0.7)- .frame(width: 16, height: 16)- .help("正在同步")- } else if let lastSyncText {- Text(lastSyncText)- .font(.caption.monospacedDigit())- .foregroundStyle(.secondary)- .lineLimit(1)+ ZStack(alignment: .trailing) {+ if syncSettings.isSyncing {+ ProgressView()+ .controlSize(.mini)+ .frame(+ width: Metrics.syncStatusRowHeight,+ height: Metrics.syncStatusRowHeight+ )+ .help("正在同步")+ .transition(.opacity)+ } else if let lastSyncText {+ Text(lastSyncText)+ .font(.caption.monospacedDigit())+ .foregroundStyle(.secondary)+ .lineLimit(1)+ .transition(.opacity)+ }}+ .frame(+ width: Metrics.syncStatusValueWidth,+ height: Metrics.syncStatusRowHeight,+ alignment: .trailing+ )+ .animation(Metrics.statusAnimation, value: syncSettings.isSyncing)}+ .frame(height: Metrics.syncStatusRowHeight)+ .opacity(showsSyncStatus ? 1 : 0)+ .accessibilityHidden(!showsSyncStatus)}}}diff --git a/CodexBar/Views/Settings/HotKeyRecorderRow.swift b/CodexBar/Views/Settings/HotKeyRecorderRow.swiftindex 059042a..21a0b92 100644--- a/CodexBar/Views/Settings/HotKeyRecorderRow.swift+++ b/CodexBar/Views/Settings/HotKeyRecorderRow.swift@@ -14,7 +14,7 @@ struct HotKeyRecorderRow: View {.frame(width: SettingsRowMetrics.iconWidth).foregroundStyle(.tint)- Text("使用快捷键")+ Text("APP 快捷键")Spacer()@@ -45,7 +45,7 @@ struct HotKeyRecorderRow: View {iconButton(systemName: "arrow.counterclockwise.circle",- help: "恢复默认快捷键",+ help: "恢复默认",isDisabled: !canRestoreDefaultShortcut) {settings.restoreDefaultShortcut()@@ -54,7 +54,7 @@ struct HotKeyRecorderRow: View {iconButton(systemName: "xmark.circle",- help: "清除设置快捷键",+ help: "清除 APP 快捷键",isDisabled: !canClearShortcut) {settings.clearShortcut()@@ -73,7 +73,7 @@ struct HotKeyRecorderRow: View {private var shortcutLabel: String {if isRecording {- return "请输入快捷键"+ return "请设置快捷键"}return settings.shortcut?.label ?? "未设置"diff --git a/CodexBar/Views/Settings/NotificationOptionsView.swift b/CodexBar/Views/Settings/NotificationOptionsView.swiftindex 0951e8f..b998f7b 100644--- a/CodexBar/Views/Settings/NotificationOptionsView.swift+++ b/CodexBar/Views/Settings/NotificationOptionsView.swift@@ -1,26 +1,29 @@+import AppKitimport SwiftUI/// 通知子选项面板, 挂在设置窗口"系统通知"行右侧展开-/// 面板尺寸在 Hook 开/关两种状态下保持不变: 行高固定, Picker 行内显隐不改行高+/// 通知开启时展开音效子行, 关闭时连同占位一起收起struct NotificationOptionsView: View {@ObservedObject var notificationSettings: NotificationSettings@ObservedObject var codexHookSettings: CodexHookSettings@ObservedObject var codexCLINotificationSettings: CodexCLINotificationSettings+ @State private var previewSound: NSSound?var body: some View {VStack(alignment: .leading, spacing: Metrics.rowSpacing) {- lowQuotaRow- quotaResetRowlongTaskRowtaskWaitingRow- taskHapticRow+ lowQuotaRow+ quotaResetRowcreditExpiryRow+ taskHapticRowcodexCLINotificationRow}.padding(.horizontal, Metrics.horizontalPadding).padding(.vertical, Metrics.verticalPadding).frame(width: Metrics.panelWidth, alignment: .topLeading).sidePanelChrome(cornerRadius: Metrics.cornerRadius)+ .onDisappear(perform: stopPreview)}static var panelCornerRadius: CGFloat {@@ -28,45 +31,49 @@ struct NotificationOptionsView: View {}static var initialPanelSize: CGSize {- let rowCount = CGFloat(Metrics.optionRowCount)- return CGSize(+ CGSize(width: Metrics.panelWidth,height: Metrics.verticalPadding * 2- + Metrics.rowHeight * rowCount- + Metrics.rowSpacing * (rowCount - 1)+ + Metrics.notificationRowHeight * CGFloat(Metrics.notificationRowCount)+ + Metrics.rowHeight * CGFloat(Metrics.standardRowCount)+ + Metrics.rowSpacing * CGFloat(Metrics.totalRowCount - 1))}private var lowQuotaRow: some View {- optionRow(+ notificationOptionRow(title: "额度预警通知",isOn: Binding(get: { notificationSettings.isLowQuotaEnabled },set: { notificationSettings.setLowQuotaEnabled($0) }+ ),+ sound: Binding(+ get: { notificationSettings.lowQuotaSound },+ set: { notificationSettings.setLowQuotaSound($0) })) {- if notificationSettings.isLowQuotaEnabled {- optionPicker(- title: "低额度阈值",- selection: Binding(- get: { notificationSettings.lowQuotaThresholdPercent },- set: { notificationSettings.setLowQuotaThresholdPercent($0) }- ),- options: NotificationSettings.lowQuotaThresholdOptions,- label: { "\($0)%" }- )- .transition(.opacity.combined(with: .move(edge: .trailing)))- }+ optionPicker(+ title: "低额度阈值",+ selection: Binding(+ get: { notificationSettings.lowQuotaThresholdPercent },+ set: { notificationSettings.setLowQuotaThresholdPercent($0) }+ ),+ options: NotificationSettings.lowQuotaThresholdOptions,+ label: { "\($0)%" }+ )}- .animation(Metrics.statusAnimation, value: notificationSettings.isLowQuotaEnabled)}private var quotaResetRow: some View {- optionRow(+ notificationOptionRow(title: "额度重置通知",isOn: Binding(get: { notificationSettings.isQuotaResetEnabled },set: { notificationSettings.setQuotaResetEnabled($0) }+ ),+ sound: Binding(+ get: { notificationSettings.quotaResetSound },+ set: { notificationSettings.setQuotaResetSound($0) }))}@@ -75,41 +82,45 @@ struct NotificationOptionsView: View {private var longTaskRow: some View {let isDisplayedOn = codexHookSettings.isEnabled && notificationSettings.isLongTaskEnabled- return optionRow(+ return notificationOptionRow(title: "任务完成通知",isOn: Binding(get: { isDisplayedOn },set: { notificationSettings.setLongTaskEnabled($0) }),- isEnabled: codexHookSettings.isEnabled+ isEnabled: codexHookSettings.isEnabled,+ sound: Binding(+ get: { notificationSettings.longTaskSound },+ set: { notificationSettings.setLongTaskSound($0) }+ )) {- if isDisplayedOn {- optionPicker(- title: "任务时长",- selection: Binding(- get: { notificationSettings.longTaskThresholdSeconds },- set: { notificationSettings.setLongTaskThresholdSeconds($0) }- ),- options: NotificationSettings.longTaskThresholdOptions,- label: { Self.longTaskOptionLabel($0) }- )- .transition(.opacity.combined(with: .move(edge: .trailing)))- }+ optionPicker(+ title: "任务时长",+ selection: Binding(+ get: { notificationSettings.longTaskThresholdSeconds },+ set: { notificationSettings.setLongTaskThresholdSeconds($0) }+ ),+ options: NotificationSettings.longTaskThresholdOptions,+ label: { Self.longTaskOptionLabel($0) }+ )}- .animation(Metrics.statusAnimation, value: isDisplayedOn)}/// Hook 未开启时显示为关闭并置灰, 不修改持久化的 isTaskWaitingEnabledprivate var taskWaitingRow: some View {let isDisplayedOn = codexHookSettings.isEnabled && notificationSettings.isTaskWaitingEnabled- return optionRow(+ return notificationOptionRow(title: "任务等待通知",isOn: Binding(get: { isDisplayedOn },set: { notificationSettings.setTaskWaitingEnabled($0) }),- isEnabled: codexHookSettings.isEnabled+ isEnabled: codexHookSettings.isEnabled,+ sound: Binding(+ get: { notificationSettings.taskWaitingSound },+ set: { notificationSettings.setTaskWaitingSound($0) }+ ))}@@ -128,11 +139,15 @@ struct NotificationOptionsView: View {}private var creditExpiryRow: some View {- optionRow(- title: "重置次数临期通知",+ notificationOptionRow(+ title: "重置临期通知",isOn: Binding(get: { notificationSettings.isCreditExpiryEnabled },set: { notificationSettings.setCreditExpiryEnabled($0) }+ ),+ sound: Binding(+ get: { notificationSettings.creditExpirySound },+ set: { notificationSettings.setCreditExpirySound($0) }))}@@ -148,8 +163,7 @@ struct NotificationOptionsView: View {) {if codexCLINotificationSettings.isUpdating {ProgressView()- .controlSize(.small)- .scaleEffect(0.7)+ .controlSize(.mini).frame(width: Metrics.statusIconSize, height: Metrics.statusIconSize)} else if let errorMessage = codexCLINotificationSettings.errorMessage {Image(systemName: "exclamationmark.circle")@@ -194,6 +208,69 @@ struct NotificationOptionsView: View {.frame(height: Metrics.rowHeight)}+ private func notificationOptionRow(+ title: String,+ isOn: Binding<Bool>,+ isEnabled: Bool = true,+ sound: Binding<NotificationSoundOption>+ ) -> some View {+ notificationOptionRow(+ title: title,+ isOn: isOn,+ isEnabled: isEnabled,+ sound: sound+ ) {+ EmptyView()+ }+ }++ private func notificationOptionRow(+ title: String,+ isOn: Binding<Bool>,+ isEnabled: Bool = true,+ sound: Binding<NotificationSoundOption>,+ @ViewBuilder accessory: () -> some View+ ) -> some View {+ let showsSoundControls = isEnabled && isOn.wrappedValue++ return VStack(spacing: 0) {+ HStack(spacing: Metrics.notificationControlSpacing) {+ Text(title)+ .font(.caption)+ .foregroundStyle(.secondary)+ .layoutPriority(1)++ Spacer(minLength: 0)++ if showsSoundControls {+ accessory()+ }++ Toggle(title, isOn: isOn)+ .labelsHidden()+ .toggleStyle(.switch)+ .controlSize(.mini)+ .disabled(!isEnabled)+ }+ .frame(height: Metrics.rowHeight)++ if showsSoundControls {+ HStack(spacing: Metrics.notificationControlSpacing) {+ Text("通知音效")+ .font(.caption2)+ .foregroundStyle(.tertiary)++ Spacer(minLength: 8)++ soundMenu(selection: sound)+ }+ .frame(height: Metrics.soundRowHeight)+ .transition(.opacity.combined(with: .move(edge: .top)))+ }+ }+ .animation(Metrics.statusAnimation, value: showsSoundControls)+ }+private func optionPicker(title: String,selection: Binding<Int>,@@ -211,18 +288,91 @@ struct NotificationOptionsView: View {.frame(width: Metrics.pickerWidth)}+ private func soundMenu(selection: Binding<NotificationSoundOption>) -> some View {+ Menu {+ soundMenuButton(.systemDefault, selection: selection)+ soundMenuButton(.silent, selection: selection)++ Divider()++ Menu("经典提示音") {+ ForEach(NotificationSoundOption.classicSounds) { sound in+ soundMenuButton(sound, selection: selection)+ }+ }++ Menu("现代提示音") {+ ForEach(NotificationSoundOption.modernSounds) { sound in+ soundMenuButton(sound, selection: selection)+ }+ }+ } label: {+ Text(selection.wrappedValue.title)+ .font(.caption)+ .foregroundStyle(.secondary)+ .lineLimit(1)+ .frame(maxWidth: .infinity, alignment: .trailing)+ .contentShape(Rectangle())+ }+ .menuStyle(.borderlessButton)+ .controlSize(.small)+ .frame(width: Metrics.soundMenuWidth, alignment: .trailing)+ }++ private func soundMenuButton(+ _ sound: NotificationSoundOption,+ selection: Binding<NotificationSoundOption>+ ) -> some View {+ Button {+ selection.wrappedValue = sound+ playPreview(for: sound)+ } label: {+ if sound == selection.wrappedValue {+ Label(sound.title, systemImage: "checkmark")+ } else {+ Text(sound.title)+ }+ }+ }++ private func playPreview(for sound: NotificationSoundOption) {+ stopPreview()++ switch sound {+ case .silent:+ return+ case .systemDefault:+ NSSound.beep()+ default:+ previewSound = sound.makePreviewSound()+ ?? NSSound(named: NSSound.Name(sound.title))+ previewSound?.play()+ }+ }++ private func stopPreview() {+ previewSound?.stop()+ previewSound = nil+ }+private static func longTaskOptionLabel(_ seconds: Int) -> String {seconds < 60 ? "\(seconds) 秒" : "\(seconds / 60) 分钟"}private enum Metrics {- static let panelWidth: CGFloat = 300+ static let panelWidth: CGFloat = 320static let horizontalPadding: CGFloat = 12static let verticalPadding: CGFloat = 10- static let optionRowCount = 7- static let rowSpacing: CGFloat = 7+ static let notificationRowCount = 5+ static let standardRowCount = 2+ static let totalRowCount = notificationRowCount + standardRowCount+ static let rowSpacing: CGFloat = 5static let rowHeight: CGFloat = 22- static let pickerWidth: CGFloat = 72+ static let soundRowHeight: CGFloat = 18+ static let notificationRowHeight = rowHeight + soundRowHeight+ static let notificationControlSpacing: CGFloat = 6+ static let pickerWidth: CGFloat = 68+ static let soundMenuWidth: CGFloat = 160static let statusIconSize: CGFloat = 16static let cornerRadius: CGFloat = 12static let statusAnimation = Animation.codexStatusdiff --git a/Docs/CodexHook.md b/Docs/CodexHook.mdindex 9a4968c..48a1087 100644--- a/Docs/CodexHook.md+++ b/Docs/CodexHook.md@@ -4,7 +4,7 @@## 开关行为-设置页「启用 Codex Hook」由 `CodexHookSettings` 管理。开启后,CodexBar 会把当前 App 的可执行文件路径写入全局配置:+设置页「CodexBar Hook」由 `CodexHookSettings` 管理。开启后,CodexBar 会把当前 App 的可执行文件路径写入全局配置:```text~/.codex/hooks.jsondiff --git a/Docs/CrossDeviceSync.md b/Docs/CrossDeviceSync.mdindex 2479c2d..de46d6b 100644--- a/Docs/CrossDeviceSync.md+++ b/Docs/CrossDeviceSync.md@@ -180,6 +180,8 @@ UI 状态:| 同步中 | 开关下方显示 `最近同步` 和小型进度指示 || 有成功上传记录 | 开关下方显示 `最近同步 yyyy-MM-dd HH:mm:ss` |+跨设备同步开启时,设置页始终为「最近同步」状态子行保留固定 16 pt 高的单行布局;右侧状态区域固定宽度,同步时间与进度指示通过交叉淡入淡出平滑切换,不触发设置窗口高度或行内位置变化。关闭跨设备同步后移除整行及其占位,让设置窗口随内容缩回。+主面板「数据更新时间」行最右侧始终显示同步状态图标:| 状态 | SF Symbol | tooltip |diff --git a/Docs/DevelopmentGuide.md b/Docs/DevelopmentGuide.mdindex 3def2af..3d57ecc 100644--- a/Docs/DevelopmentGuide.md+++ b/Docs/DevelopmentGuide.md@@ -620,7 +620,7 @@ Hook 开启且当天没有 token bucket 时, 今天的 token 数显示 `--`。## 10. Codex Hook 开启后完整流程-设置页"启用 Codex Hook"由 `CodexHookSettings` 管理, Hook 写入文件是:+设置页「CodexBar Hook」由 `CodexHookSettings` 管理, Hook 写入文件是:```text~/.codex/hooks.json@@ -940,20 +940,24 @@ App 再次成为 active 时, 也会刷新 Hook、同步、菜单栏额度、主设置项:-| 设置项 | 状态源 | 写入行为 |-| --------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |-| 开机自动启动 | `SMAppService.mainApp.status` | `register()` / `unregister()` |-| 自动检查更新 | Sparkle updater | 设置 `automaticallyChecksForUpdates` |-| 菜单栏额度指示 | `MenuBarQuotaSettings.selection` / `MenuBarQuota.lastWindowSelection` | 开关写入 `.off` 或恢复持久化的上次窗口选择, 窗口菜单写入所选窗口并同步记住; 标签优先来自当前账号 Codex limit 返回的额度窗口, 缺失时使用 fallback 标题 |-| 任务中心 | `MainPanelSettings.showsTaskCenter` + Codex Hook 状态 | 写入 `MainPanel.showsTaskCenter`; 缺失时默认开启。Hook 关闭时显示为关闭并置灰但保留偏好, 重新开启后恢复 |-| 系统通知 | `NotificationSettings` + `UNUserNotificationCenter` | 总开关、五类通知子开关、任务触觉开关与阈值写入 `UserDefaults`; 首次开启时请求系统通知授权 |-| Codex TUI 通知 | `CodexCLINotificationSettings` + app-server `config/read` / `config/batchWrite` | 读取用户级 `[tui].notifications`; 缺失时按开启处理,关闭/开启分别 upsert `false` / `true`,不修改顶层 `notify` |-| 使用快捷键 | `GlobalHotKeySettings.shortcut` | 写入 `UserDefaults` 并注册 hot key |-| 启用 Codex Hook | app-server `config/read` / `hooks/list` / `config/batchWrite`, `~/.codex/hooks.json` | 检查全局 Hook 开关后追加或移除当前 CodexBar command hook, 并维护对应 `hooks.state` 信任状态 |-| 跨设备同步 | `WorkflowSyncSettings` + CloudKit account status + `WorkflowSyncScheduler` | Hook 开启且同步账号可用时写入 `UserDefaults`; 开启时标记 `needsBackfill` 并请求调度同步 |-| 重建数据 | `WorkflowStorage.rebuildableEventDateKeys()` + `WorkflowSyncScheduler` | 选择最近 210 天内的日期范围, 将范围内非空本机事件日期交给调度器逐日重建, 并登记当前设备对应日期的待云端替换状态 |-| Codex 版本 | `CodexCLIVersionSnapshot` + 当前 app-server 握手信息 | 路径点击复制到剪贴板 |-| CodexBar 版本 | Bundle + AppUpdater 状态 | 有更新状态时优先显示动态消息 |+主设置卡片依次展示「开机自动启动」「自动检查更新」「菜单栏额度指示」「设置快捷键」「CodexBar Hook」「主面板任务中心」「系统通知」「跨设备同步」「重建数据」「CodexBar 版本」和「Codex 版本」。++跨设备同步开启时,状态子行始终保留固定 16 pt 高的单行布局;右侧固定宽度 `ZStack` 让同步时间和 `.mini` 进度指示以交叉淡入淡出切换,不对 AppKit 进度控件应用几何缩放,也不改变该行高度或控件位置。关闭同步后移除整行占位,让设置窗口 fitting size 随开关状态缩回。++| 设置项 | 状态源 | 写入行为 |+| -------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |+| 开机自动启动 | `SMAppService.mainApp.status` | `register()` / `unregister()` |+| 自动检查更新 | Sparkle updater | 设置 `automaticallyChecksForUpdates` |+| 菜单栏额度指示 | `MenuBarQuotaSettings.selection` / `MenuBarQuota.lastWindowSelection` | 开关写入 `.off` 或恢复持久化的上次窗口选择, 窗口菜单写入所选窗口并同步记住; 标签优先来自当前账号 Codex limit 返回的额度窗口, 缺失时使用 fallback 标题 |+| 设置快捷键 | `GlobalHotKeySettings.shortcut` | 写入 `UserDefaults` 并注册 hot key |+| CodexBar Hook | app-server `config/read` / `hooks/list` / `config/batchWrite`, `~/.codex/hooks.json` | 检查全局 Hook 开关后追加或移除当前 CodexBar command hook, 并维护对应 `hooks.state` 信任状态 |+| 主面板任务中心 | `MainPanelSettings.showsTaskCenter` + Codex Hook 状态 | 写入 `MainPanel.showsTaskCenter`; 缺失时默认开启。Hook 关闭时显示为关闭并置灰但保留偏好, 重新开启后恢复 |+| 系统通知 | `NotificationSettings` + `UNUserNotificationCenter` | 总开关、五类通知子开关、任务触觉开关与阈值写入 `UserDefaults`; 首次开启时请求系统通知授权 |+| Codex TUI 通知 | `CodexCLINotificationSettings` + app-server `config/read` / `config/batchWrite` | 读取用户级 `[tui].notifications`; 缺失时按开启处理,关闭/开启分别 upsert `false` / `true`,不修改顶层 `notify` |+| 跨设备同步 | `WorkflowSyncSettings` + CloudKit account status + `WorkflowSyncScheduler` | Hook 开启且同步账号可用时写入 `UserDefaults`; 开启时标记 `needsBackfill` 并请求调度同步 |+| 重建数据 | `WorkflowStorage.rebuildableEventDateKeys()` + `WorkflowSyncScheduler` | 选择最近 210 天内的日期范围, 将范围内非空本机事件日期交给调度器逐日重建, 并登记当前设备对应日期的待云端替换状态 |+| CodexBar 版本 | Bundle + AppUpdater 状态 | 有更新状态时优先显示动态消息 |+| Codex 版本 | `CodexCLIVersionSnapshot` + 当前 app-server 握手信息 | 路径点击复制到剪贴板 |错误显示:@@ -1124,16 +1128,17 @@ App 再次成为 active 时, 也会刷新 Hook、同步、菜单栏额度、主通知与触觉反馈判定在 `CodexBar/Services/Notifications/`, 偏好类随其他设置类放在 `CodexBar/Services/Settings/`:-- `NotificationSettings` (`Services/Settings/`): 总开关、五类通知子开关、任务触觉开关、低额度阈值 (5%/10%/25%, 默认 10%) 和长任务时长 (30s/1m/2m/5m, 默认 1m), 持久化到 UserDefaults; 负责系统授权请求、被拒状态镜像和设置页选项面板可展示状态+- `NotificationSettings` (`Services/Settings/`): 总开关、五类通知子开关及各自的声音、任务触觉开关、低额度阈值 (5%/10%/25%, 默认 10%) 和长任务时长 (30s/1m/2m/5m, 默认 1m), 持久化到 UserDefaults; 负责系统授权请求、被拒状态镜像和设置页选项面板可展示状态+- `NotificationSoundOption`: 定义系统提示音、静音、14 个经典提示音和 17 个现代提示音;非静音选项统一生成 `UNNotificationSound` 并为设置页提供同源 WAV 试听资源- `CodexCLINotificationSettings` (`Services/Settings/`): 通过 app-server 读取和写入用户级 `tui.notifications`; 支持解析布尔值与事件数组,缺失时按默认开启,写入后回读验证并把错误显示在通知选项行-- `CodexNotificationService`: 集中判定、去重、调度与发送; 由 `CodexBarAppDelegate` 创建, 订阅 `CodexStatusViewModel.$snapshot`、`CodexActivityMonitor` live transition 与 `NSWorkspace.didWakeNotification`; 五类正式通知共用 `CodexNotificationContent` 文案工厂,系统提交失败时重试一次,等待与完成 transition 还会按偏好请求 AppKit `.levelChange` 触觉反馈+- `CodexNotificationService`: 集中判定、去重、调度与发送; 由 `CodexBarAppDelegate` 创建, 订阅 `CodexStatusViewModel.$snapshot`、`CodexActivityMonitor` live transition 与 `NSWorkspace.didWakeNotification`; 五类正式通知共用 `CodexNotificationContent` 文案工厂并按类型附加用户选择的声音,系统提交失败时重试一次,等待与完成 transition 还会按偏好请求 AppKit `.levelChange` 触觉反馈- `CodexActivityMonitor`: Hook 开启期间始终运行并维护并发任务;向 UI 发布快照,向提醒服务发布 live transition。`PermissionRequest` 先作为审批候选,只有同 turn 的 rollout reviewer 为 `user` 才确认等待;自动 reviewer 或未知 reviewer 保持运行。单个 live 批次先完整应用事件,再按任务键合并已确认的等待候选;只有批次结束后仍处于等待的任务会使用最终快照发布一次等待 transition,完成候选保持顺序并按 completion ID 做批内去重。通知与触觉开关不会停止活动监测- `HookEventTailReader` (`Services/Workflow/`): 后台 actor;bootstrap 以 512 KB 为单次分块流式读取滚动 24 小时事件,并用 start/events/end 三阶段恢复状态。当前文件用 inode + 完整行 offset 固定 bootstrap/live 边界;bootstrap 结束后 monitor 再发起一次定向回溯,为缺少起点的精确 turn 向旧日期文件最多回读 8 MB。之后每 2 秒 tail 当日增量,保留半行、跨日先读旧文件尾部;live 每成功处理一个分块就推进到最后完整行 offset,后续分块失败只重试未处理部分。旧文件异常触发 bootstrap 时保留 bootstrap 设置的新日期 offset,临时读取失败则保留旧日期等待下轮重试。bootstrap、定时轮询和 Mac 唤醒补读共用串行入口,读取期间到达的请求合并为当前读取结束后的一次补读;monitor generation 会丢弃停用 reader 的迟到批次- `CodexSessionLifecycleReader`: 后台 actor,只为 monitor 当前活动或等待终态确认的精确 session + turn 定位对应 rollout;便宜目录每 10 秒重试,每个活跃生命周期最多递归 `sessions` 一次并保留负缓存,缓存文件移动、session 重新活跃或 Mac 唤醒时重置。rollout 初次最多读取末尾 512 KB,之后每 1 秒按 offset 增量读取;活跃 turn 的 effort 仍缺失且初始窗口未覆盖完整历史时,在任务开始至少 2 秒后从文件尾部最多 8 MB 定向回查,每轮查询最多处理一个 turn,失败至少间隔 10 秒重试。`task_started` 回填缺失起点,`task_complete` 补齐结束和精确耗时,`turn_aborted` 由 monitor 移除任务并生成灰色最近终止记录,`turn_context.approvals_reviewer` 用于确认 `PermissionRequest` 是否真的路由给用户,`turn_context.effort` 用于回填推理强度。读取失败时不把审批候选误判为等待,也不猜测 effort。同次查询同时包含 reviewer 和终态时,monitor 保留起点回填后优先处理终态并跳过审批候选确认。轮询和即时 lifecycle 查询都绑定 reader generation,跨 actor 返回后仍会复核,旧查询不能落入新 reader 状态活动并发以 session 为边界:不同 session 可以同时运行;同一 session 的 turn 按顺序执行。收到新的 `UserPromptSubmit` 时,monitor 会让该 session 中更早且缺少结束信号的 turn 立即退出活动列表,但保留为等待终态确认任务并触发一次即时 rollout 查询;5 秒内收到 Hook `Stop`、rollout `task_complete` 或 `turn_aborted` 时按真实终态归类,到期仍无终态才生成灰色最近终止记录。子 Agent 事件只能通过共享 session 关联父任务,早于当前顶层任务可信开始时间的事件会被当作上一 turn 的迟到事件忽略。已完成和已终止任务键分别保留 24 小时 tombstone,避免迟到事件恢复旧任务或误操作同 session 的新 turn。终止不会触发绿色完成状态、长任务通知或完成触觉反馈。Hook `Stop` 与 rollout `task_complete` 均视为完成信号,先到者生效,后到者按任务键和 session 回退键去重;重复完成不会覆盖首次确认结果,也不会缩短去重窗口或再次触发反馈。-设置页交互: 「系统通知」主开关行保留在设置窗口内, 子选项 (五类通知子开关、任务触觉开关、Codex TUI 通知开关与两个阈值 Picker) 在主选项右侧的子面板中展开 (`NotificationOptionsPanelController`, 复用 SidePanelSupport 抽屉机制挂在设置窗口上, 内容用常驻 hosting controller + ObservableObject 驱动, 面板尺寸在 Hook 开/关两种状态下保持不变)。「任务等待通知」和「任务触觉反馈」依次排列在「任务完成通知」下方。主开关开启后仅在系统授权允许时展开, 首次授权场景会等待授权结果; 点击行内滑杆按钮可手动展开; 设置窗口 resign key/关闭、主开关关闭或授权变为被拒时自动收起。任务完成、任务等待与任务触觉子项在 Hook 未开启时显示为关闭并置灰, 不修改各自持久化偏好, Hook 重新开启后恢复用户原选择。「Codex TUI 通知」与用户级 `[tui] notifications` 联动,面板打开时刷新,写入后回读验证;已有 CLI 会话需重启后生效。该项不服从 CodexBar 通知发送判定,也不修改顶层 `notify`。「任务中心」沿用相同依赖语义;关闭只隐藏活动卡片和任务中心入口,不停止 Monitor、状态点、通知或触觉反馈。授权被拒的引导文案与"打开系统设置"按钮仍内联显示在主开关行下方, 插入提示时不触发设置项纵向动画。+设置页交互: 「系统通知」主开关行保留在设置窗口内, 子选项 (五类通知子开关与声音、任务触觉开关、Codex TUI 通知开关及两个阈值 Picker) 在主选项右侧的子面板中展开 (`NotificationOptionsPanelController`, 复用 SidePanelSupport 抽屉机制挂在设置窗口上, 内容用常驻 hosting controller + ObservableObject 驱动)。五类通知按需使用双行布局:第一行展示通知名称、可选阈值和开关,阈值 Picker 位于开关前;通知开启且依赖可用时,第二行展示「通知音效」和加宽的声音菜单,关闭时整行从布局移除。控制器订阅五类通知开关和 Hook 状态,在 SwiftUI 完成布局后按 fitting size 动画调整面板高度并保持面板顶边位置,避免收起后残留空白。菜单顶层提供系统提示音和静音,其他声音按「经典提示音」和「现代提示音」子菜单分组。选择任意声音时立即试听,再次选择当前项可重复试听,新的试听会停止上一段自定义声音;系统提示音使用 `NSSound.beep()`, 静音不播放预览,其余声音优先播放 App 包内与正式通知同源的 WAV。选项依次排列为「任务完成通知」「任务等待通知」「额度预警通知」「额度重置通知」「重置临期通知」「任务触觉反馈」和「Codex TUI 通知」。主开关开启后仅在系统授权允许时展开, 首次授权场景会等待授权结果; 点击行内滑杆按钮可手动展开; 设置窗口 resign key/关闭、主开关关闭或授权变为被拒时自动收起。任务完成、任务等待与任务触觉子项在 Hook 未开启时显示为关闭并置灰, 不修改各自持久化偏好及声音, Hook 重新开启后恢复用户原选择。「Codex TUI 通知」与用户级 `[tui] notifications` 联动,面板打开时刷新,写入后回读验证;已有 CLI 会话需重启后生效。该项不服从 CodexBar 通知发送判定,也不修改顶层 `notify`。「主面板任务中心」沿用相同依赖语义;关闭只隐藏活动卡片和任务中心入口,不停止 Monitor、状态点、通知或触觉反馈。授权被拒的引导文案与"打开系统设置"按钮仍内联显示在主开关行下方, 插入提示时不触发设置项纵向动画。五类通知的触发与去重:@@ -1147,6 +1152,8 @@ App 再次成为 active 时, 也会刷新 Hook、同步、菜单栏额度、主额度低阈值、额度重置和重置机会通知只在系统成功接收后把去重键写入 UserDefaults (`Notification.sentKeys`),最多保留 300 条。键包含账号维度;额度重置窗口提供 `resetsAt` 时,去重键还包含该时间,缺失时仍发送通知但不生成周期去重键。额度重置观察状态和等待通知跟踪集合保存在当前进程内;通知不按预测时间调度,也不补发已错过的状态转换。可信额度快照持续推进重置观察状态,stale 快照不参与判定;窗口消失时移除对应观察状态,快照为 `nil` 时清空全部观察状态。Hook bootstrap 只恢复任务状态,不发布 transition,因此不产生历史任务通知或触觉反馈。+五类声音分别使用 `Notification.lowQuotaSound`、`Notification.quotaResetSound`、`Notification.longTaskSound`、`Notification.taskWaitingSound` 和 `Notification.creditExpirySound`。偏好缺失或保存值未知时回退到系统提示音,兼容升级前的用户数据;系统提示音提交 `.default`,静音提交 `nil`,其他选项提交 App 包根资源目录中的 `CodexBar-<Name>.wav`,由系统通知中心按系统授权、专注模式和通知设置决定是否实际播放。+「任务触觉反馈」使用 `Notification.taskHapticEnabled` 持久化,缺失时默认开启。等待批准和任意任务完成 transition 都启动一段触觉反馈任务:每 100 ms 请求一次 `.levelChange`,连续 10 次;新 transition 会取消并重启当前序列,开关关闭后会在下一脉冲前停止。触觉反馈不受长任务阈值与系统通知授权影响;App 内「系统通知」总开关关闭时不触发。`NSHapticFeedbackManager.defaultPerformer` 会按当前输入设备、辅助功能与系统偏好决定是否实际反馈及震感强弱。通知错误处理 (延续"细节不打扰用户"原则, 不写入请求日志窗口):diff --git a/Docs/UserGuide.md b/Docs/UserGuide.mdindex 6738e19..6e5664b 100644--- a/Docs/UserGuide.md+++ b/Docs/UserGuide.md@@ -35,8 +35,8 @@ CodexBar 是纯菜单栏 App,不显示 Dock 图标,也没有传统主窗口2. 右键点击菜单栏图标,选择「设置」。3. 根据需要开启「开机自动启动」和「自动检查更新」。4. 如果希望在菜单栏直接看到剩余额度,开启「菜单栏额度指示」并选择额度窗口。-5. 如果希望查看工作流统计、实时任务或任务提醒,开启「启用 Codex Hook」。-6. 开启 Hook 后,可继续开启「任务中心」和「跨设备同步」。+5. 如果希望查看工作流统计、实时任务或任务提醒,开启「CodexBar Hook」。+6. 开启 Hook 后,可继续开启「主面板任务中心」和「跨设备同步」。7. 如果希望接收提醒,开启「系统通知」,允许 macOS 通知权限,再打开右侧的通知选项。如果第一步显示「未登录」或「初始化失败」,先阅读[账号状态与数据刷新](#4-账号状态与数据刷新)。@@ -72,8 +72,8 @@ CodexBar 是纯菜单栏 App,不显示 Dock 图标,也没有传统主窗口| ---------------------- | ---------------------------------------------------- || 账号、额度、Token 用量 | Codex 已安装并登录 || 菜单栏额度指示 | 开启「菜单栏额度指示」,且所选额度窗口有数据 |-| 工作流统计 | 开启「启用 Codex Hook」 |-| 活动卡片与任务中心 | 开启「启用 Codex Hook」和「任务中心」 |+| 工作流统计 | 开启「CodexBar Hook」 |+| 活动卡片与任务中心 | 开启「CodexBar Hook」和「主面板任务中心」 || 任务状态点 | 开启 Hook,且当前主数据可用 || 跨设备同步 | 开启 Hook 和「跨设备同步」,并登录可用的 iCloud 账号 || 额度类通知 | 开启「系统通知」、macOS 通知权限和对应通知选项 |@@ -215,7 +215,7 @@ CodexBar 已读取到可用次数,但暂时没有取得有效过期时间。### 需要什么- Token 摘要和热力图不需要额外开关。-- 热力图中的工作流明细需要开启「启用 Codex Hook」。+- 热力图中的工作流明细需要开启「CodexBar Hook」。### 摘要指标@@ -283,11 +283,11 @@ Token 用量和 Hook 工作流统计来自不同功能。请确认当天使用 C### 开启步骤1. 打开设置。-2. 开启「启用 Codex Hook」。+2. 开启「CodexBar Hook」。3. 等待开关更新完成,确认下方没有错误提示。-4. 开启「任务中心」,让活动卡片显示在主面板中。+4. 开启「主面板任务中心」,让活动卡片显示在主面板中。-「任务中心」依赖 Hook。Hook 关闭时,该开关会显示为关闭并置灰;重新开启 Hook 后会恢复此前选择。+「主面板任务中心」依赖 Hook。Hook 关闭时,该开关会显示为关闭并置灰;重新开启 Hook 后会恢复此前选择。### 活动卡片图标@@ -343,8 +343,8 @@ Token 用量和 Hook 工作流统计来自不同功能。请确认当天使用 C依次检查:-1. 「启用 Codex Hook」是否开启且没有错误。-2. 「任务中心」是否开启。+1. 「CodexBar Hook」是否开启且没有错误。+2. 「主面板任务中心」是否开启。3. 该任务是否在开启 Hook 后启动。4. 当前使用的 Codex 是否为设置中标记「当前使用」的版本。5. 日志中是否有 Hook 验证或读取错误。@@ -415,14 +415,14 @@ Hook 与当前 App 位置相关。建议先在旧位置关闭 Hook,把 App 移### 开启条件-- 「启用 Codex Hook」已开启+- 「CodexBar Hook」已开启- 「跨设备同步」已开启- 当前 Mac 已登录可用的 iCloud 账号- 多台 Mac 使用同一个 iCloud 账号### 开启步骤-1. 先开启「启用 Codex Hook」。+1. 先开启「CodexBar Hook」。2. 确认 macOS 已登录 iCloud。3. 开启「跨设备同步」。4. 等待设置中出现「最近同步」时间,或在菜单底部查看 iCloud 图标。@@ -468,29 +468,32 @@ Hook 与当前 App 位置相关。建议先在旧位置关闭 Hook,把 App 移2. 开启「系统通知」。3. 在 macOS 弹窗中允许 CodexBar 发送通知。4. 点击「系统通知」右侧的滑杆图标。-5. 分别开启需要的通知类型并选择阈值。+5. 分别开启需要的通知类型,选择阈值与通知声音。如果通知权限被拒绝,设置中会显示提示和「打开系统设置」按钮。允许通知后,返回 CodexBar 即可继续配置。### 通知选项-| 选项 | 触发条件 | 依赖与设置 |-| ---------------- | ----------------------------- | ----------------------------------- |-| 额度预警通知 | 剩余额度下降到所选阈值 | 可选 5%、10%、25%,默认 10% |-| 额度重置通知 | 已使用过的额度恢复到 100% | 需要可用额度数据 |-| 任务完成通知 | 任务确认完成且耗时达到阈值 | 需要 Hook;可选 30 秒、1、2、5 分钟 |-| 任务等待通知 | 任务正在等待用户批准 | 需要 Hook |-| 任务触觉反馈 | 任务进入等待批准或确认结束 | 需要 Hook 和支持的输入设备 |-| 重置次数临期通知 | 手动重置机会将在 7 天内过期 | 需要读取到机会及过期时间 |-| Codex TUI 通知 | 控制 Codex CLI 自身的终端通知 | 修改后重新启动正在运行的 Codex 会话 |+| 选项 | 触发条件 | 依赖与设置 |+| -------------- | ----------------------------- | ----------------------------------- |+| 任务完成通知 | 任务确认完成且耗时达到阈值 | 需要 Hook;可选 30 秒、1、2、5 分钟 |+| 任务等待通知 | 任务正在等待用户批准 | 需要 Hook |+| 额度预警通知 | 剩余额度下降到所选阈值 | 可选 5%、10%、25%,默认 10% |+| 额度重置通知 | 已使用过的额度恢复到 100% | 需要可用额度数据 |+| 重置临期通知 | 手动重置机会将在 7 天内过期 | 需要读取到机会及过期时间 |+| 任务触觉反馈 | 任务进入等待批准或确认结束 | 需要 Hook 和支持的输入设备 |+| Codex TUI 通知 | 控制 Codex CLI 自身的终端通知 | 修改后重新启动正在运行的 Codex 会话 |任务完成、任务等待和任务触觉选项依赖 Hook。Hook 关闭时,它们会置灰,但会保留此前选择。+五类 CodexBar 系统通知都可以独立选择声音,默认使用 macOS 系统通知声;选择「静音」时只显示通知。声音菜单将选项分为 14 个经典提示音和 17 个现代提示音,包括 Basso、Glass、Sosumi、Antic、Droplet、Portal、Received Message 等。打开声音菜单并选择任意声音时会立即试听;再次选择当前声音可以重复试听。声音偏好会在通知关闭或 Hook 暂停时保留;Codex TUI 通知由 Codex CLI 自己播放,不使用这里的声音设置。+### 图标与状态| 图标或状态 | 含义 || ---------------------------- | ------------------------------ || 「系统通知」右侧滑杆 | 打开通知子选项 |+| 通知声音菜单 | 选择声音并立即试听 || Codex TUI 通知旁的小进度圈 | 正在读取或保存设置 || Codex TUI 通知旁的橙色感叹号 | 读取或保存失败;悬停可查看原因 || 「打开系统设置」按钮 | macOS 尚未授权 CodexBar 通知 |@@ -533,19 +536,19 @@ Hook 与当前 App 位置相关。建议先在旧位置关闭 Hook,把 App 移### 设置项说明-| 设置项 | 图标 | 作用 | 常见问题 |-| --------------- | -------- | ---------------------------------- | ------------------------------------------------------- |-| 开机自动启动 | 电源 | 登录 macOS 后自动运行 CodexBar | 设置失败时下方会显示错误;移动 App 后建议关闭再开启一次 |-| 自动检查更新 | 循环箭头 | 定期检查 CodexBar 新版本 | 关闭后仍可手动点击「检查更新」 |-| 菜单栏额度指示 | 仪表 | 在菜单栏显示所选额度窗口 | 没有对应额度数据时自动隐藏 |-| 启用 Codex Hook | 链接 | 开启工作流统计和实时任务能力 | 失败时根据该行下方提示处理 |-| 任务中心 | 列表 | 在主面板显示活动卡片和任务中心入口 | 需要 Hook;Hook 关闭时置灰 |-| 跨设备同步 | iCloud | 合并多台 Mac 的每日工作流统计 | 需要 Hook 和可用 iCloud 账号 |-| 重建数据 | 圆形箭头 | 重新生成所选日期的本机工作流统计 | 需要所选日期仍有本机记录 |-| 系统通知 | 铃铛 | 控制 CodexBar 通知与任务触觉总开关 | 首次开启需要 macOS 授权 |-| 使用快捷键 | 键盘 | 设置全局打开或关闭菜单面板的快捷键 | 至少需要两个修饰键 |-| Codex 版本 | 数字圆圈 | 查看已安装 Codex 及当前使用来源 | 点击路径可以复制 |-| CodexBar 版本 | 信息圆圈 | 查看当前版本与更新状态 | 有更新时显示下载按钮 |+| 设置项 | 图标 | 作用 | 常见问题 |+| -------------- | -------- | ---------------------------------- | ------------------------------------------------------- |+| 开机自动启动 | 电源 | 登录 macOS 后自动运行 CodexBar | 设置失败时下方会显示错误;移动 App 后建议关闭再开启一次 |+| 自动检查更新 | 循环箭头 | 定期检查 CodexBar 新版本 | 关闭后仍可手动点击「检查更新」 |+| 菜单栏额度指示 | 仪表 | 在菜单栏显示所选额度窗口 | 没有对应额度数据时自动隐藏 |+| 设置快捷键 | 键盘 | 设置全局打开或关闭菜单面板的快捷键 | 至少需要两个修饰键 |+| CodexBar Hook | 链接 | 开启工作流统计和实时任务能力 | 失败时根据该行下方提示处理 |+| 主面板任务中心 | 列表 | 在主面板显示活动卡片和任务中心入口 | 需要 Hook;Hook 关闭时置灰 |+| 系统通知 | 铃铛 | 控制 CodexBar 通知与任务触觉总开关 | 首次开启需要 macOS 授权 |+| 跨设备同步 | iCloud | 合并多台 Mac 的每日工作流统计 | 需要 Hook 和可用 iCloud 账号 |+| 重建数据 | 圆形箭头 | 重新生成所选日期的本机工作流统计 | 需要所选日期仍有本机记录 |+| CodexBar 版本 | 信息圆圈 | 查看当前版本与更新状态 | 有更新时显示下载按钮 |+| Codex 版本 | 数字圆圈 | 查看已安装 Codex 及当前使用来源 | 点击路径可以复制 |### 设置全局快捷键@@ -636,7 +639,7 @@ Hook 与当前 App 位置相关。建议先在旧位置关闭 Hook,把 App 移| 菜单栏没有额度竖条 | 开启「菜单栏额度指示」,并检查所选窗口是否有数据 || 看不到手动重置次数 | 当前账号没有可用机会,或数据尚未刷新 || 热力图没有工作流统计 | 开启 Hook,并确认该日期有 Hook 记录 |-| 活动卡片没有出现 | 同时开启 Hook 和「任务中心」 |+| 活动卡片没有出现 | 同时开启 Hook 和「主面板任务中心」 || 点击活动卡片没有反应 | 当前没有可展示任务,或主数据尚未加载 || 任务一直显示运行中 | 任务可能没有正常留下结束状态,等待后续活动或自动过期 || 跨设备同步开关置灰 | 先开启 Hook,并确认 iCloud 可用 |diff --git a/README.md b/README.mdindex c3e3405..0945d61 100644--- a/README.md+++ b/README.md@@ -14,7 +14,7 @@ CodexBar 是一款无 Dock 图标的 macOS 菜单栏应用。无需打开 Codex- **Token 热力图**:用近 30 周日历热力图回顾每日 Token 用量- **实时任务**:开启 Codex Hook 后,查看运行中、等待批准、最近完成和终止的任务- **工作流统计**:按日期查看会话、对话轮次、工具调用、权限请求、上下文压缩和子 Agent 等数据-- **及时提醒**:可选额度告急、额度恢复、等待批准、长任务完成通知与触觉反馈+- **及时提醒**:可选额度告急、额度恢复、等待批准、长任务完成通知与触觉反馈,各类通知可独立选择声音- **跨设备汇总**:通过可选的 iCloud 私有数据库同步每日聚合数据- **本地优先**:账号、额度、Token 用量和工作流事件均以本机处理为主- **原生体验**:支持全局快捷键、开机启动、系统日志和 Sparkle 自动更新diff --git a/appcast.xml b/appcast.xmlindex 8fc8efe..f457381 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 3.4.2</title>+ <sparkle:version>52</sparkle:version>+ <sparkle:shortVersionString>3.4.2</sparkle:shortVersionString>+ <sparkle:minimumSystemVersion>15.0</sparkle:minimumSystemVersion>+ <sparkle:releaseNotesLink>https://codexbar.zabrian.app/notes#3.4.2</sparkle:releaseNotesLink>+ <pubDate>Thu, 23 Jul 2026 14:20:05 +0800</pubDate>+ <enclosure url="https://codexbar.zabrian.app/download/CodexBar-v3.4.2.dmg" sparkle:edSignature="yLOeDCaJForqKjgFIORG3jBzbyWozlONQSM66pq9FLdL+cj4YYCbSkCtDAPiaDk4BlqN2pcVTcSTM4YEo3foAw==" length="5686121" type="application/octet-stream"/>+ </item><item><title>CodexBar.app 3.4.1</title><sparkle:version>51</sparkle:version>