Skip to content

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

fix: 改善主面板交互并修正性能报告

Bob4d850e9ebf6f
diff --git a/CodexBar/Controllers/MenuSurfaceDismissMonitor.swift b/CodexBar/Controllers/MenuSurfaceDismissMonitor.swift
index 4240d17..53bcabc 100644
--- a/CodexBar/Controllers/MenuSurfaceDismissMonitor.swift
+++ b/CodexBar/Controllers/MenuSurfaceDismissMonitor.swift
@@ -183,7 +183,9 @@ final class MenuSurfaceDismissMonitor {
return
}
- activeMenuSurfaceWindow.bringToFrontActivatingApp()
+ // 原生 popover 借用键盘焦点, 强制激活 App 会触发全屏空间的失活关闭
+ activeMenuSurfaceWindow.orderFrontRegardless()
+ activeMenuSurfaceWindow.makeKey()
}
private func removeEventMonitor(_ monitor: inout Any?) {
diff --git a/CodexBar/Models/GlobalHotKeyShortcut.swift b/CodexBar/Models/GlobalHotKeyShortcut.swift
index 26619fb..89233b1 100644
--- a/CodexBar/Models/GlobalHotKeyShortcut.swift
+++ b/CodexBar/Models/GlobalHotKeyShortcut.swift
@@ -8,9 +8,9 @@ nonisolated struct GlobalHotKeyShortcut: Codable, Equatable {
let keyLabel: String
static let `default` = GlobalHotKeyShortcut(
- keyCode: UInt32(kVK_ANSI_W),
+ keyCode: UInt32(kVK_ANSI_E),
modifiers: UInt32(cmdKey | shiftKey),
- keyLabel: "W"
+ keyLabel: "E"
)
init(keyCode: UInt32, modifiers: UInt32, keyLabel: String) {
diff --git a/CodexBar/Views/Menu/CodexActivityCard.swift b/CodexBar/Views/Menu/CodexActivityCard.swift
index b62503c..9c29256 100644
--- a/CodexBar/Views/Menu/CodexActivityCard.swift
+++ b/CodexBar/Views/Menu/CodexActivityCard.swift
@@ -175,11 +175,13 @@ struct CodexActivityCard: View {
Text(usage.cacheHitRate.map { $0.formatted(.percent.precision(.fractionLength(0 ... 1))) } ?? "—")
.font(.caption2.monospacedDigit().weight(.semibold))
.foregroundStyle(Color.codexLabel)
+ .contentTransition(.numericText(value: usage.cacheHitRate ?? 0))
}
.frame(minWidth: 0, maxWidth: .infinity)
tokenMetric("activity.tokens.reasoning", tokens: usage.reasoningOutputTokens)
}
.lineLimit(1)
+ .animation(.codexStatus, value: usage)
}
private func tokenMetric(_ title: LocalizedStringKey, tokens: Int64) -> some View {
diff --git a/CodexBar/Views/Menu/StatusItemIconView.swift b/CodexBar/Views/Menu/StatusItemIconView.swift
index 36c5907..52bc8e3 100644
--- a/CodexBar/Views/Menu/StatusItemIconView.swift
+++ b/CodexBar/Views/Menu/StatusItemIconView.swift
@@ -82,6 +82,8 @@ struct StatusItemIconView: View {
.opacity(state.showsQuota && state.isStale ? 0.75 : 1)
}
.animation(.easeInOut(duration: 0.2), value: state.showsQuota)
+ // 菜单栏跨桌面切换时使用图标快照, 先合成圆弧和人物以保持绘制一致
+ .drawingGroup()
.frame(width: Self.size.width, height: Self.size.height)
.allowsHitTesting(false)
}
diff --git a/CodexBar/Views/Menu/TokenCountText.swift b/CodexBar/Views/Menu/TokenCountText.swift
index 2569920..bb23b1c 100644
--- a/CodexBar/Views/Menu/TokenCountText.swift
+++ b/CodexBar/Views/Menu/TokenCountText.swift
@@ -31,6 +31,7 @@ struct TokenCountText: View {
}
} else {
Text(parts.text)
+ .contentTransition(.numericText(value: Double(tokens)))
}
}
}
diff --git a/Config/Version.xcconfig b/Config/Version.xcconfig
index 047dc5d..323b485 100644
--- a/Config/Version.xcconfig
+++ b/Config/Version.xcconfig
@@ -1,2 +1,2 @@
-MARKETING_VERSION = 4.0.9
-CURRENT_PROJECT_VERSION = 109
+MARKETING_VERSION = 4.1.0
+CURRENT_PROJECT_VERSION = 110
diff --git a/Docs/DeveloperGuide/ui-and-lifecycle.md b/Docs/DeveloperGuide/ui-and-lifecycle.md
index 50174bd..c5b9720 100644
--- a/Docs/DeveloperGuide/ui-and-lifecycle.md
+++ b/Docs/DeveloperGuide/ui-and-lifecycle.md
@@ -94,6 +94,8 @@ UI 使用 SwiftUI 声明内容,由 AppKit Controller 管理窗口。
SwiftUI 视图持续挂载在原生 `NSStatusBarButton` 中,透明图片用于系统自适应占位。图标使用系统前景色,宿主视图不接受焦点或鼠标命中,左右键仍交给原按钮处理。
+圆弧和人物通过 `drawingGroup()` 合成为一个绘制结果,保持全屏与普通桌面切换时额度圆弧的长度和颜色一致。
+
tooltip 在存在活跃任务时每 60 秒更新,空闲时停止计时。
左键打开主面板。右键或按住 Control 点击打开上下文菜单。
@@ -140,6 +142,7 @@ hidden -> opening -> shown -> closing -> hidden
- Command-Space 短暂抑制 activation dismiss,避免打开 Spotlight 时误关
- 点击后重新固定 `NSVisualEffectView` 为 inactive,避免 AppKit 自动强调背景导致明暗跳变
- 初次安装 observer 后 `Task.yield()` 再补一次窗口获取和聚焦,覆盖 popover window 尚未挂载的时机
+- 菜单窗口聚焦只执行 `orderFrontRegardless()` 和 `makeKey()`,不额外激活 App,避免原生 popover 在其他 App 全屏时因激活切换而关闭;备用面板在自身展示入口处理 App 激活
### 淡入淡出与完成任务
diff --git a/Docs/UserGuide/getting-started.md b/Docs/UserGuide/getting-started.md
index 1478851..af0d655 100644
--- a/Docs/UserGuide/getting-started.md
+++ b/Docs/UserGuide/getting-started.md
@@ -44,7 +44,7 @@ CodexBar 每 60 秒自动刷新一次账户、额度和 Token 用量,双击主
| --- | --- |
| 左键点击菜单栏图标 | 打开或关闭主面板 |
| 右键或 Control 点击菜单栏图标 | 打开设置、日志和退出菜单 |
-| `⌘⇧W` | 使用默认全局快捷键打开或关闭主面板 |
+| `⌘⇧E` | 使用默认全局快捷键打开或关闭主面板 |
| `⌘,` | 打开设置窗口 |
| `⌘L` | 主面板打开时关闭面板并打开日志窗口 |
| 双击账户图标 | 立即刷新账户、额度和用量 |
diff --git a/Docs/UserGuide/settings.md b/Docs/UserGuide/settings.md
index 6bac21d..b9d0c9e 100644
--- a/Docs/UserGuide/settings.md
+++ b/Docs/UserGuide/settings.md
@@ -14,7 +14,7 @@
| 开机自动启动 | 登录 Mac 后启动 CodexBar | 跟随系统登录项状态 |
| 自动检查更新 | 定期检查 CodexBar 更新 | 跟随当前更新设置 |
| 菜单栏额度指示 | 显示所选额度窗口的剩余比例 | 主额度 |
-| 全局快捷键 | 在任意 App 中开关主面板 | `⌘⇧W` |
+| 全局快捷键 | 在任意 App 中开关主面板 | `⌘⇧E` |
### 主面板布局
diff --git a/Docs/en/DeveloperGuide/ui-and-lifecycle.md b/Docs/en/DeveloperGuide/ui-and-lifecycle.md
index 5a33378..eeea320 100644
--- a/Docs/en/DeveloperGuide/ui-and-lifecycle.md
+++ b/Docs/en/DeveloperGuide/ui-and-lifecycle.md
@@ -94,6 +94,8 @@ When no tasks are active, `CodexActivitySnapshot.statusItemActivity(at:)` select
A persistent SwiftUI view lives inside the native `NSStatusBarButton`, with a transparent image preserving automatic spacing. Symbols use the system foreground color. The hosting view rejects focus and hit testing, leaving mouse actions with the original button.
+The arc and person symbol are composited with `drawingGroup()` so the quota arc keeps the same length and color when switching between full-screen and regular desktops.
+
The tooltip updates every 60 seconds while tasks are active and stops its timer when idle.
Left-click opens the main panel. Right-click or Control-click opens the context menu.
@@ -140,6 +142,7 @@ Special rules include:
- Command-Space temporarily suppresses activation dismissal so opening Spotlight does not close the surface accidentally
- After a click, the code pins `NSVisualEffectView` back to inactive so AppKit background emphasis does not cause a brightness jump
- After first installing observers, `Task.yield()` performs a second window acquisition and focus pass in case the popover window was not attached yet
+- Focusing the menu window only calls `orderFrontRegardless()` and `makeKey()`, without activating the app again, so an activation transition does not dismiss the native popover over another app's full-screen window; the fallback panel handles app activation in its own presentation entry point
### Fades and Completion Tasks
diff --git a/Docs/en/UserGuide/getting-started.md b/Docs/en/UserGuide/getting-started.md
index 1d8e505..13568fa 100644
--- a/Docs/en/UserGuide/getting-started.md
+++ b/Docs/en/UserGuide/getting-started.md
@@ -44,7 +44,7 @@ CodexBar refreshes account, rate-limit, and token usage data every 60 seconds. D
| --- | --- |
| Left-click the menu bar icon | Open or close the main panel |
| Right-click or Control-click the menu bar icon | Open the Settings, Logs, and Quit menu |
-| `⌘⇧W` | Open or close the main panel with the default global shortcut |
+| `⌘⇧E` | Open or close the main panel with the default global shortcut |
| `⌘,` | Open the Settings window |
| `⌘L` | Close the main panel and open the Logs window while the panel is open |
| Double-click the account icon | Refresh account, rate-limit, and usage data immediately |
diff --git a/Docs/en/UserGuide/settings.md b/Docs/en/UserGuide/settings.md
index c2fd7fd..8cb7bda 100644
--- a/Docs/en/UserGuide/settings.md
+++ b/Docs/en/UserGuide/settings.md
@@ -14,7 +14,7 @@ Right-click or Control-click the menu bar icon and choose `Settings`, or press `
| Launch at Login | Start CodexBar when you sign in to your Mac | Follows the system login-item state |
| Automatically Check for Updates | Periodically check for CodexBar updates | Follows the current update setting |
| Menu Bar Quota Indicator | Show the remaining allowance in a selected window | Primary quota |
-| Global Shortcut | Toggle the main panel from any app | `⌘⇧W` |
+| Global Shortcut | Toggle the main panel from any app | `⌘⇧E` |
### Main Panel Layout
diff --git a/Images/preview-en.gif b/Images/preview-en.gif
deleted file mode 100644
index a2b5be2..0000000
Binary files a/Images/preview-en.gif and /dev/null differ
diff --git a/Images/preview-zh.gif b/Images/preview.gif
similarity index 60%
rename from Images/preview-zh.gif
rename to Images/preview.gif
index c9d634f..01f1435 100644
Binary files a/Images/preview-zh.gif and b/Images/preview.gif differ
diff --git a/README.en.md b/README.en.md
index 9bb44d3..9ab11bf 100644
--- a/README.en.md
+++ b/README.en.md
@@ -16,7 +16,7 @@
[Features](#features) | [Installation](#installation) | [Quick Start](#quick-start) | [Documentation](#documentation) | [Privacy](#privacy) | [Runtime Architecture](https://codexbar.zabrian.app/architecture) | [Performance Report](https://codexbar.zabrian.app/performance)
-<img src="Images/preview-en.gif" width="640" alt="CodexBar preview">
+<img src="Images/preview.gif" width="640" alt="CodexBar preview">
</div>
@@ -93,7 +93,7 @@ Download the latest version from [GitHub Releases](https://github.com/bob-zebedy
3. Right-click or Control-click the icon to open Settings, Logs, or the Quit menu
4. Enable CodexBar Hook under `Settings > Advanced` to unlock live tasks, task notifications, sleep prevention, and Hook metrics
-The default global shortcut is `⌘⇧W`. You can record a different shortcut or disable it in Settings.
+The default global shortcut is `⌘⇧E`. You can record a different shortcut or disable it in Settings.
## Documentation
diff --git a/README.md b/README.md
index 450fa69..5e937f6 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@
[功能](#功能) | [安装](#安装) | [快速开始](#快速开始) | [使用文档](#使用文档) | [隐私](#隐私) | [运行架构](https://codexbar.zabrian.app/architecture) | [性能报告](https://codexbar.zabrian.app/performance)
-<img src="Images/preview-zh.gif" width="640" alt="CodexBar 预览">
+<img src="Images/preview.gif" width="640" alt="CodexBar 预览">
</div>
@@ -93,7 +93,7 @@ brew install --cask bob-zebedy/tap/codexbar
3. 右键或按住 Control 点击图标打开设置、日志或退出菜单
4. 在 `设置 > 高级` 中启用 CodexBar Hook,解锁实时任务、任务类通知、防睡眠和 Hook 统计
-默认全局快捷键为 `⌘⇧W`,可在设置中重新录制或关闭。
+默认全局快捷键为 `⌘⇧E`,可在设置中重新录制或关闭。
## 使用文档
diff --git a/Scripts/performance/analyze.py b/Scripts/performance/analyze.py
index e0b4ed5..56daf4b 100644
--- a/Scripts/performance/analyze.py
+++ b/Scripts/performance/analyze.py
@@ -204,11 +204,7 @@ def profile_summary(table: Table, pid: int) -> Profile:
if timestamp is not None:
seconds[int(timestamp / 1e9)] += weight
stack = table.resolve(row.get("stack"))
- backtrace = table.resolve(stack.find("backtrace")) if stack is not None else None
- if backtrace is None:
- missing += weight
- continue
- frames = [table.resolve(f) for f in backtrace]
+ frames = [table.resolve(f) for f in stack.findall("frame")] if stack is not None else []
if not frames:
missing += weight
continue
diff --git a/appcast.xml b/appcast.xml
index dfc7ff2..70cddf4 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 4.1.0</title>
+ <sparkle:version>110</sparkle:version>
+ <sparkle:shortVersionString>4.1.0</sparkle:shortVersionString>
+ <sparkle:minimumSystemVersion>15.0</sparkle:minimumSystemVersion>
+ <sparkle:releaseNotesLink>https://codexbar.zabrian.app/notes#4.1.0</sparkle:releaseNotesLink>
+ <pubDate>Wed, 30 Sep 2026 14:16:33 +0800</pubDate>
+ <enclosure url="https://codexbar.zabrian.app/download/CodexBar-v4.1.0.dmg" sparkle:edSignature="o3P7LNUsv/rawY0upp4R2QXLZLN1rKWYM1w6zkIgAf/+jPZ937K0wEKWdPqztZekinzfUXgnCmvFILGKDxEOBw==" length="8689152" type="application/octet-stream"/>
+ </item>
<item>
<title>CodexBar.app 4.0.9</title>
<sparkle:version>109</sparkle:version>