Skip to content

CodexBar 是一个 macOS 菜单栏应用,用于查看本机 Codex 账号状态、额度、Token 用量、详细统计信息

feat: 为设置项提供即时悬浮说明

Bobd3272ff6370f
diff --git a/CodexBar.xcodeproj/project.pbxproj b/CodexBar.xcodeproj/project.pbxproj
index d2c980f..060f82f 100644
--- a/CodexBar.xcodeproj/project.pbxproj
+++ b/CodexBar.xcodeproj/project.pbxproj
@@ -60,10 +60,10 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
- B10000000000000000000014 /* CodexBarPowerHelper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CodexBarPowerHelper; sourceTree = BUILT_PRODUCTS_DIR; };
- C449FB5030203E0000ED2123 /* Version.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
A82000000000000000000001 /* Standard.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Standard.xctestplan; sourceTree = "<group>"; };
A82000000000000000000002 /* Sanitizers.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Sanitizers.xctestplan; sourceTree = "<group>"; };
+ B10000000000000000000014 /* CodexBarPowerHelper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CodexBarPowerHelper; sourceTree = BUILT_PRODUCTS_DIR; };
+ C449FB5030203E0000ED2123 /* Version.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
C4A0FD952FD9302E000263A7 /* CodexBar Debug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CodexBar Debug.app"; sourceTree = BUILT_PRODUCTS_DIR; };
D10000000000000000000002 /* CodexBarTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CodexBarTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
E10000000000000000000002 /* CodexBarPowerHelperTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CodexBarPowerHelperTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
diff --git a/CodexBar/Controllers/SettingsHelpPresenter.swift b/CodexBar/Controllers/SettingsHelpPresenter.swift
new file mode 100644
index 0000000..6a8a03d
--- /dev/null
+++ b/CodexBar/Controllers/SettingsHelpPresenter.swift
@@ -0,0 +1,123 @@
+import AppKit
+import Combine
+import SwiftUI
+
+@MainActor
+final class SettingsHelpPresenter {
+ private var panel: NSPanel?
+ private var presentedAnchorFrame: CGRect?
+ private var dismissObservers = Set<AnyCancellable>()
+
+ func show(_ help: LocalizedStringResource, anchorProvider: ScreenFrameProvider) {
+ hide()
+ guard let window = anchorProvider.window, window.isVisible,
+ let anchorFrame = anchorProvider.currentScreenFrame(in: window, allowingCachedFrame: false) else {
+ return
+ }
+
+ let visibleFrame = window.screen?.visibleFrame ?? window.frame
+ let maximumWidth = min(280, visibleFrame.width - SidePanelSupport.Metrics.screenPadding * 2)
+ let content = Text(help)
+ .font(.footnote)
+ .foregroundStyle(.primary)
+ .fixedSize(horizontal: false, vertical: true)
+ .padding(.horizontal, 12)
+ .padding(.vertical, 6)
+ let measuringController = NSHostingController(rootView: content)
+ measuringController.sizingOptions = []
+
+ // 测量宿主不接入窗口, 只排版文字, 避免表面效果参与无界高度的测量
+ let fittingSize = measuringController.sizeThatFits(in: CGSize(
+ width: maximumWidth,
+ height: .greatestFiniteMagnitude
+ ))
+ guard CGRect(origin: .zero, size: fittingSize).isValidScreenRect else {
+ return
+ }
+ let size = CGSize(
+ width: min(fittingSize.width.rounded(.up), maximumWidth),
+ height: fittingSize.height.rounded(.up)
+ )
+
+ // 提示不参与焦点与鼠标命中, 避免收起设置子面板或触发反复进入和移出
+ let panel = SidePanelSupport.makePanel(initialSize: size, ignoresMouseEvents: true)
+ let contentFrame = NSRect(origin: .zero, size: size)
+ let hostingView = NSHostingView(rootView:
+ content
+ .frame(width: size.width, height: size.height, alignment: .topLeading)
+ .sidePanelChrome(cornerRadius: 10)
+ )
+ hostingView.sizingOptions = []
+ hostingView.frame = contentFrame
+ hostingView.autoresizingMask = [.width, .height]
+
+ // 普通容器拥有窗口尺寸, SwiftUI 只绘制已测量的固定区域, 不反向更新窗口约束
+ let container = NSView(frame: contentFrame)
+ container.addSubview(hostingView)
+ panel.contentView = container
+ panel.level = window.level
+ let position = SidePanelSupport.position(
+ panelSize: size,
+ menuSurfaceFrame: anchorFrame,
+ visibleFrame: visibleFrame,
+ preferredSide: .right,
+ proposedY: anchorFrame.maxY - size.height,
+ clampsToSurfaceBottom: false
+ )
+ panel.setFrame(position.frame, display: false)
+ self.panel = panel
+ presentedAnchorFrame = anchorFrame
+ SidePanelSupport.attach(panel, to: window)
+ panel.order(.above, relativeTo: window.windowNumber)
+ observeDismissal(in: window)
+ }
+
+ func hide() {
+ dismissObservers.removeAll()
+ presentedAnchorFrame = nil
+ guard let panel else {
+ return
+ }
+
+ SidePanelSupport.orderOut(panel, menuSurfaceWindow: panel.parent)
+ self.panel = nil
+ }
+
+ func updateAnchorFrame(_ frame: CGRect?) {
+ if let presentedAnchorFrame, presentedAnchorFrame != frame {
+ hide()
+ }
+ }
+
+ private func observeDismissal(in window: NSWindow) {
+ let center = NotificationCenter.default
+ center.publisher(for: NSApplication.didResignActiveNotification)
+ .sink { [weak self] _ in self?.hide() }
+ .store(in: &dismissObservers)
+
+ // 子选项面板可能没有键盘焦点, 也要跟随主设置窗口的关闭和失焦
+ var ancestor: NSWindow? = window
+ while let current = ancestor {
+ center.publisher(for: NSWindow.didChangeOcclusionStateNotification, object: current)
+ .sink { [weak self, weak current] _ in
+ if current?.isVisible != true {
+ self?.hide()
+ }
+ }
+ .store(in: &dismissObservers)
+
+ for name in [
+ NSWindow.willCloseNotification,
+ NSWindow.willMiniaturizeNotification,
+ NSWindow.didResignKeyNotification,
+ NSWindow.willMoveNotification,
+ NSWindow.didResizeNotification
+ ] {
+ center.publisher(for: name, object: current)
+ .sink { [weak self] _ in self?.hide() }
+ .store(in: &dismissObservers)
+ }
+ ancestor = current.parent
+ }
+ }
+}
diff --git a/CodexBar/Controllers/SettingsWindowController.swift b/CodexBar/Controllers/SettingsWindowController.swift
index 0319884..8130727 100644
--- a/CodexBar/Controllers/SettingsWindowController.swift
+++ b/CodexBar/Controllers/SettingsWindowController.swift
@@ -144,7 +144,7 @@ final class SettingsWindowController: HostingWindowController {
private enum Metrics {
static let minimumContentSize = NSSize(width: 420, height: 240)
- static let initialContentSize = NSSize(width: 430, height: 270)
+ static let initialContentSize = NSSize(width: AppSettingsView.preferredContentWidth, height: 270)
static let maximumFallbackContentSize = NSSize(width: 560, height: 720)
/// 只用于首次定位的稳定顶边基准 不限制页面自适应高度
static let topEdgeReferenceContentHeight: CGFloat = 500
diff --git a/CodexBar/Resources/Localizable.xcstrings b/CodexBar/Resources/Localizable.xcstrings
index 1930abe..7f68d72 100644
--- a/CodexBar/Resources/Localizable.xcstrings
+++ b/CodexBar/Resources/Localizable.xcstrings
@@ -2289,6 +2289,22 @@
}
}
},
+ "auto-reset.lead-time.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Choose how long before a banked reset expires to start trying to use it automatically"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "设置留存重置过期前多久开始尝试自动使用"
+ }
+ }
+ }
+ },
"auto-reset.lead-time.two-hours" : {
"localizations" : {
"en" : {
@@ -3409,6 +3425,22 @@
}
}
},
+ "history.rebuild.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Recalculate historical statistics for a selected date or date range using the collected source data. This can restore missing or incomplete statistics. Rebuilt results are synced if sync is enabled. Lost source data cannot be recovered"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "选择指定的日期或者日期范围,根据采集到的原始数据重新计算历史统计。可用于修复缺失或不完整的数据,开启同步时会同步重建结果;已丢失的原始数据无法恢复"
+ }
+ }
+ }
+ },
"hotkey.error.default-in-use" : {
"localizations" : {
"en" : {
@@ -3521,66 +3553,66 @@
}
}
},
- "keep-alive.display.caption" : {
+ "keep-alive.display.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Also prevent the screen saver and auto-lock"
+ "value" : "Keep Display Awake"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "同时阻止屏幕保护与自动锁屏"
+ "value" : "保持屏幕常亮"
}
}
}
},
- "keep-alive.display.title" : {
+ "keep-alive.display.title.help" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Keep Display Awake"
+ "value" : "Keep the display on while sleep prevention is active, and prevent the screen saver from starting or your Mac from locking automatically"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "保持屏幕常亮"
+ "value" : "在防睡眠生效期间保持屏幕常亮,同时阻止屏幕保护与自动锁屏"
}
}
}
},
- "keep-alive.duration-limit.caption" : {
+ "keep-alive.duration-limit.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Restore normal sleep when the limit is reached"
+ "value" : "Keep-Awake Limit"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "防睡眠时长超过阈值后自动恢复系统睡眠"
+ "value" : "最长防睡眠时间"
}
}
}
},
- "keep-alive.duration-limit.title" : {
+ "keep-alive.duration-limit.title.help" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Keep-Awake Limit"
+ "value" : "Limit how long CodexBar can keep your Mac awake continuously. Normal sleep resumes when the limit is reached"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "最长防睡眠时间"
+ "value" : "限制单次连续防睡眠的最长时间,达到上限后恢复系统睡眠"
}
}
}
@@ -3681,50 +3713,50 @@
}
}
},
- "keep-alive.low-battery.caption" : {
+ "keep-alive.low-battery.off" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Battery only; resumes when charging"
+ "value" : "Off"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "仅在使用电池供电时生效, 充电时自动恢复"
+ "value" : "关闭"
}
}
}
},
- "keep-alive.low-battery.off" : {
+ "keep-alive.low-battery.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Off"
+ "value" : "Low Battery Protection"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "关闭"
+ "value" : "低电量保护"
}
}
}
},
- "keep-alive.low-battery.title" : {
+ "keep-alive.low-battery.title.help" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Low Battery Protection"
+ "value" : "While your Mac is running on battery power, stop preventing sleep when the battery level drops to the threshold. Resume sleep prevention automatically when your Mac is connected to power"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "低电量保护"
+ "value" : "仅在使用电池供电时生效;电量降至阈值时停止防睡眠,接通电源后自动恢复防睡眠"
}
}
}
@@ -3777,34 +3809,34 @@
}
}
},
- "keep-alive.waiting.caption" : {
+ "keep-alive.waiting.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Prevent sleep while a task awaits a response"
+ "value" : "Keep Awake While Waiting"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "任务等待回应期间继续防止系统睡眠"
+ "value" : "等待回应时保持防睡眠"
}
}
}
},
- "keep-alive.waiting.title" : {
+ "keep-alive.waiting.title.help" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Keep Awake While Waiting"
+ "value" : "Continue keeping your Mac awake while Codex tasks are waiting for your response"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "等待回应时保持防睡眠"
+ "value" : "Codex 任务在等待用户回应期间也防止系统睡眠"
}
}
}
@@ -4769,66 +4801,66 @@
}
}
},
- "protection.caption" : {
+ "protection.duration.hours" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Hide inactive tasks and exclude them from keep-awake"
+ "value" : "%lld hr"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "任务长时间没有进展时隐藏并停止参与防睡眠"
+ "value" : "%lld 小时"
}
}
}
},
- "protection.duration.hours" : {
+ "protection.duration.thirty-minutes" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "%lld hr"
+ "value" : "30 min"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "%lld 小时"
+ "value" : "30 分钟"
}
}
}
},
- "protection.duration.thirty-minutes" : {
+ "protection.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "30 min"
+ "value" : "Stalled Task Protection"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "30 分钟"
+ "value" : "异常任务保护"
}
}
}
},
- "protection.title" : {
+ "protection.title.help" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Stalled Task Protection"
+ "value" : "Hide running tasks that have made no progress for an extended period and stop counting them as tasks that keep your Mac awake. This check does not apply to tasks waiting for your response"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "异常任务保护"
+ "value" : "隐藏长时间未取得进展的运行中任务,并停止将其计入防止睡眠的任务。等待用户回应的任务不参与此判定"
}
}
}
@@ -5126,7 +5158,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Dark Mode"
+ "value" : "Dark"
}
},
"zh-Hans" : {
@@ -5142,7 +5174,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Light Mode"
+ "value" : "Light"
}
},
"zh-Hans" : {
@@ -5158,7 +5190,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Follow System"
+ "value" : "System"
}
},
"zh-Hans" : {
@@ -5185,6 +5217,22 @@
}
}
},
+ "settings.appearance.theme.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Choose the app's appearance"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "选择 App 外观"
+ }
+ }
+ }
+ },
"settings.auto-reset.title" : {
"localizations" : {
"en" : {
@@ -5201,6 +5249,22 @@
}
}
},
+ "settings.auto-reset.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Enable or disable automatic use of banked resets that are about to expire"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启用/禁用 自动使用临近过期的留存重置"
+ }
+ }
+ }
+ },
"settings.codex.connection.action.reconnect" : {
"localizations" : {
"en" : {
@@ -5313,6 +5377,22 @@
}
}
},
+ "settings.data-update.interval.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Set how often data is refreshed"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "设置数据的刷新间隔"
+ }
+ }
+ }
+ },
"settings.general.automatic-update-checks" : {
"localizations" : {
"en" : {
@@ -5329,6 +5409,22 @@
}
}
},
+ "settings.general.automatic-update-checks.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Enable or disable automatic checks for new versions of CodexBar. You can still check for updates manually from the About page when this is disabled"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启用/禁用 自动检查是否有新的 CodexBar 版本,关闭后仍可在关于页面手动检查更新"
+ }
+ }
+ }
+ },
"settings.general.launch-at-login" : {
"localizations" : {
"en" : {
@@ -5377,6 +5473,22 @@
}
}
},
+ "settings.general.launch-at-login.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Enable or disable launching CodexBar automatically when you log in to macOS"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启用/禁用 登录 macOS 后自动启动 CodexBar"
+ }
+ }
+ }
+ },
"settings.hotkey.action.clear" : {
"localizations" : {
"en" : {
@@ -5425,6 +5537,22 @@
}
}
},
+ "settings.hotkey.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Set a global keyboard shortcut to show or hide the CodexBar main panel. To change it, clear the current shortcut, then click to record a new one. Press Esc to cancel recording"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "设置用于打开或收起 CodexBar 主面板的全局快捷键。修改前先清除现有快捷键,再点击录制;按 Esc 取消录制"
+ }
+ }
+ }
+ },
"settings.keep-alive.title" : {
"localizations" : {
"en" : {
@@ -5441,6 +5569,22 @@
}
}
},
+ "settings.keep-alive.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Enable or disable sleep prevention while Codex tasks are running"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启用/禁用 Codex 任务运行期间防止系统睡眠"
+ }
+ }
+ }
+ },
"settings.main-panel.animations" : {
"localizations" : {
"en" : {
@@ -5457,6 +5601,22 @@
}
}
},
+ "settings.main-panel.animations.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Enable or disable animations in the app"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启用/禁用 App 内展示动画效果"
+ }
+ }
+ }
+ },
"settings.main-panel.layout.title" : {
"localizations" : {
"en" : {
@@ -5473,6 +5633,22 @@
}
}
},
+ "settings.main-panel.layout.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Choose which sections appear in the main panel and in what order. Drag a section's icon on the left to move it. Keep at least one section visible"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "调整主面板各模块的显示和顺序,拖动模块左侧图标可调节顺序;需要至少保留一个模块"
+ }
+ }
+ }
+ },
"settings.main-panel.section.account" : {
"localizations" : {
"en" : {
@@ -5585,6 +5761,22 @@
}
}
},
+ "settings.menu-bar-quota.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Enable or disable quota display in the menu bar icon"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启用/禁用 菜单栏图标显示额度信息"
+ }
+ }
+ }
+ },
"settings.menu-bar-quota.window" : {
"localizations" : {
"en" : {
@@ -5617,6 +5809,22 @@
}
}
},
+ "settings.notifications.auto-reset.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Notify you when an automatic reset succeeds or fails. Automatic Reset must be enabled"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "自动重置成功或失败时发送通知。需要开启自动重置功能"
+ }
+ }
+ }
+ },
"settings.notifications.banked-reset-expiry.title" : {
"localizations" : {
"en" : {
@@ -5633,18 +5841,18 @@
}
}
},
- "settings.notifications.codex-tui.caption" : {
+ "settings.notifications.banked-reset-expiry.title.help" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Separate from CodexBar notifications"
+ "value" : "Notify you when banked resets are about to expire"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Codex TUI 通知, 独立于 CodexBar 通知"
+ "value" : "在留存重置次数即将过期时发送通知"
}
}
}
@@ -5665,6 +5873,22 @@
}
}
},
+ "settings.notifications.codex-tui.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Codex TUI notifications are separate from CodexBar notifications"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Codex TUI 通知,独立于 CodexBar 的通知类型"
+ }
+ }
+ }
+ },
"settings.notifications.keep-alive-limit.title" : {
"localizations" : {
"en" : {
@@ -5681,6 +5905,22 @@
}
}
},
+ "settings.notifications.keep-alive-limit.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Notify you when the keep-awake time limit is reached and normal sleep resumes. Sleep prevention must be enabled and the time limit must be set to a value other than Unlimited"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "达到最长防睡眠时间并恢复系统睡眠时发送通知。需要启用防睡眠功能,且时长上限不是无限制"
+ }
+ }
+ }
+ },
"settings.notifications.low-battery.title" : {
"localizations" : {
"en" : {
@@ -5697,6 +5937,22 @@
}
}
},
+ "settings.notifications.low-battery.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Notify you when CodexBar stops keeping your Mac awake because the battery is low. Both sleep prevention and low battery protection must be enabled"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "因电量过低而停止防睡眠时发送通知,需要启用防睡眠功能,且启用低电量保护"
+ }
+ }
+ }
+ },
"settings.notifications.low-quota.threshold" : {
"localizations" : {
"en" : {
@@ -5729,6 +5985,22 @@
}
}
},
+ "settings.notifications.low-quota.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Notify you when your remaining quota drops to the selected threshold"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "当剩余额度降至设置阈值时发送通知"
+ }
+ }
+ }
+ },
"settings.notifications.quota-reset.title" : {
"localizations" : {
"en" : {
@@ -5745,6 +6017,22 @@
}
}
},
+ "settings.notifications.quota-reset.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Notify you when your quota has reset"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "当额度已重置时发送通知"
+ }
+ }
+ }
+ },
"settings.notifications.sound.title" : {
"localizations" : {
"en" : {
@@ -5793,6 +6081,22 @@
}
}
},
+ "settings.notifications.system.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Enable or disable CodexBar notifications. The first time you turn this on, you'll need to grant notification permission in macOS"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启用/禁用 CodexBar 发送通知,首次开启需要 macOS 通知授权"
+ }
+ }
+ }
+ },
"settings.notifications.task-completion.minimum-duration" : {
"localizations" : {
"en" : {
@@ -5825,18 +6129,18 @@
}
}
},
- "settings.notifications.task-haptics.caption" : {
+ "settings.notifications.task-completion.title.help" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Trackpad haptics when tasks finish or await a response"
+ "value" : "Notify you when a Codex task completes after running for at least the selected duration"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "任务完成或等待回应时触发触摸板震动"
+ "value" : "Codex 任务完成时发送通知,运行时长低于设置阈值的 Codex 任务不会发送通知"
}
}
}
@@ -5857,6 +6161,22 @@
}
}
},
+ "settings.notifications.task-haptics.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Trigger haptic feedback on the trackpad when a task completes or needs your response"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "任务完成或等待回应时触发触摸板触觉反馈"
+ }
+ }
+ }
+ },
"settings.notifications.task-waiting.title" : {
"localizations" : {
"en" : {
@@ -5873,6 +6193,22 @@
}
}
},
+ "settings.notifications.task-waiting.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Notify you when a Codex task needs your response"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Codex 任务需要用户回应时发送通知"
+ }
+ }
+ }
+ },
"settings.sync.title" : {
"localizations" : {
"en" : {
@@ -5889,6 +6225,22 @@
}
}
},
+ "settings.sync.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Enable or disable data syncing across devices using your iCloud account"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启用/禁用 通过 iCloud 账户同步不同设备的数据"
+ }
+ }
+ }
+ },
"settings.tab.about" : {
"localizations" : {
"en" : {
@@ -5953,6 +6305,22 @@
}
}
},
+ "settings.task-glow.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Enable or disable the glow at the top of the screen that shows Codex task status"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启用/禁用 屏幕顶部通过流光展示 Codex 任务状态"
+ }
+ }
+ }
+ },
"settings.window.title" : {
"localizations" : {
"en" : {
@@ -6161,6 +6529,22 @@
}
}
},
+ "task-glow.brightness.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Adjust the brightness of the glow"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "调整流光效果的亮度"
+ }
+ }
+ }
+ },
"task-glow.color.completed" : {
"localizations" : {
"en" : {
@@ -6177,18 +6561,18 @@
}
}
},
- "task-glow.color.preview-help" : {
+ "task-glow.color.help" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Double-click to preview effect"
+ "value" : "Choose the glow color for this task state. Double-click the color swatch to preview the effect"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "双击预览效果"
+ "value" : "设置此任务状态的流光颜色,双击色块可预览效果"
}
}
}
@@ -6257,6 +6641,22 @@
}
}
},
+ "task-glow.duration.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Choose how long the glow stays visible after a task completes or is stopped"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "任务完成或终止后,对应流光效果展示时长"
+ }
+ }
+ }
+ },
"task-glow.speed.fast" : {
"localizations" : {
"en" : {
@@ -6321,6 +6721,22 @@
}
}
},
+ "task-glow.speed.title.help" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Adjust the speed of the glow animation"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "调整流光动画的运动速度"
+ }
+ }
+ }
+ },
"updater.action.check" : {
"localizations" : {
"en" : {
@@ -6646,7 +7062,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Cache-H"
+ "value" : "Cache-HR%"
}
},
"zh-Hans" : {
@@ -6662,7 +7078,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Cache-W"
+ "value" : "Cache-WR"
}
},
"zh-Hans" : {
@@ -6755,4 +7171,4 @@
}
},
"version" : "1.0"
-}
+}
\ No newline at end of file
diff --git a/CodexBar/Views/Menu/QuotaRow.swift b/CodexBar/Views/Menu/QuotaRow.swift
index 1d2fcdc..dcd1c15 100644
--- a/CodexBar/Views/Menu/QuotaRow.swift
+++ b/CodexBar/Views/Menu/QuotaRow.swift
@@ -114,9 +114,9 @@ private extension QuotaRow {
static let resetFormatter: DateFormatter = {
let formatter = DateFormatter()
- formatter.locale = .autoupdatingCurrent
+ formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = .autoupdatingCurrent
- formatter.setLocalizedDateFormatFromTemplate("MMddjmm")
+ formatter.dateFormat = "MM/dd HH:mm"
return formatter
}()
}
diff --git a/CodexBar/Views/Settings/AppSettingsView.swift b/CodexBar/Views/Settings/AppSettingsView.swift
index 61f6d12..eef2394 100644
--- a/CodexBar/Views/Settings/AppSettingsView.swift
+++ b/CodexBar/Views/Settings/AppSettingsView.swift
@@ -4,6 +4,8 @@ import SwiftUI
/// 设置窗口根视图, 按通用, 高级和关于分页汇总设置与版本信息
struct AppSettingsView: View {
+ static let preferredContentWidth: CGFloat = 470
+
@EnvironmentObject private var statusViewModel: CodexStatusViewModel
@EnvironmentObject private var appUpdater: AppUpdater
@EnvironmentObject private var animationState: SettingsWindowAnimationState
@@ -65,7 +67,7 @@ struct AppSettingsView: View {
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
}
.font(SettingsRowMetrics.bodyFont)
- .frame(width: Metrics.windowWidth)
+ .frame(width: Self.preferredContentWidth)
.frame(maxHeight: .infinity, alignment: .top)
.liquidGlassSurface(
cornerRadii: RectangleCornerRadii(
@@ -178,14 +180,13 @@ struct AppSettingsView: View {
private extension AppSettingsView {
enum Metrics {
static let padding: CGFloat = 12
- static let windowWidth: CGFloat = 430
static let sectionSpacing: CGFloat = 18
static let rowSpacing: CGFloat = 14
static let panelPadding: CGFloat = 12
static let githubIconSize: CGFloat = 16
static let surfaceCornerRadius: CGFloat = 16
static let panelCornerRadius: CGFloat = 10
- static let tabBarWidth = windowWidth - padding * 2
+ static let tabBarWidth = AppSettingsView.preferredContentWidth - padding * 2
static let tabBarHeight: CGFloat = 38
static let tabBarPadding: CGFloat = 4
static let tabSpacing: CGFloat = 4
@@ -357,7 +358,7 @@ private extension AppSettingsView {
Image(systemName: "circle.lefthalf.filled")
.frame(width: SettingsRowMetrics.iconWidth)
.foregroundStyle(.tint)
- Text("settings.appearance.theme.title")
+ SettingsHelpLabel(title: "settings.appearance.theme.title", help: "settings.appearance.theme.title.help")
Spacer()
SettingsOptionsPicker(
title: "settings.appearance.theme.title",
@@ -389,6 +390,7 @@ private extension AppSettingsView {
SettingsToggleRow(
icon: "power",
title: "settings.general.launch-at-login",
+ help: "settings.general.launch-at-login.help",
isOn: Binding(
get: { loginItemSettings.isEnabled },
set: { loginItemSettings.setEnabled($0) }
@@ -410,6 +412,7 @@ private extension AppSettingsView {
SettingsToggleRow(
icon: "arrow.triangle.2.circlepath",
title: "settings.general.automatic-update-checks",
+ help: "settings.general.automatic-update-checks.help",
isOn: Binding(
get: { appUpdater.automaticallyChecksForUpdates },
set: { appUpdater.setAutomaticallyChecksForUpdates($0) }
@@ -428,6 +431,7 @@ private extension AppSettingsView {
return SettingsToggleRow(
icon: "gauge.with.dots.needle.50percent",
title: "settings.menu-bar-quota.title",
+ help: "settings.menu-bar-quota.title.help",
isOn: Binding(
get: { isMenuBarQuotaEnabled },
set: { menuBarQuotaSettings.setEnabled($0) }
@@ -497,7 +501,7 @@ private extension AppSettingsView {
Image(systemName: "timer")
.frame(width: SettingsRowMetrics.iconWidth)
.foregroundStyle(.tint)
- Text("settings.data-update.interval.title")
+ SettingsHelpLabel(title: "settings.data-update.interval.title", help: "settings.data-update.interval.title.help")
Spacer()
SettingsOptionsPicker(
title: "settings.data-update.interval.title",
@@ -522,6 +526,7 @@ private extension AppSettingsView {
SettingsToggleRow(
icon: "arrow.counterclockwise.circle",
title: "settings.auto-reset.title",
+ help: "settings.auto-reset.title.help",
isOn: Binding(
get: { autoResetSettings.isEnabled },
set: { enabled in
@@ -600,6 +605,7 @@ private extension AppSettingsView {
SettingsToggleRow(
icon: "moon.zzz",
title: "settings.keep-alive.title",
+ help: "settings.keep-alive.title.help",
isOn: Binding(
get: { keepAliveController.isEnabled },
set: { enabled in
@@ -712,6 +718,7 @@ private extension AppSettingsView {
SettingsToggleRow(
icon: "icloud",
title: "settings.sync.title",
+ help: "settings.sync.title.help",
isOn: Binding(
get: { state.isActive },
set: { enabled in
@@ -782,7 +789,7 @@ private extension AppSettingsView {
.frame(width: SettingsRowMetrics.iconWidth)
.foregroundStyle(.tint)
- Text("history.rebuild.title")
+ SettingsHelpLabel(title: "history.rebuild.title", help: "history.rebuild.title.help")
.lineLimit(1)
.fixedSize(horizontal: true, vertical: false)
@@ -910,6 +917,7 @@ private extension AppSettingsView {
SettingsToggleRow(
icon: "bell.badge",
title: "settings.notifications.system.title",
+ help: "settings.notifications.system.title.help",
isOn: Binding(
get: { notificationSettings.isEnabled },
set: { notificationSettings.setEnabled($0) }
diff --git a/CodexBar/Views/Settings/AppearanceSettingsRows.swift b/CodexBar/Views/Settings/AppearanceSettingsRows.swift
index 9a83552..6578721 100644
--- a/CodexBar/Views/Settings/AppearanceSettingsRows.swift
+++ b/CodexBar/Views/Settings/AppearanceSettingsRows.swift
@@ -7,6 +7,7 @@ struct MainPanelAnimationsSettingsRow: View {
SettingsToggleRow(
icon: "sparkles",
title: "settings.main-panel.animations",
+ help: "settings.main-panel.animations.help",
isOn: Binding(
get: { settings.areAnimationsEnabled },
set: { settings.setAnimationsEnabled($0) }
@@ -28,6 +29,7 @@ struct TaskGlowSettingsRow: View {
SettingsToggleRow(
icon: "light.max",
title: "settings.task-glow.title",
+ help: "settings.task-glow.title.help",
isOn: Binding(
get: { settings.isEnabled },
set: { settings.setEnabled($0) }
diff --git a/CodexBar/Views/Settings/AutoResetOptionsView.swift b/CodexBar/Views/Settings/AutoResetOptionsView.swift
index 825c344..9f060a5 100644
--- a/CodexBar/Views/Settings/AutoResetOptionsView.swift
+++ b/CodexBar/Views/Settings/AutoResetOptionsView.swift
@@ -6,7 +6,7 @@ struct AutoResetOptionsView: View {
var body: some View {
HStack(spacing: Metrics.controlSpacing) {
- Text("auto-reset.lead-time.title")
+ SettingsHelpLabel(title: "auto-reset.lead-time.title", help: "auto-reset.lead-time.title.help")
.font(SettingsRowMetrics.captionFont)
.foregroundStyle(.secondary)
diff --git a/CodexBar/Views/Settings/HotKeyRecorderRow.swift b/CodexBar/Views/Settings/HotKeyRecorderRow.swift
index b90a5cd..b5904ea 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("settings.hotkey.title")
+ SettingsHelpLabel(title: "settings.hotkey.title", help: "settings.hotkey.title.help")
.font(SettingsRowMetrics.bodyFont)
Spacer()
diff --git a/CodexBar/Views/Settings/KeepAliveOptionsView.swift b/CodexBar/Views/Settings/KeepAliveOptionsView.swift
index b1f5600..d2ecfff 100644
--- a/CodexBar/Views/Settings/KeepAliveOptionsView.swift
+++ b/CodexBar/Views/Settings/KeepAliveOptionsView.swift
@@ -29,7 +29,7 @@ struct KeepAliveOptionsView: View {
CGSize(
width: Metrics.panelWidth,
height: Metrics.verticalPadding * 2
- + (Metrics.rowHeight + Metrics.captionRowHeight) * CGFloat(Metrics.maximumRowCount)
+ + Metrics.rowHeight * CGFloat(Metrics.maximumRowCount)
+ Metrics.rowSpacing * CGFloat(Metrics.maximumRowCount - 1)
)
}
@@ -37,7 +37,7 @@ struct KeepAliveOptionsView: View {
private var maximumDurationRow: some View {
pickerRow(
title: "keep-alive.duration-limit.title",
- caption: "keep-alive.duration-limit.caption",
+ help: "keep-alive.duration-limit.title.help",
selection: Binding(
get: { keepAliveController.maximumDuration },
set: { keepAliveController.setMaximumDuration($0) }
@@ -50,7 +50,7 @@ struct KeepAliveOptionsView: View {
private var protectionRow: some View {
pickerRow(
title: "protection.title",
- caption: "protection.caption",
+ help: "protection.title.help",
selection: Binding(
get: { protectionSettings.inactivityDuration },
set: { protectionSettings.setInactivityDuration($0) }
@@ -64,7 +64,7 @@ struct KeepAliveOptionsView: View {
private var waitingApprovalRow: some View {
toggleRow(
title: "keep-alive.waiting.title",
- caption: "keep-alive.waiting.caption",
+ help: "keep-alive.waiting.title.help",
isOn: Binding(
get: { keepAliveController.keepsAwakeWhileWaiting },
set: { keepAliveController.setKeepsAwakeWhileWaiting($0) }
@@ -76,7 +76,7 @@ struct KeepAliveOptionsView: View {
private var displayAwakeRow: some View {
toggleRow(
title: "keep-alive.display.title",
- caption: "keep-alive.display.caption",
+ help: "keep-alive.display.title.help",
isOn: Binding(
get: { keepAliveController.keepsDisplayAwake },
set: { keepAliveController.setKeepsDisplayAwake($0) }
@@ -87,7 +87,7 @@ struct KeepAliveOptionsView: View {
private var lowBatteryRow: some View {
pickerRow(
title: "keep-alive.low-battery.title",
- caption: "keep-alive.low-battery.caption",
+ help: "keep-alive.low-battery.title.help",
selection: Binding(
get: { keepAliveController.lowBatteryThreshold },
set: { keepAliveController.setLowBatteryThreshold($0) }
@@ -99,12 +99,12 @@ struct KeepAliveOptionsView: View {
private func pickerRow<Option: Hashable>(
title: LocalizedStringResource,
- caption: LocalizedStringResource,
+ help: LocalizedStringResource,
selection: Binding<Option>,
options: [Option],
label: KeyPath<Option, String>
) -> some View {
- row(title: title, caption: caption) {
+ row(title: title, help: help) {
SettingsOptionsPicker(
title: title,
selection: selection,
@@ -119,10 +119,10 @@ struct KeepAliveOptionsView: View {
/// 开关的修饰链与通知子面板的 optionRow 保持一致, 两个面板才是同一套控件
private func toggleRow(
title: LocalizedStringResource,
- caption: LocalizedStringResource,
+ help: LocalizedStringResource,
isOn: Binding<Bool>
) -> some View {
- row(title: title, caption: caption) {
+ row(title: title, help: help) {
Toggle(title, isOn: isOn)
.labelsHidden()
.toggleStyle(.switch)
@@ -130,44 +130,31 @@ struct KeepAliveOptionsView: View {
}
}
- /// 面板里每一行都是控件行加一句固定说明, 说明那行与通知子面板的音效子行同一套字号和层级
private func row(
title: LocalizedStringResource,
- caption: LocalizedStringResource,
+ help: LocalizedStringResource,
@ViewBuilder control: () -> some View
) -> some View {
- VStack(spacing: 0) {
- HStack(spacing: Metrics.controlSpacing) {
- Text(title)
- .font(SettingsRowMetrics.captionFont)
- .foregroundStyle(.secondary)
+ HStack(spacing: Metrics.controlSpacing) {
+ SettingsHelpLabel(title: title, help: help)
+ .font(SettingsRowMetrics.captionFont)
+ .foregroundStyle(.secondary)
- Spacer(minLength: 8)
+ Spacer(minLength: 8)
- control()
- }
- .frame(height: Metrics.rowHeight)
-
- HStack(spacing: 0) {
- Text(caption)
- .font(SettingsRowMetrics.captionFont)
- .foregroundStyle(.tertiary)
-
- Spacer(minLength: 0)
- }
- .frame(height: Metrics.captionRowHeight)
+ control()
}
+ .frame(height: Metrics.rowHeight)
}
private enum Metrics {
- static let panelWidth: CGFloat = 250
+ static let panelWidth: CGFloat = 280
/// 有内置电池的设备时行数, 无内置电池设备少一行低电量保护
static let maximumRowCount = 5
static let horizontalPadding = SettingsOptionsPanelMetrics.horizontalPadding
static let verticalPadding = SettingsOptionsPanelMetrics.verticalPadding
static let rowSpacing = SettingsOptionsPanelMetrics.rowSpacing
static let rowHeight = SettingsOptionsPanelMetrics.rowHeight
- static let captionRowHeight = SettingsOptionsPanelMetrics.secondaryRowHeight
static let controlSpacing = SettingsOptionsPanelMetrics.controlSpacing
static let pickerWidth: CGFloat = 88
static let cornerRadius = SettingsOptionsPanelMetrics.cornerRadius
diff --git a/CodexBar/Views/Settings/MainPanelOptionsView.swift b/CodexBar/Views/Settings/MainPanelOptionsView.swift
index 7ccd424..80be14e 100644
--- a/CodexBar/Views/Settings/MainPanelOptionsView.swift
+++ b/CodexBar/Views/Settings/MainPanelOptionsView.swift
@@ -12,7 +12,7 @@ struct MainPanelLayoutSettingsRow: View {
.frame(width: SettingsRowMetrics.iconWidth)
.foregroundStyle(.tint)
- Text("settings.main-panel.layout.title")
+ SettingsHelpLabel(title: "settings.main-panel.layout.title", help: "settings.main-panel.layout.title.help")
.font(SettingsRowMetrics.bodyFont)
Spacer()
diff --git a/CodexBar/Views/Settings/NotificationOptionsView.swift b/CodexBar/Views/Settings/NotificationOptionsView.swift
index 409940d..c68729a 100644
--- a/CodexBar/Views/Settings/NotificationOptionsView.swift
+++ b/CodexBar/Views/Settings/NotificationOptionsView.swift
@@ -35,7 +35,7 @@ struct NotificationOptionsView: View {
width: Metrics.panelWidth,
height: Metrics.verticalPadding * 2
+ Metrics.notificationRowHeight * CGFloat(Metrics.notificationRowCount)
- + Metrics.captionedRowHeight * CGFloat(Metrics.captionedRowCount)
+ + Metrics.rowHeight * CGFloat(Metrics.optionRowCount)
+ Metrics.rowSpacing * CGFloat(Metrics.totalRowCount - 1)
)
}
@@ -45,6 +45,7 @@ struct NotificationOptionsView: View {
private var lowQuotaRow: some View {
notificationOptionRow(
title: "settings.notifications.low-quota.title",
+ help: "settings.notifications.low-quota.title.help",
isOn: Binding(
get: { notificationSettings.isLowQuotaEnabled },
set: { notificationSettings.setLowQuotaEnabled($0) }
@@ -69,6 +70,7 @@ struct NotificationOptionsView: View {
private var quotaResetRow: some View {
notificationOptionRow(
title: "settings.notifications.quota-reset.title",
+ help: "settings.notifications.quota-reset.title.help",
isOn: Binding(
get: { notificationSettings.isQuotaResetEnabled },
set: { notificationSettings.setQuotaResetEnabled($0) }
@@ -85,6 +87,7 @@ struct NotificationOptionsView: View {
return notificationOptionRow(
title: "settings.notifications.task-completion.title",
+ help: "settings.notifications.task-completion.title.help",
isOn: Binding(
get: { isDisplayedOn },
set: { notificationSettings.setTaskCompletionEnabled($0) }
@@ -111,6 +114,7 @@ struct NotificationOptionsView: View {
return notificationOptionRow(
title: "settings.notifications.task-waiting.title",
+ help: "settings.notifications.task-waiting.title.help",
isOn: Binding(
get: { isDisplayedOn },
set: { notificationSettings.setTaskWaitingEnabled($0) }
@@ -125,22 +129,20 @@ struct NotificationOptionsView: View {
private var taskHapticRow: some View {
let isDisplayedOn = notificationSettings.isTaskHapticEnabled
- return VStack(spacing: 0) {
- optionRow(
- title: "settings.notifications.task-haptics.title",
- isOn: Binding(
- get: { isDisplayedOn },
- set: { notificationSettings.setTaskHapticEnabled($0) }
- )
+ return optionRow(
+ title: "settings.notifications.task-haptics.title",
+ help: "settings.notifications.task-haptics.title.help",
+ isOn: Binding(
+ get: { isDisplayedOn },
+ set: { notificationSettings.setTaskHapticEnabled($0) }
)
-
- captionRow("settings.notifications.task-haptics.caption")
- }
+ )
}
private var creditExpiryRow: some View {
notificationOptionRow(
title: "settings.notifications.banked-reset-expiry.title",
+ help: "settings.notifications.banked-reset-expiry.title.help",
isOn: Binding(
get: { notificationSettings.isCreditExpiryEnabled },
set: { notificationSettings.setCreditExpiryEnabled($0) }
@@ -159,6 +161,7 @@ struct NotificationOptionsView: View {
return notificationOptionRow(
title: "settings.notifications.auto-reset.title",
+ help: "settings.notifications.auto-reset.title.help",
isOn: Binding(
get: { isDisplayedOn },
set: { notificationSettings.setAutoResetEnabled($0) }
@@ -181,6 +184,7 @@ struct NotificationOptionsView: View {
return notificationOptionRow(
title: "settings.notifications.low-battery.title",
+ help: "settings.notifications.low-battery.title.help",
isOn: Binding(
get: { isDisplayedOn },
set: { notificationSettings.setLowBatteryEnabled($0) }
@@ -201,6 +205,7 @@ struct NotificationOptionsView: View {
return notificationOptionRow(
title: "settings.notifications.keep-alive-limit.title",
+ help: "settings.notifications.keep-alive-limit.title.help",
isOn: Binding(
get: { isDisplayedOn },
set: { notificationSettings.setKeepAliveLimitEnabled($0) }
@@ -214,28 +219,25 @@ struct NotificationOptionsView: View {
}
private var tuiNotificationRow: some View {
- VStack(spacing: 0) {
- optionRow(
- title: "settings.notifications.codex-tui.title",
- isOn: Binding(
- get: { tuiNotificationSettings.isEnabled },
- set: { tuiNotificationSettings.setEnabled($0) }
- ),
- isEnabled: !tuiNotificationSettings.isUpdating
- ) {
- if tuiNotificationSettings.isUpdating {
- ProgressView()
- .controlSize(.mini)
- .frame(width: Metrics.statusIconSize, height: Metrics.statusIconSize)
- } else if let errorMessage = tuiNotificationSettings.errorMessage {
- Image(systemName: "exclamationmark.circle")
- .foregroundStyle(.orange)
- .frame(width: Metrics.statusIconSize, height: Metrics.statusIconSize)
- .help(errorMessage)
- }
+ optionRow(
+ title: "settings.notifications.codex-tui.title",
+ help: "settings.notifications.codex-tui.title.help",
+ isOn: Binding(
+ get: { tuiNotificationSettings.isEnabled },
+ set: { tuiNotificationSettings.setEnabled($0) }
+ ),
+ isEnabled: !tuiNotificationSettings.isUpdating
+ ) {
+ if tuiNotificationSettings.isUpdating {
+ ProgressView()
+ .controlSize(.mini)
+ .frame(width: Metrics.statusIconSize, height: Metrics.statusIconSize)
+ } else if let errorMessage = tuiNotificationSettings.errorMessage {
+ Image(systemName: "exclamationmark.circle")
+ .foregroundStyle(.orange)
+ .frame(width: Metrics.statusIconSize, height: Metrics.statusIconSize)
+ .help(errorMessage)
}
-
- captionRow("settings.notifications.codex-tui.caption")
}
}
@@ -243,22 +245,24 @@ struct NotificationOptionsView: View {
private func optionRow(
title: LocalizedStringResource,
+ help: LocalizedStringResource,
isOn: Binding<Bool>,
isEnabled: Bool = true
) -> some View {
- optionRow(title: title, isOn: isOn, isEnabled: isEnabled) {
+ optionRow(title: title, help: help, isOn: isOn, isEnabled: isEnabled) {
EmptyView()
}
}
private func optionRow(
title: LocalizedStringResource,
+ help: LocalizedStringResource,
isOn: Binding<Bool>,
isEnabled: Bool = true,
@ViewBuilder accessory: () -> some View
) -> some View {
HStack(spacing: 10) {
- Text(title)
+ SettingsHelpLabel(title: title, help: help)
.font(SettingsRowMetrics.captionFont)
.foregroundStyle(.secondary)
@@ -275,25 +279,16 @@ struct NotificationOptionsView: View {
.frame(height: Metrics.rowHeight)
}
- private func captionRow(_ caption: LocalizedStringResource) -> some View {
- HStack(spacing: 0) {
- Text(caption)
- .font(SettingsRowMetrics.captionFont)
- .foregroundStyle(.tertiary)
-
- Spacer(minLength: 0)
- }
- .frame(height: Metrics.secondaryRowHeight)
- }
-
private func notificationOptionRow(
title: LocalizedStringResource,
+ help: LocalizedStringResource,
isOn: Binding<Bool>,
isEnabled: Bool = true,
sound: Binding<NotificationSoundOption>
) -> some View {
notificationOptionRow(
title: title,
+ help: help,
isOn: isOn,
isEnabled: isEnabled,
sound: sound
@@ -304,6 +299,7 @@ struct NotificationOptionsView: View {
private func notificationOptionRow(
title: LocalizedStringResource,
+ help: LocalizedStringResource,
isOn: Binding<Bool>,
isEnabled: Bool = true,
sound: Binding<NotificationSoundOption>,
@@ -314,7 +310,7 @@ struct NotificationOptionsView: View {
return VStack(spacing: 0) {
HStack(spacing: Metrics.notificationControlSpacing) {
- Text(title)
+ SettingsHelpLabel(title: title, help: help)
.font(SettingsRowMetrics.captionFont)
.foregroundStyle(.secondary)
.layoutPriority(1)
@@ -449,14 +445,12 @@ struct NotificationOptionsView: View {
static let horizontalPadding = SettingsOptionsPanelMetrics.horizontalPadding
static let verticalPadding = SettingsOptionsPanelMetrics.verticalPadding
static let notificationRowCount = 8
- static let captionedRowCount = 2
- static let totalRowCount = notificationRowCount + captionedRowCount
+ static let optionRowCount = 2
+ static let totalRowCount = notificationRowCount + optionRowCount
static let rowSpacing = SettingsOptionsPanelMetrics.rowSpacing
static let rowHeight = SettingsOptionsPanelMetrics.rowHeight
- static let secondaryRowHeight = SettingsOptionsPanelMetrics.secondaryRowHeight
- static let soundRowHeight = secondaryRowHeight
+ static let soundRowHeight = SettingsOptionsPanelMetrics.secondaryRowHeight
static let notificationRowHeight = rowHeight + soundRowHeight
- static let captionedRowHeight = rowHeight + secondaryRowHeight
static let notificationControlSpacing = SettingsOptionsPanelMetrics.controlSpacing
static let pickerWidth: CGFloat = 68
static let soundMenuWidth: CGFloat = 160
diff --git a/CodexBar/Views/Settings/SettingsHelpLabel.swift b/CodexBar/Views/Settings/SettingsHelpLabel.swift
new file mode 100644
index 0000000..094fd0a
--- /dev/null
+++ b/CodexBar/Views/Settings/SettingsHelpLabel.swift
@@ -0,0 +1,36 @@
+import SwiftUI
+
+struct SettingsHelpLabel: View {
+ let title: LocalizedStringResource
+ let help: LocalizedStringResource
+ @State private var anchorProvider = ScreenFrameProvider()
+ @State private var helpPresenter = SettingsHelpPresenter()
+
+ var body: some View {
+ HStack(spacing: 4) {
+ Text(title)
+
+ Image(systemName: "questionmark.circle")
+ .font(.system(size: 11))
+ .foregroundStyle(.secondary)
+ .frame(width: 18, height: 18)
+ .contentShape(Rectangle())
+ .fixedSize()
+ .background {
+ ScreenFrameReader(provider: anchorProvider) { frame in
+ helpPresenter.updateAnchorFrame(frame)
+ }
+ }
+ .onHover { isHovered in
+ if isHovered {
+ helpPresenter.show(help, anchorProvider: anchorProvider)
+ } else {
+ helpPresenter.hide()
+ }
+ }
+ }
+ .onDisappear {
+ helpPresenter.hide()
+ }
+ }
+}
diff --git a/CodexBar/Views/Settings/SettingsToggleRow.swift b/CodexBar/Views/Settings/SettingsToggleRow.swift
index 23dfacd..7f546f9 100644
--- a/CodexBar/Views/Settings/SettingsToggleRow.swift
+++ b/CodexBar/Views/Settings/SettingsToggleRow.swift
@@ -49,7 +49,7 @@ enum SettingsOptionsPanelMetrics {
static let verticalPadding: CGFloat = 10
static let rowSpacing: CGFloat = 5
static let rowHeight: CGFloat = 22
- /// 第二行的高度, 通知面板用于音效子行, 防睡眠面板用于固定说明
+ /// 通知面板音效子行的高度
static let secondaryRowHeight: CGFloat = 18
static let controlSpacing: CGFloat = 6
static let cornerRadius: CGFloat = 12
@@ -83,6 +83,7 @@ struct SettingsOptionsPicker<Option: Hashable>: View {
struct SettingsToggleRow<Accessory: View>: View {
let icon: String
let title: LocalizedStringResource
+ let help: LocalizedStringResource
let isOn: Binding<Bool>
let isEnabled: Bool
private let accessory: Accessory
@@ -90,12 +91,14 @@ struct SettingsToggleRow<Accessory: View>: View {
init(
icon: String,
title: LocalizedStringResource,
+ help: LocalizedStringResource,
isOn: Binding<Bool>,
isEnabled: Bool = true,
@ViewBuilder accessory: () -> Accessory
) {
self.icon = icon
self.title = title
+ self.help = help
self.isOn = isOn
self.isEnabled = isEnabled
self.accessory = accessory()
@@ -107,7 +110,7 @@ struct SettingsToggleRow<Accessory: View>: View {
.frame(width: SettingsRowMetrics.iconWidth)
.foregroundStyle(.tint)
- Text(title)
+ SettingsHelpLabel(title: title, help: help)
.font(SettingsRowMetrics.bodyFont)
Spacer()
@@ -127,10 +130,11 @@ extension SettingsToggleRow where Accessory == EmptyView {
init(
icon: String,
title: LocalizedStringResource,
+ help: LocalizedStringResource,
isOn: Binding<Bool>,
isEnabled: Bool = true
) {
- self.init(icon: icon, title: title, isOn: isOn, isEnabled: isEnabled) {
+ self.init(icon: icon, title: title, help: help, isOn: isOn, isEnabled: isEnabled) {
EmptyView()
}
}
diff --git a/CodexBar/Views/Settings/TaskGlowOptionsView.swift b/CodexBar/Views/Settings/TaskGlowOptionsView.swift
index fb12c57..c69851a 100644
--- a/CodexBar/Views/Settings/TaskGlowOptionsView.swift
+++ b/CodexBar/Views/Settings/TaskGlowOptionsView.swift
@@ -6,7 +6,7 @@ struct TaskGlowOptionsView: View {
var body: some View {
VStack(spacing: SettingsOptionsPanelMetrics.rowSpacing) {
ForEach(TaskGlowColorRole.allCases, id: \.self) { role in
- optionRow(role.title) {
+ optionRow(role.title, help: "task-glow.color.help") {
TaskGlowColorHexField(settings: settings, role: role)
}
}
@@ -14,7 +14,7 @@ struct TaskGlowOptionsView: View {
LiquidGlassDivider()
.padding(.vertical, 4)
- optionRow("task-glow.speed.title") {
+ optionRow("task-glow.speed.title", help: "task-glow.speed.title.help") {
SettingsOptionsPicker(
title: "task-glow.speed.title",
selection: Binding(
@@ -27,7 +27,7 @@ struct TaskGlowOptionsView: View {
alignment: .trailing
)
}
- optionRow("task-glow.duration.title") {
+ optionRow("task-glow.duration.title", help: "task-glow.duration.title.help") {
SettingsOptionsPicker(
title: "task-glow.duration.title",
selection: Binding(
@@ -40,7 +40,7 @@ struct TaskGlowOptionsView: View {
alignment: .trailing
)
}
- optionRow("task-glow.brightness.title") {
+ optionRow("task-glow.brightness.title", help: "task-glow.brightness.title.help") {
TaskGlowBrightnessControl(value: Binding(
get: { settings.appearance.brightness },
set: { settings.setBrightness($0) }
@@ -61,9 +61,9 @@ struct TaskGlowOptionsView: View {
CGSize(width: panelWidth, height: 220)
}
- private func optionRow(_ title: LocalizedStringResource, @ViewBuilder content: () -> some View) -> some View {
+ private func optionRow(_ title: LocalizedStringResource, help: LocalizedStringResource, @ViewBuilder content: () -> some View) -> some View {
HStack(spacing: SettingsOptionsPanelMetrics.controlSpacing) {
- Text(title)
+ SettingsHelpLabel(title: title, help: help)
.foregroundStyle(.secondary)
Spacer(minLength: 8)
content()
@@ -193,7 +193,6 @@ private struct TaskGlowColorHexField: View {
.onTapGesture(count: 2) {
settings.previewColor(for: role)
}
- .help("task-glow.color.preview-help")
Text(verbatim: "#")
.font(SettingsRowMetrics.captionFont.monospaced())
diff --git a/Config/Version.xcconfig b/Config/Version.xcconfig
index d67784e..7e408fe 100644
--- a/Config/Version.xcconfig
+++ b/Config/Version.xcconfig
@@ -1,2 +1,2 @@
-MARKETING_VERSION = 5.0.7
-CURRENT_PROJECT_VERSION = 207
+MARKETING_VERSION = 5.0.8
+CURRENT_PROJECT_VERSION = 208
diff --git a/Tests/App/Presentation/SettingsHelpPresenterTests.swift b/Tests/App/Presentation/SettingsHelpPresenterTests.swift
new file mode 100644
index 0000000..8c2d987
--- /dev/null
+++ b/Tests/App/Presentation/SettingsHelpPresenterTests.swift
@@ -0,0 +1,144 @@
+import AppKit
+import Testing
+
+@MainActor
+struct SettingsHelpPresenterTests {
+ @Test func showsAndHidesSynchronouslyWithoutTakingFocus() throws {
+ let window = makeWindow()
+ defer { window.close() }
+ let anchor = makeAnchor(in: window)
+ let presenter = SettingsHelpPresenter()
+ defer { presenter.hide() }
+ let previousKeyWindow = NSApplication.shared.keyWindow
+
+ presenter.show("settings.sync.title.help", anchorProvider: anchor)
+
+ let panel = try #require(window.childWindows?.first as? NSPanel)
+ #expect(panel.isVisible)
+ #expect(!panel.canBecomeKey)
+ #expect(!panel.canBecomeMain)
+ #expect(panel.ignoresMouseEvents)
+ #expect(NSApplication.shared.keyWindow === previousKeyWindow)
+
+ presenter.hide()
+
+ #expect(!panel.isVisible)
+ #expect(panel.parent == nil)
+ #expect(window.childWindows?.isEmpty != false)
+ }
+
+ @Test func repeatedHoverReplacesThePreviousPanel() throws {
+ let window = makeWindow()
+ defer { window.close() }
+ let anchor = makeAnchor(in: window)
+ let presenter = SettingsHelpPresenter()
+ defer { presenter.hide() }
+
+ presenter.show("settings.sync.title.help", anchorProvider: anchor)
+ let previousPanel = try #require(window.childWindows?.first)
+ presenter.show("settings.keep-alive.title.help", anchorProvider: anchor)
+
+ #expect(!previousPanel.isVisible)
+ #expect(previousPanel.parent == nil)
+ #expect(window.childWindows?.count == 1)
+ #expect(window.childWindows?.first?.isVisible == true)
+ }
+
+ @Test(arguments: [
+ NSWindow.willCloseNotification,
+ NSWindow.willMiniaturizeNotification,
+ NSWindow.didResignKeyNotification,
+ NSWindow.willMoveNotification,
+ NSWindow.didResizeNotification,
+ NSApplication.didResignActiveNotification
+ ])
+ func dismissesWithTheSettingsWindow(_ notification: Notification.Name) throws {
+ let window = makeWindow()
+ defer { window.close() }
+ let options = makeWindow()
+ defer {
+ window.removeChildWindow(options)
+ options.close()
+ }
+ window.addChildWindow(options, ordered: .above)
+ let presenter = SettingsHelpPresenter()
+ defer { presenter.hide() }
+ presenter.show("settings.sync.title.help", anchorProvider: makeAnchor(in: options))
+ let panel = try #require(options.childWindows?.first)
+
+ NotificationCenter.default.post(name: notification, object: window)
+
+ #expect(!panel.isVisible)
+ #expect(panel.parent == nil)
+ }
+
+ @Test func doesNotShowForHiddenOrDetachedAnchors() {
+ let window = makeWindow()
+ defer { window.close() }
+ let anchor = makeAnchor(in: window)
+ let presenter = SettingsHelpPresenter()
+ defer { presenter.hide() }
+ window.orderOut(nil)
+
+ presenter.show("settings.sync.title.help", anchorProvider: anchor)
+ #expect(window.childWindows?.isEmpty != false)
+
+ presenter.show("settings.sync.title.help", anchorProvider: ScreenFrameProvider())
+ #expect(window.childWindows?.isEmpty != false)
+ }
+
+ @Test func keepsInitialLayoutReportAndDismissesWhenAnchorMoves() throws {
+ let window = makeWindow()
+ defer { window.close() }
+ let anchor = makeAnchor(in: window)
+ let presenter = SettingsHelpPresenter()
+ defer { presenter.hide() }
+ presenter.show("settings.sync.title.help", anchorProvider: anchor)
+ let panel = try #require(window.childWindows?.first)
+ let frame = try #require(anchor.currentScreenFrame(in: window))
+
+ presenter.updateAnchorFrame(frame)
+ #expect(panel.isVisible)
+
+ presenter.updateAnchorFrame(frame.offsetBy(dx: 0, dy: 20))
+ #expect(!panel.isVisible)
+ #expect(panel.parent == nil)
+ }
+
+ @Test func hidingTheOwnerRemovesTheTooltipBeforeReopening() throws {
+ let window = makeWindow()
+ defer { window.close() }
+ let presenter = SettingsHelpPresenter()
+ defer { presenter.hide() }
+ presenter.show("settings.sync.title.help", anchorProvider: makeAnchor(in: window))
+ let panel = try #require(window.childWindows?.first)
+
+ window.orderOut(nil)
+ NotificationCenter.default.post(name: NSWindow.didChangeOcclusionStateNotification, object: window)
+ window.orderFront(nil)
+
+ #expect(!panel.isVisible)
+ #expect(panel.parent == nil)
+ #expect(window.childWindows?.isEmpty != false)
+ }
+
+ private func makeWindow() -> NSWindow {
+ let window = NSWindow(
+ contentRect: NSRect(x: -10000, y: -10000, width: 470, height: 300),
+ styleMask: [.borderless],
+ backing: .buffered,
+ defer: false
+ )
+ window.isReleasedWhenClosed = false
+ window.orderFront(nil)
+ return window
+ }
+
+ private func makeAnchor(in window: NSWindow) -> ScreenFrameProvider {
+ let view = NSView(frame: NSRect(x: 40, y: 240, width: 18, height: 18))
+ window.contentView?.addSubview(view)
+ let provider = ScreenFrameProvider()
+ provider.bind(to: view)
+ return provider
+ }
+}
diff --git a/appcast.xml b/appcast.xml
index 6a932d0..57973e2 100644
--- a/appcast.xml
+++ b/appcast.xml
@@ -5,6 +5,20 @@
<link>https://codexbar.zabrian.app/appcast.xml</link>
<description>CodexBar appcast feed</description>
<language>zh-CN</language>
+ <item>
+ <title>CodexBar.app 5.0.8</title>
+ <sparkle:version>208</sparkle:version>
+ <sparkle:shortVersionString>5.0.8</sparkle:shortVersionString>
+ <sparkle:minimumSystemVersion>15.0</sparkle:minimumSystemVersion>
+ <sparkle:minimumAutoupdateVersion>200</sparkle:minimumAutoupdateVersion>
+ <sparkle:informationalUpdate><sparkle:belowVersion>200</sparkle:belowVersion></sparkle:informationalUpdate>
+ <link xml:lang="en-US">https://codexbar.zabrian.app/notes?lang=en-US#5.0.0-Guide</link>
+ <link xml:lang="zh-CN">https://codexbar.zabrian.app/notes?lang=zh-CN#5.0.0-Guide</link>
+ <sparkle:releaseNotesLink xml:lang="en-US">https://codexbar.zabrian.app/notes?lang=en-US#5.0.8</sparkle:releaseNotesLink>
+ <sparkle:releaseNotesLink xml:lang="zh-CN">https://codexbar.zabrian.app/notes?lang=zh-CN#5.0.8</sparkle:releaseNotesLink>
+ <pubDate>Tue, 27 Oct 2026 16:21:10 +0800</pubDate>
+ <enclosure url="https://codexbar.zabrian.app/download/CodexBar-v5.0.8.dmg" sparkle:edSignature="Sb+/b4vjzUXm81zgBLs/TuwymIv0lPz5zcbuCpD5zatgm9PYnr8Mj7cMvbC65AAYEZpwo5NCxyPUZ0G751q6BA==" length="10322944" type="application/octet-stream"/>
+ </item>
<item>
<title>CodexBar.app 5.0.7</title>
<sparkle:version>207</sparkle:version>