cc-pets 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CC_BRIDGE.md CHANGED
@@ -212,15 +212,15 @@ Right-click the pet → **CC Bridge**:
212
212
  | Switch | Effect |
213
213
  | --- | --- |
214
214
  | 启用 (Enable) | Same as `cc-pets bridge enable / disable`; takes a few seconds |
215
- | 免审批 (Skip approval): 查看类 view / 发消息 send / 文件预留 reserve / 改会话名 rename | Each group applies to both Codex approval and Claude permissions. With "send" on, agents can message other sessions without asking |
216
215
  | 自动唤醒 (Auto-wake) | Same as `--wake` |
217
216
  | 编辑拦截 (Edit guard) | Same as `--edit-guard` |
218
- | 消息角标 (Message badge) | Pet only: show the message badge on the status icon |
219
- | 新消息通知 (New-message notifications) | Pet only: a system notification when sessions message each other (sender and recipient only, never the body); asks for notification permission the first time |
217
+ | 免审批 (Skip approval) › 查看类 view / 发消息 send / 文件预留 reserve / 改会话名 rename | Each group applies to both Codex approval and Claude permissions. With "send" on, agents can message other sessions without asking |
218
+ | 桌宠提醒 (Pet alerts) › 消息角标 (Message badge) | Pet only: show the message badge on the status icon |
219
+ | 桌宠提醒 (Pet alerts) › 新消息通知 (New-message notifications) | Pet only: a system notification when sessions message each other (sender and recipient only, never the body); asks for notification permission the first time |
220
220
 
221
- The pet's UI is currently in Simplified Chinese. The bottom of the menu shows "N 会话 · M 预留"
222
- (online sessions and active reservations), and each switch has a hover tooltip. Except for the badge and
223
- notification switches, everything is dimmed while CC Bridge is off. The menu finds the command-line
221
+ The pet's UI is currently in Simplified Chinese. "N 会话 · M 预留" (online sessions and active
222
+ reservations) appears under 启用, and each switch has a hover tooltip. While CC Bridge is off the menu
223
+ shows only 启用; reopen the menu after enabling to see the other switches. The menu finds the command-line
224
224
  tool through `~/.cc-pets/bridge-cli.json`, written on every `cc-pets install`; if it's missing, you'll be asked to reinstall.
225
225
 
226
226
  ## Security and privacy
@@ -187,13 +187,13 @@ Claude Code 的 watcher 在会话启动和每轮结束时挂上,每次最多
187
187
  | 开关 | 作用 |
188
188
  | --- | --- |
189
189
  | 启用 | 等同 `cc-pets bridge enable / disable`,执行需要几秒 |
190
- | 免审批:查看类 / 发消息 / 文件预留 / 改会话名 | 每组同时作用于 Codex 免审批与 Claude 免确认。"发消息"开启后,Agent 可以不经确认给其他会话发消息 |
191
190
  | 自动唤醒 | 自动唤醒空闲会话,同 `--wake` |
192
191
  | 编辑拦截 | 编辑前预留拦截,同 `--edit-guard` |
193
- | 消息角标 | 只影响桌宠:是否显示状态图标右下角的消息角标 |
194
- | 新消息通知 | 只影响桌宠:会话之间有消息送达时发系统通知(只含谁发给谁,不含正文),首次开启时申请通知权限 |
192
+ | 免审批 › 查看类 / 发消息 / 文件预留 / 改会话名 | 每组同时作用于 Codex 免审批与 Claude 免确认。"发消息"开启后,Agent 可以不经确认给其他会话发消息 |
193
+ | 桌宠提醒 › 消息角标 | 只影响桌宠:是否显示状态图标右下角的消息角标 |
194
+ | 桌宠提醒 › 新消息通知 | 只影响桌宠:会话之间有消息送达时发系统通知(只含谁发给谁,不含正文),首次开启时申请通知权限 |
195
195
 
196
- 菜单底部显示"N 会话 · M 预留"(在线会话数与有效预留数),各开关悬停可看说明。除角标和通知外,其余开关在 CC Bridge 未开启时置灰。
196
+ "启用"下方显示"N 会话 · M 预留"(在线会话数与有效预留数),各开关悬停可看说明。CC Bridge 未开启时菜单里只有"启用"一项,开启后重新打开菜单即可看到其余开关。
197
197
  菜单开关通过 `~/.cc-pets/bridge-cli.json` 找到命令行程序(每次 `cc-pets install` 时写入);找不到时会提示重新安装。
198
198
 
199
199
  ## 安全与隐私
package/CHANGELOG.md CHANGED
@@ -5,7 +5,39 @@ English | [简体中文](./CHANGELOG.zh-CN.md)
5
5
  This project follows Semantic Versioning. `package.json` is the single source of
6
6
  truth for the version.
7
7
 
8
- ## [Unreleased]
8
+ ## [2.1.1] - 2026-09-30
9
+
10
+ Liquid Glass panel theme, Codex jump-back through the shared background server, and quota fixes.
11
+
12
+ ### Panels and menus
13
+
14
+ - Added a Liquid Glass panel theme on macOS 26 and later, chosen under **Panel theme** in the right-click menu; Classic stays the default and is unchanged. It covers the quota panel, status card, speech bubble and agent session list.
15
+ - The public glass styles turn frosted whenever the app is inactive, and the pet never activates. On macOS 27 an undocumented glass variant keeps the clear, refractive look; `defaults write com.universewang.cc-pets CCPetsDisableExperimentalGlass -bool YES` turns it off and falls back to public Clear glass.
16
+ - **Glass dimming** offers Clear (0%), Light (15%), Standard (25%, default) and Legible (45%); soft shades on the top and bottom edges tone down the bright rim.
17
+ - In Liquid Glass the quota panel uses white text with colored dots instead of colored text and pill badges, a minimum text size, monospaced digits and a light scrim under each card.
18
+ - The agent session list opens as a glass panel with a height limit and scrolling; unlike the system menu it has no arrow-key navigation.
19
+ - Theme and dimming choices apply immediately and keep the menu open, so levels can be compared.
20
+ - Added **About CC Pets** to the right-click menu.
21
+ - Menu switch hints now show even while the pet app is inactive.
22
+ - Removed the **Refresh usage** menu item and the quota panel's refresh button; usage still refreshes on a timer.
23
+ - The CC Bridge submenu is down from 14 rows to 6; while CC Bridge is off it shows only **Enable**.
24
+
25
+ ### Agent status
26
+
27
+ - Fix Codex bubbles jumping to the wrong terminal: Codex 0.159 runs every terminal's sessions in one shared `codex app-server --managed-daemon`, so hooks inherited the environment of whichever terminal started it. `codex-with-pet` now registers each launch, hooks pair new sessions with the launch in the same directory, and when no pairing is certain the bubble does not jump. Codex sessions started before this version need to be restarted once.
28
+
29
+ ### Quota and usage
30
+
31
+ - Fix idle Claude sessions rolling the quota back to an older, higher remaining value: a lower value is accepted only from a newer response, and expired 5-hour windows no longer show their old percentage.
32
+ - Keep the live Codex quota across restarts and app-server gaps, instead of falling back to an hours-old session-log snapshot.
33
+
34
+ ### CLI
35
+
36
+ - Added `cc-pets --help`; unknown flags now fail with exit status 2 instead of launching the pet, and `cc-pets uninstall --purge` takes effect.
37
+
38
+ ## [2.1.0] - 2026-09-24
39
+
40
+ CC Bridge for messaging between Claude Code and Codex sessions.
9
41
 
10
42
  ### CC Bridge (experimental, off by default)
11
43
 
@@ -18,6 +50,10 @@ truth for the version.
18
50
  - Options and pet switches: `cc-pets bridge configure` and `enable` accept `--approve` / `--codex-approve` / `--claude-allow` (skip approval in Codex and Claude by tool group), `--wake`, and `--edit-guard`, keeping anything not given; the pet's right-click menu gains a CC Bridge section (enable, four approval groups, auto-wake, edit guard, message badge, new-message notifications).
19
51
  - Custom session names via `CC_BRIDGE_NAME` at launch, or `set_name` / `cc-pets bridge name` in a session; `list_agents` shows each session's terminal (tty).
20
52
 
53
+ ### Agent status
54
+
55
+ - Fix the status card not jumping back from VS Code family editors: `TERM_PROGRAM=vscode` is shared by VS Code, Cursor, Windsurf and Antigravity, so it no longer decides the application on its own — the captured bundle identifier goes first, and every candidate that is not running is skipped instead of failing the whole jump.
56
+
21
57
  ## [2.0.3] - 2026-09-17
22
58
 
23
59
  Terminal jump-back and session-liveness fixes for agents started outside the wrapper scripts.
@@ -4,7 +4,39 @@
4
4
 
5
5
  本项目遵循语义化版本号。版本号以 `package.json` 为唯一来源。
6
6
 
7
- ## [未发布]
7
+ ## [2.1.1] - 2026-09-30
8
+
9
+ Liquid Glass 面板主题、Codex 共享后台服务下的终端回跳,以及额度修复。
10
+
11
+ ### 面板与菜单
12
+
13
+ - 新增 Liquid Glass 面板主题(macOS 26 及以上),在右键菜单「面板主题」里切换;默认仍是经典主题,经典主题不变。作用于额度面板、状态卡、说话气泡和 Agent 会话列表。
14
+ - 公开的玻璃样式在 App 未激活时会变成磨砂,而桌宠从不激活。macOS 27 上改用一个未公开的玻璃样式,保持清透和折射;执行 `defaults write com.universewang.cc-pets CCPetsDisableExperimentalGlass -bool YES` 可关闭,回退到公开的 Clear 玻璃。
15
+ - 「玻璃压暗」提供通透(0%)、轻度(15%)、标准(25%,默认)、清晰(45%)四档;玻璃上下沿加了柔和暗带,压住过亮的边缘高光。
16
+ - Liquid Glass 下额度面板改为白字加彩色圆点,不再使用彩色字和彩色底标签;小字设了字号下限,数字用等宽字形,卡片下垫一层浅衬底。
17
+ - Agent 会话列表改为玻璃面板,有高度上限,超出可滚动;与系统菜单不同,不支持方向键选择。
18
+ - 主题和压暗档位点击后立即生效,菜单不收起,方便连续对比。
19
+ - 右键菜单新增「关于 CC Pets」。
20
+ - 菜单开关的悬停说明在桌宠未激活时也能显示。
21
+ - 移除右键菜单的「刷新用量」和额度面板的刷新按钮;用量仍定时自动刷新。
22
+ - CC Bridge 子菜单从 14 行精简到 6 行;未启用时只显示「启用」。
23
+
24
+ ### Agent 状态
25
+
26
+ - 修复 Codex 气泡跳错终端:Codex 0.159 把所有终端的会话放进同一个 `codex app-server --managed-daemon` 执行,hook 继承的是最先拉起它的终端的环境。现在 `codex-with-pet` 会登记每次启动,hook 按同一工作目录把新会话配到对应的启动记录;配不准时气泡不跳转。本版本之前启动的 Codex 会话需要重启一次。
27
+
28
+ ### 额度与用量
29
+
30
+ - 修复空闲的 Claude 会话把额度回退到更早、更高的剩余值:只有更新的响应才能把数值调低,已过期的 5 小时窗口不再显示旧百分比。
31
+ - Codex 的实时额度在重启和 app-server 中断期间也能保留,不再回退到几小时前的会话日志快照。
32
+
33
+ ### 命令行
34
+
35
+ - 新增 `cc-pets --help`;未知参数改为以退出码 2 报错,不再启动桌宠;`cc-pets uninstall --purge` 现在生效。
36
+
37
+ ## [2.1.0] - 2026-09-24
38
+
39
+ CC Bridge:Claude Code 与 Codex 会话之间互发消息。
8
40
 
9
41
  ### CC Bridge(实验性,默认关闭)
10
42
 
@@ -17,6 +49,10 @@
17
49
  - 选项与菜单开关:`cc-pets bridge configure` 与 `enable` 支持 `--approve` / `--codex-approve` / `--claude-allow`(按分组放开 Codex 免审批与 Claude 免确认)、`--wake`、`--edit-guard`,未给出的选项保持原值;桌宠右键菜单新增 CC Bridge 开关组(启用、免审批四组、自动唤醒、编辑拦截、消息角标、新消息系统通知)。
18
50
  - 会话名可自定义:启动时用 `CC_BRIDGE_NAME`,或会话内调用 `set_name` / `cc-pets bridge name`;`list_agents` 显示会话所在终端(tty)。
19
51
 
52
+ ### Agent 状态
53
+
54
+ - 修复在 VS Code 家族编辑器里点状态卡片无法回跳:`TERM_PROGRAM=vscode` 是 VS Code、Cursor、Windsurf、Antigravity 共用的标记,不再由它单独决定跳转的应用——捕获到的 bundle ID 优先,候选里没在运行的直接跳过,不再让整次回跳失败。
55
+
20
56
  ## [2.0.3] - 2026-09-17
21
57
 
22
58
  修复未经包装脚本启动的 Agent 的终端回跳与会话存活判定。
package/README.md CHANGED
@@ -131,6 +131,7 @@ cc-pets pet add boba # Install an asset into CC Pets' own directory.
131
131
  cc-pets pet list # List installed assets.
132
132
  cc-pets pet remove boba # Remove an installed asset.
133
133
 
134
+ cc-pets --help # List all commands.
134
135
  cc-pets install # Repair or reinitialize integrations.
135
136
  cc-pets bridge enable # CC Bridge (experimental, off by default); see CC_BRIDGE.md.
136
137
  cc-pets bridge status # Show CC Bridge state and online sessions.
@@ -178,7 +179,16 @@ prompts, command text, file contents, or model output.
178
179
  | Hover on either body side | Directional interaction animation |
179
180
  | Click | Playful response animation |
180
181
  | Drag left or right | Directional drag animation |
181
- | Right-click | Pet, quota, notification, update, and exit menu |
182
+ | Right-click | Pet, notification, update, and exit menu |
183
+
184
+ The **Panel theme** submenu offers **Classic** and **Liquid Glass**. Classic is the
185
+ default. Changes apply immediately to the quota panel, status card, and speech
186
+ bubble, and persist across restarts. Liquid Glass uses native system glass and is
187
+ available on macOS 26 and later only. Building native glass support requires the
188
+ macOS 26 SDK or later. The same submenu has a **Glass dimming** setting for the quota
189
+ panel, status card, and speech bubble: Clear (0%), Light (15%), Standard (25%,
190
+ default), or Legible (45%). Lower levels
191
+ look more transparent; higher levels keep text readable over light backgrounds.
182
192
 
183
193
  The pet switcher scans only built-in assets and `~/.cc-pets/pets/`. It does not
184
194
  scan `~/.petdex/pets/` or `~/.codex/pets/`. To use assets installed by Codex,
package/README.zh-CN.md CHANGED
@@ -20,7 +20,7 @@
20
20
  - 支持待机、左右拖动、身体两侧感应、头部/脚部悬停和点击反馈动画
21
21
  - 待机呼吸、随机小动作(11 行素材会转头看鼠标)、拖动时的水平滞后与落脚回弹
22
22
  - 桌宠以自己的口吻播报 Agent 状态,闲着时还会自己碎碎念,台词和频率都可自定义
23
- - 支持拖动桌宠位置,右键刷新用量、检查更新或退出
23
+ - 支持拖动桌宠位置,右键检查更新或退出;用量定时自动刷新
24
24
  - 响应 Codex 与 Claude Code Agent 的思考、工具调用、审批、子 Agent、完成和失败状态
25
25
  - 在桌宠旁显示脱敏后的玻璃 Agent 状态卡片,可展开、折叠并显示活跃 CLI 会话数
26
26
  - 点击任意 Hook 状态卡,可返回触发该事件的终端;直接启动、没走包装脚本的会话同样可以回跳
@@ -83,7 +83,13 @@ JetBrains IDE、Warp、WezTerm、Ghostty 等在不安装扩展的模式下仅激
83
83
  | 按住并向右拖动 | 播放向右拖行动画,同时移动桌宠 |
84
84
  | 按住并向左拖动 | 播放向左拖行动画,同时移动桌宠 |
85
85
  | 鼠标移开或拖动结束 | 恢复默认待机动画 |
86
- | 右键桌宠 | 切换桌宠、刷新用量、设置历史/通知、检查更新或退出 |
86
+ | 右键桌宠 | 切换桌宠、设置历史/通知、查看关于、检查更新或退出 |
87
+
88
+ 右键菜单「面板主题」提供「经典」和「Liquid Glass」,默认使用经典样式。
89
+ 选择后立即应用于额度面板、状态条和说话气泡,并在重启后保留。Liquid Glass 使用系统原生玻璃,
90
+ 仅在 macOS 26 及以上可选;构建原生玻璃支持需要 macOS 26 或更新的 SDK。同一子菜单里的「玻璃压暗」
91
+ 可在通透(0%)、轻度(15%)、标准(25%,默认)、清晰(45%)之间切换,作用于额度面板、状态卡和
92
+ 说话气泡:档位越低越通透,档位越高在浅色背景上越容易看清。
87
93
 
88
94
  右键菜单中的“切换桌宠”只扫描 `~/.cc-pets/pets/`(见 [素材管理](#素材管理))和包内素材,
89
95
  **不会**去读 `~/.petdex/pets/` 和 `~/.codex/pets/`——那两个目录由 PetDex CLI 和 Codex 写入,
@@ -395,6 +401,9 @@ cc-pets bridge enable
395
401
  cc-pets bridge status
396
402
  cc-pets bridge disable
397
403
 
404
+ # 查看全部命令
405
+ cc-pets --help
406
+
398
407
  # 安全移除 Hooks、恢复 Claude status line,并清理 shell 集成
399
408
  cc-pets uninstall
400
409
 
@@ -4,6 +4,7 @@
4
4
  #import "QuotaDashboardView.h"
5
5
  #import "CCPetsUsageMonitor.h"
6
6
  #import "CCPetsSystemMonitor.h"
7
+ #import "CCPetsGlassView.h"
7
8
 
8
9
  @interface AppDelegate : NSObject <NSApplicationDelegate>
9
10
  @property NSPanel *panel;
@@ -11,7 +12,7 @@
11
12
  // 说话气泡。懒创建:用户不开启说话功能就永远不存在这个窗口。
12
13
  @property NSPanel *speechPanel;
13
14
  @property NSTextField *speechLabel;
14
- @property NSVisualEffectView *speechGlass;
15
+ @property CCPetsGlassView *speechGlass;
15
16
  // 预算制:这一小时说过几句、以及冷却到什么时候。
16
17
  @property NSMutableArray<NSNumber *> *speechTimestamps;
17
18
  @property NSTimeInterval speechCooldownUntil;
@@ -28,7 +29,8 @@
28
29
  @property NSInteger lastQuotaTier;
29
30
  @property BOOL lastQuotaTierInitialized;
30
31
  @property NSPanel *statusPanel;
31
- @property NSVisualEffectView *statusGlass;
32
+ @property CCPetsGlassView *statusGlass;
33
+ @property CCPetsGlassView *quotaGlass;
32
34
  // 卡片要随文案长度伸缩,阴影层得跟着一起改,所以不能再是个局部变量。
33
35
  @property NSView *statusShadowView;
34
36
  @property NSTextField *statusTitleLabel;
@@ -8,6 +8,8 @@
8
8
  #import "CCPetsPhrasesEditor.h"
9
9
  #import "CCPetsUsage.h"
10
10
  #import "CCPetsTerminalFocus.h"
11
+ #import "MenuChoiceRow.h"
12
+ #import "CCPetsGlassMenu.h"
11
13
  #import "CCPetsBridge.h"
12
14
  #import "MenuToggleSwitch.h"
13
15
  #import <UserNotifications/UserNotifications.h>
@@ -303,6 +305,30 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
303
305
  message:[NSString stringWithFormat:@"正在下载并安装 CC Pets %@。完成后桌宠会自动重启。", version]];
304
306
  }
305
307
  }
308
+ // 系统标准关于面板:图标取自 Info.plist,版本号用构建时注入的 CC_PETS_VERSION(与检查更新
309
+ // 同一口径)。桌宠是 LSUIElement,不先激活的话面板会开在其他 App 后面。
310
+ - (void)showAboutPanel:(id)sender {
311
+ NSMutableAttributedString *credits = [[NSMutableAttributedString alloc]
312
+ initWithString:@"Claude Code / Codex CLI 的多功能桌面宠物。\n\n"
313
+ attributes:@{NSFontAttributeName: [NSFont systemFontOfSize:11],
314
+ NSForegroundColorAttributeName: NSColor.secondaryLabelColor}];
315
+ NSString *homepage = @"https://github.com/Sunnyshinnny776/cc-pets";
316
+ [credits appendAttributedString:[[NSAttributedString alloc] initWithString:homepage
317
+ attributes:@{NSFontAttributeName: [NSFont systemFontOfSize:11],
318
+ NSLinkAttributeName: [NSURL URLWithString:homepage]}]];
319
+ NSMutableParagraphStyle *centered = [NSMutableParagraphStyle new];
320
+ centered.alignment = NSTextAlignmentCenter;
321
+ [credits addAttribute:NSParagraphStyleAttributeName value:centered
322
+ range:NSMakeRange(0, credits.length)];
323
+ [NSApp activateIgnoringOtherApps:YES];
324
+ [NSApp orderFrontStandardAboutPanelWithOptions:@{
325
+ NSAboutPanelOptionApplicationName: @"CC Pets",
326
+ NSAboutPanelOptionApplicationVersion: @CC_PETS_VERSION,
327
+ // 空字符串才能去掉版本号后面括号里的 CFBundleVersion(Info.plist 里没有这一项)。
328
+ NSAboutPanelOptionVersion: @"",
329
+ NSAboutPanelOptionCredits: credits
330
+ }];
331
+ }
306
332
  - (void)checkForUpdates:(id)sender {
307
333
  if (self.checkingForUpdate || self.updating) return;
308
334
  self.checkingForUpdate = YES;
@@ -418,6 +444,52 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
418
444
  if (tag == 4) return NotificationStallKey;
419
445
  return nil;
420
446
  }
447
+ // sender 是菜单里的 MenuChoiceRowView,勾选状态由它自己更新。
448
+ - (void)setPanelTheme:(MenuChoiceRowView *)sender {
449
+ NSString *theme = sender.representedObject;
450
+ if (![@[@"classic", @"liquid"] containsObject:theme]) return;
451
+ [NSUserDefaults.standardUserDefaults setObject:theme forKey:CCPetsPanelThemeKey];
452
+ [self.statusGlass applyTheme];
453
+ [self.speechGlass applyTheme];
454
+ [self.quotaGlass applyTheme];
455
+ self.statusShadowView.hidden = self.statusGlass.usesLiquidGlass;
456
+ self.quotaView.usesLiquidGlass = self.quotaGlass.usesLiquidGlass;
457
+ self.quotaView.cardScrimAlpha = CCPetsGlassCardScrimAlpha();
458
+ self.quotaView.needsDisplay = YES;
459
+ [self applyBubbleTextStyle];
460
+ // quotaView 换了父视图,mouseExited 不一定会送达;切主题是在宠物右键菜单里点的,
461
+ // 鼠标此刻不在面板上,直接复位,免得面板一直当作"悬停中"不收起。
462
+ self.dashboardHovering = NO;
463
+ }
464
+ // 状态卡和说话气泡原来是浅色磨砂配深色字;换成原生清透玻璃后背景是任意壁纸加一层
465
+ // 压暗,深色字会看不见,改成白字加贴字形的投影,和额度面板一致。
466
+ - (void)applyBubbleTextStyle {
467
+ NSShadow *shadow = [NSShadow new];
468
+ shadow.shadowColor = [NSColor colorWithWhite:0 alpha:0.45];
469
+ shadow.shadowBlurRadius = 2;
470
+ shadow.shadowOffset = NSMakeSize(0, -0.5);
471
+ BOOL statusLiquid = self.statusGlass.usesLiquidGlass;
472
+ self.statusTitleLabel.textColor = statusLiquid ? [NSColor colorWithWhite:1 alpha:0.78]
473
+ : [NSColor colorWithWhite:0.42 alpha:0.90];
474
+ self.statusDetailLabel.textColor = statusLiquid ? [NSColor colorWithWhite:1 alpha:0.97]
475
+ : [NSColor colorWithWhite:0.12 alpha:0.96];
476
+ self.statusTitleLabel.shadow = statusLiquid ? shadow : nil;
477
+ self.statusDetailLabel.shadow = statusLiquid ? shadow : nil;
478
+ BOOL speechLiquid = self.speechGlass.usesLiquidGlass;
479
+ self.speechLabel.textColor = speechLiquid ? [NSColor colorWithWhite:1 alpha:0.97]
480
+ : [NSColor colorWithWhite:0.10 alpha:0.96];
481
+ self.speechLabel.shadow = speechLiquid ? shadow : nil;
482
+ }
483
+ - (void)setGlassDimLevel:(MenuChoiceRowView *)sender {
484
+ NSNumber *level = sender.representedObject;
485
+ if (![CCPetsGlassDimLevels() containsObject:level]) return;
486
+ [NSUserDefaults.standardUserDefaults setObject:level forKey:CCPetsGlassDimKey];
487
+ [self.quotaGlass applyDimLevel];
488
+ [self.statusGlass applyDimLevel];
489
+ [self.speechGlass applyDimLevel];
490
+ self.quotaView.cardScrimAlpha = CCPetsGlassCardScrimAlpha();
491
+ self.quotaView.needsDisplay = YES;
492
+ }
421
493
  - (void)toggleSpeech:(NSButton *)sender {
422
494
  NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
423
495
  id current = [defaults objectForKey:@"CCPetsSpeechEnabled"];
@@ -659,6 +731,7 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
659
731
  [NSObject cancelPreviousPerformRequestsWithTarget:self
660
732
  selector:@selector(enterIdleStatus) object:nil];
661
733
  [self.statusPanel orderOut:nil];
734
+ [CCPetsGlassMenu dismiss];
662
735
  self.hasAgentStatus = NO;
663
736
  [self refreshApprovalBadge];
664
737
  }
@@ -688,6 +761,7 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
688
761
  [self.statusPanel orderFrontRegardless];
689
762
  } else {
690
763
  [self.statusPanel orderOut:nil];
764
+ [CCPetsGlassMenu dismiss];
691
765
  }
692
766
  }
693
767
  // Stop 之后还会飘来 SubagentStop / PostToolUse / TaskCompleted 这类"仍在工作"的尾巴事件
@@ -727,6 +801,7 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
727
801
  if (self.speechPanel.isVisible) [self hideSpeechBubble];
728
802
  } else {
729
803
  [self.statusPanel orderOut:nil];
804
+ [CCPetsGlassMenu dismiss];
730
805
  }
731
806
  }
732
807
  // "正在启动"只在会话拉起的一瞬间成立。之后如果没有任何后续事件,真实情况是会话已就绪、
@@ -1032,8 +1107,7 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
1032
1107
  self.bridgeSeenAt = NSDate.date.timeIntervalSince1970;
1033
1108
  [self refreshBridgeBadge];
1034
1109
  if (records.count == 0) {
1035
- [menu popUpMenuPositioningItem:nil
1036
- atLocation:NSMakePoint(0, NSHeight(sender.bounds) + 4) inView:sender];
1110
+ [self popUpAgentSessionsMenu:menu from:sender];
1037
1111
  return;
1038
1112
  }
1039
1113
  NSMenuItem *heading = [menu addItemWithTitle:@"最近 Agent 会话" action:nil keyEquivalent:@""];
@@ -1070,6 +1144,15 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
1070
1144
  item.representedObject = record;
1071
1145
  if ([target isEqual:self.lastTerminalFocusTarget]) item.state = NSControlStateValueOn;
1072
1146
  }
1147
+ [self popUpAgentSessionsMenu:menu from:sender];
1148
+ }
1149
+ // Liquid Glass 主题下用玻璃面板展示,和旁边的玻璃状态卡保持一致;经典主题仍是系统菜单。
1150
+ // 玻璃面板不抢焦点,所以不支持方向键选择,Esc 只在本 App 处于前台时有效。
1151
+ - (void)popUpAgentSessionsMenu:(NSMenu *)menu from:(NSButton *)sender {
1152
+ if (self.statusGlass.usesLiquidGlass) {
1153
+ [CCPetsGlassMenu showMenu:menu belowView:self.statusGlass alignRightTo:self.statusGlass];
1154
+ return;
1155
+ }
1073
1156
  [menu popUpMenuPositioningItem:nil
1074
1157
  atLocation:NSMakePoint(0, NSHeight(sender.bounds) + 4) inView:sender];
1075
1158
  }
@@ -1689,8 +1772,8 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
1689
1772
  NSView *statusShadow = [[NSView alloc] initWithFrame:NSMakeRect(
1690
1773
  6, 6, statusGlassSize.width, statusGlassSize.height)];
1691
1774
  self.statusShadowView = statusShadow;
1692
- statusShadow.layer.cornerRadius = statusGlassSize.height / 2.0;
1693
1775
  statusShadow.wantsLayer = YES;
1776
+ statusShadow.layer.cornerRadius = statusGlassSize.height / 2.0;
1694
1777
  statusShadow.layer.backgroundColor = [NSColor colorWithWhite:0 alpha:0.01].CGColor;
1695
1778
  statusShadow.layer.cornerCurve = kCACornerCurveContinuous;
1696
1779
  statusShadow.layer.shadowColor = NSColor.blackColor.CGColor;
@@ -1704,18 +1787,14 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
1704
1787
  CGPathRelease(statusShadowPath);
1705
1788
  [statusRoot addSubview:statusShadow];
1706
1789
 
1707
- self.statusGlass = [[NSVisualEffectView alloc]
1708
- initWithFrame:NSMakeRect(6, 6, statusGlassSize.width, statusGlassSize.height)];
1709
- self.statusGlass.material = NSVisualEffectMaterialPopover;
1710
- self.statusGlass.blendingMode = NSVisualEffectBlendingModeBehindWindow;
1711
- self.statusGlass.state = NSVisualEffectStateActive;
1712
- self.statusGlass.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
1713
- self.statusGlass.wantsLayer = YES;
1714
- self.statusGlass.layer.cornerRadius = statusGlassSize.height / 2.0;
1715
- self.statusGlass.layer.cornerCurve = kCACornerCurveContinuous;
1716
- self.statusGlass.layer.masksToBounds = YES;
1717
- self.statusGlass.layer.borderWidth = 1;
1718
- self.statusGlass.layer.borderColor = [NSColor colorWithWhite:1 alpha:0.48].CGColor;
1790
+ self.statusGlass = [[CCPetsGlassView alloc]
1791
+ initWithFrame:NSMakeRect(6, 6, statusGlassSize.width, statusGlassSize.height)
1792
+ material:NSVisualEffectMaterialPopover appearance:NSAppearanceNameAqua
1793
+ cornerRadius:statusGlassSize.height / 2.0];
1794
+ // 胶囊比面板矮,边缘高光占比更大;10pt / 0.6 是对照截图里深色背景下刚好压住的值。
1795
+ self.statusGlass.edgeShadeHeight = 10;
1796
+ self.statusGlass.edgeShadeAlpha = 0.6;
1797
+ self.statusGlass.usesWidgetGlass = YES;
1719
1798
 
1720
1799
  self.statusTitleLabel = [NSTextField labelWithString:@""];
1721
1800
  // 层级是反的:宠物是主角,事实退成眉标。
@@ -1724,14 +1803,14 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
1724
1803
  self.statusTitleLabel.font = [NSFont systemFontOfSize:11 weight:NSFontWeightMedium];
1725
1804
  self.statusTitleLabel.textColor = [NSColor colorWithWhite:0.42 alpha:0.90];
1726
1805
  self.statusTitleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
1727
- [self.statusGlass addSubview:self.statusTitleLabel];
1806
+ [self.statusGlass.contentView addSubview:self.statusTitleLabel];
1728
1807
 
1729
1808
  self.statusDetailLabel = [NSTextField labelWithString:@""];
1730
1809
  self.statusDetailLabel.frame = NSMakeRect(20, 10, statusGlassSize.width - 80, 22);
1731
1810
  self.statusDetailLabel.font = [NSFont systemFontOfSize:14 weight:NSFontWeightMedium];
1732
1811
  self.statusDetailLabel.textColor = [NSColor colorWithWhite:0.12 alpha:0.96];
1733
1812
  self.statusDetailLabel.lineBreakMode = NSLineBreakByTruncatingTail;
1734
- [self.statusGlass addSubview:self.statusDetailLabel];
1813
+ [self.statusGlass.contentView addSubview:self.statusDetailLabel];
1735
1814
 
1736
1815
  self.statusIconButton = [[CCPetsStatusClickButton alloc] initWithFrame:NSMakeRect(
1737
1816
  statusGlassSize.width - 48, 12, 34, 34)];
@@ -1743,8 +1822,11 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
1743
1822
  self.statusIconButton.toolTip = @"查看最近 Agent 会话与 CC Bridge 消息";
1744
1823
  self.statusIconButton.target = self;
1745
1824
  self.statusIconButton.action = @selector(showAgentSessionsMenu:);
1746
- [self.statusGlass addSubview:self.statusIconButton];
1825
+ [self.statusGlass.contentView addSubview:self.statusIconButton];
1826
+ // 原生玻璃自带阴影,再叠手工阴影会糊成两层。
1827
+ self.statusShadowView.hidden = self.statusGlass.usesLiquidGlass;
1747
1828
  [statusRoot addSubview:self.statusGlass];
1829
+ [self applyBubbleTextStyle];
1748
1830
  CCPetsStatusClickButton *statusClick = [[CCPetsStatusClickButton alloc]
1749
1831
  initWithFrame:NSMakeRect(6, 6, statusGlassSize.width - 56, statusGlassSize.height)];
1750
1832
  statusClick.bordered = NO;
@@ -1756,7 +1838,7 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
1756
1838
  statusClick.action = @selector(focusLatestAgentTerminal:);
1757
1839
  self.statusClickButton = statusClick;
1758
1840
  [statusRoot addSubview:statusClick];
1759
- // 角标挂在 statusRoot 而不是 statusGlass 里:玻璃卡片是 masksToBounds 的胶囊,
1841
+ // 角标挂在 statusRoot 而不是玻璃内容里:玻璃卡片会按胶囊形状裁切,
1760
1842
  // 右上角正好落在圆角外面,放进去会被裁掉一半。
1761
1843
  CCPetsApprovalBadgeView *badge = [[CCPetsApprovalBadgeView alloc]
1762
1844
  initWithFrame:NSMakeRect(0, 0, PetApprovalBadgeSize, PetApprovalBadgeSize)];
@@ -1787,17 +1869,15 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
1787
1869
  self.quotaPanel.collectionBehavior = NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary;
1788
1870
  self.quotaPanel.hidesOnDeactivate = NO;
1789
1871
  NSView *quotaRoot = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, quotaSize.width, quotaSize.height)];
1790
- NSVisualEffectView *glass = [[NSVisualEffectView alloc] initWithFrame:NSMakeRect(0, 0,
1791
- quotaSize.width, quotaSize.height)];
1792
- glass.material = NSVisualEffectMaterialUnderWindowBackground;
1793
- glass.blendingMode = NSVisualEffectBlendingModeBehindWindow;
1794
- glass.state = NSVisualEffectStateActive;
1795
- glass.appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
1796
- glass.wantsLayer = YES;
1797
- glass.layer.cornerRadius = 13;
1798
- glass.layer.masksToBounds = YES;
1799
- [quotaRoot addSubview:glass];
1872
+ self.quotaGlass = [[CCPetsGlassView alloc] initWithFrame:quotaRoot.bounds
1873
+ material:NSVisualEffectMaterialUnderWindowBackground
1874
+ appearance:NSAppearanceNameDarkAqua cornerRadius:13];
1875
+ self.quotaGlass.usesWidgetGlass = YES;
1876
+ [quotaRoot addSubview:self.quotaGlass];
1800
1877
  self.quotaView = [[QuotaDashboardView alloc] initWithFrame:NSMakeRect(0, 0, quotaSize.width, quotaSize.height)];
1878
+ self.quotaView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
1879
+ self.quotaView.usesLiquidGlass = self.quotaGlass.usesLiquidGlass;
1880
+ self.quotaView.cardScrimAlpha = CCPetsGlassCardScrimAlpha();
1801
1881
  [self applySystemMetricPreferences];
1802
1882
  [self applyUsageDisplayModePreferences];
1803
1883
  self.quotaView.codexLogo = OfficialAppIcon(@"com.openai.codex", @"icon-chatgpt.icns");
@@ -1806,10 +1886,7 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
1806
1886
  weakSelf.dashboardHovering = hovering;
1807
1887
  if (!hovering) [weakSelf scheduleQuotaDashboardHide];
1808
1888
  };
1809
- self.quotaView.refreshRequested = ^{
1810
- [weakSelf refreshUsage:nil];
1811
- };
1812
- [quotaRoot addSubview:self.quotaView];
1889
+ [self.quotaGlass.contentView addSubview:self.quotaView];
1813
1890
  self.quotaPanel.contentView = quotaRoot;
1814
1891
  // 先探测再第一次显示:否则面板会先按两张卡的高度弹出来再收缩一下。
1815
1892
  [self refreshDetectedProviders];
@@ -2147,20 +2224,13 @@ static const CGFloat PetStatusSingleLineHeight = 40.0;
2147
2224
  self.speechPanel.ignoresMouseEvents = YES;
2148
2225
 
2149
2226
  NSView *root = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, size.width, size.height)];
2150
- self.speechGlass = [[NSVisualEffectView alloc]
2151
- initWithFrame:NSMakeRect(6, 6, glassSize.width, glassSize.height)];
2152
- self.speechGlass.material = NSVisualEffectMaterialPopover;
2153
- self.speechGlass.blendingMode = NSVisualEffectBlendingModeBehindWindow;
2154
- self.speechGlass.state = NSVisualEffectStateActive;
2155
- self.speechGlass.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
2156
- self.speechGlass.wantsLayer = YES;
2157
- // 圆角交给 layer 自己:cornerRadius 是 GPU 端矢量裁切,配 continuous 曲率就是
2158
- // macOS 那个 squircle。位图 maskImage 换不来这个质感。
2159
- self.speechGlass.layer.cornerRadius = glassSize.height / 2.0;
2160
- self.speechGlass.layer.cornerCurve = kCACornerCurveContinuous;
2161
- self.speechGlass.layer.masksToBounds = YES;
2162
- self.speechGlass.layer.borderWidth = 1;
2163
- self.speechGlass.layer.borderColor = [NSColor colorWithWhite:1 alpha:0.48].CGColor;
2227
+ self.speechGlass = [[CCPetsGlassView alloc]
2228
+ initWithFrame:NSMakeRect(6, 6, glassSize.width, glassSize.height)
2229
+ material:NSVisualEffectMaterialPopover appearance:NSAppearanceNameAqua
2230
+ cornerRadius:glassSize.height / 2.0];
2231
+ self.speechGlass.edgeShadeHeight = 9;
2232
+ self.speechGlass.edgeShadeAlpha = 0.6;
2233
+ self.speechGlass.usesWidgetGlass = YES;
2164
2234
 
2165
2235
  self.speechLabel = [NSTextField labelWithString:@""];
2166
2236
  self.speechLabel.frame = NSMakeRect(14, 10, glassSize.width - 28, 18);
@@ -2169,8 +2239,9 @@ static const CGFloat PetStatusSingleLineHeight = 40.0;
2169
2239
  self.speechLabel.textColor = [NSColor colorWithWhite:0.10 alpha:0.96];
2170
2240
  self.speechLabel.alignment = NSTextAlignmentCenter;
2171
2241
  self.speechLabel.lineBreakMode = NSLineBreakByTruncatingTail;
2172
- [self.speechGlass addSubview:self.speechLabel];
2242
+ [self.speechGlass.contentView addSubview:self.speechLabel];
2173
2243
  [root addSubview:self.speechGlass];
2244
+ [self applyBubbleTextStyle];
2174
2245
  self.speechPanel.contentView = root;
2175
2246
  }
2176
2247
  // 独立气泡只在没有状态卡时出现(有状态卡时话并进它的副行),所以固定放宠物头顶即可,
@@ -2377,7 +2448,9 @@ static CGFloat PetMeasuredLabelWidth(NSTextField *label) {
2377
2448
  [self.statusPanel setContentSize:panelSize];
2378
2449
  self.statusPanel.contentView.frame = NSMakeRect(0, 0, panelSize.width, panelSize.height);
2379
2450
  self.statusGlass.frame = NSMakeRect(6, 6, glassWidth, height);
2451
+ self.statusGlass.cornerRadius = height / 2.0;
2380
2452
  self.statusShadowView.frame = NSMakeRect(6, 6, glassWidth, height);
2453
+ self.statusShadowView.layer.cornerRadius = height / 2.0;
2381
2454
  // shadowPath 是按旧尺寸算死的,卡片变宽后不重算,阴影会留在原来的形状上。
2382
2455
  CGPathRef path = CGPathCreateWithRoundedRect(self.statusShadowView.bounds,
2383
2456
  height / 2.0, height / 2.0, NULL);
@@ -2406,7 +2479,7 @@ static CGFloat PetMeasuredLabelWidth(NSTextField *label) {
2406
2479
  [self.speechPanel setContentSize:panelSize];
2407
2480
  self.speechPanel.contentView.frame = NSMakeRect(0, 0, panelSize.width, panelSize.height);
2408
2481
  self.speechGlass.frame = NSMakeRect(6, 6, width, PetSpeechBodyHeight);
2409
- self.speechGlass.layer.cornerRadius = PetSpeechBodyHeight / 2.0;
2482
+ self.speechGlass.cornerRadius = PetSpeechBodyHeight / 2.0;
2410
2483
  self.speechLabel.frame = NSMakeRect(padding, 10, width - padding * 2, 18);
2411
2484
  }
2412
2485
 
@@ -2713,8 +2786,7 @@ static BOOL ClientProcessAlive(pid_t pid, NSString *recordedTTY) {
2713
2786
  // Codex/Claude 客户端,也不应被转成 CLI 托管模式并随客户端退出。
2714
2787
  if (liveClients == 0 && self.managedByCLI) [NSApp terminate:nil];
2715
2788
  }
2716
- // 面板高度取决于渲染几张额度卡。quotaRoot / 毛玻璃 / quotaView 三层都是固定 frame、
2717
- // 没有 autoresizingMask,所以统一在这里按 contentView 的 subviews 铺一遍,避免漏掉一层。
2789
+ // 面板高度取决于渲染几张额度卡。调整玻璃容器后,内部内容随 autoresizingMask 铺满。
2718
2790
  - (void)resizeQuotaDashboard {
2719
2791
  NSSize size = NSMakeSize(QuotaLogicalWidth * QuotaScale,
2720
2792
  QuotaLogicalHeightForProviderCount([self.quotaView visibleProviders].count) * QuotaScale);
@@ -126,6 +126,8 @@ void PruneStaleRuntimeState(void) {
126
126
  NSTimeInterval cutoff = NSDate.date.timeIntervalSince1970 - RuntimeStateTTL;
127
127
  RemoveExpiredFile(AgentEventPath(), cutoff);
128
128
  RemoveExpiredFile(ClaudeUsagePath(), cutoff);
129
+ RemoveExpiredFile(CodexLiveUsagePath(), cutoff);
130
+ RemoveExpiredFile(CodexLaunchRegistryPath(), cutoff);
129
131
  RemoveDeadClientRecords();
130
132
  }
131
133
 
@@ -148,7 +150,7 @@ int CleanCCPetsData(BOOL purge) {
148
150
  }
149
151
  NSUInteger removed = 0;
150
152
  if (RemoveClaudeUsageIfUnlocked()) removed += 1;
151
- for (NSString *path in @[AgentEventPath(), RuntimeLockPath(),
153
+ for (NSString *path in @[AgentEventPath(), CodexLiveUsagePath(), CodexLaunchRegistryPath(), RuntimeLockPath(),
152
154
  ClientStateDirectory(), buildCache ?: @""]) {
153
155
  if (RemoveIfPresent(path)) removed += 1;
154
156
  }
@@ -9,5 +9,6 @@
9
9
  @end
10
10
 
11
11
  // 把实时额度覆盖到会话读取器产出的用量上;本机 Token 聚合等非官方字段会被保留。
12
+ // 会话快照的 sampledAt 更晚时原样返回会话快照。
12
13
  NSDictionary *CodexUsageByApplyingLiveUsage(NSDictionary *sessionUsage,
13
14
  NSDictionary *liveUsage);
@@ -367,6 +367,13 @@ static NSDictionary<NSString *, NSString *> *CodexAppServerEnvironment(NSString
367
367
  NSDictionary *CodexUsageByApplyingLiveUsage(NSDictionary *sessionUsage,
368
368
  NSDictionary *liveUsage) {
369
369
  if (![liveUsage isKindOfClass:NSDictionary.class]) return sessionUsage;
370
+ // 两边都是同一账号的快照,谁采样得晚用谁。实时值不再到期就丢:它丢了以后退回的会话快照
371
+ // 往往更旧(在 Codex App、其他设备上用掉的额度不会写进本机会话日志),面板会先跳回
372
+ // 旧值、等下一次实时查询再跳回来。本机会话拿到更新的响应时自然会胜出。
373
+ if ([sessionUsage isKindOfClass:NSDictionary.class] &&
374
+ [sessionUsage[@"sampledAt"] doubleValue] > [liveUsage[@"sampledAt"] doubleValue]) {
375
+ return sessionUsage;
376
+ }
370
377
  NSMutableDictionary *merged = [sessionUsage isKindOfClass:NSDictionary.class]
371
378
  ? [sessionUsage mutableCopy] : [NSMutableDictionary dictionary];
372
379
  for (NSString *key in @[@"fiveHour", @"week"]) {
@@ -197,7 +197,7 @@ int RecordHookEvent(void) {
197
197
  @"timestamp": @([NSDate.date timeIntervalSince1970])
198
198
  } mutableCopy];
199
199
  if (session.length > 0) record[@"session"] = session;
200
- NSDictionary *terminal = TerminalFocusTargetFromEnvironment();
200
+ NSDictionary *terminal = TerminalFocusTargetForHook(payload, provider);
201
201
  if (terminal.count > 0) record[@"terminal"] = terminal;
202
202
  AppendAgentEventRecord(record);
203
203
  return EXIT_SUCCESS;
@@ -0,0 +1,10 @@
1
+ #import <Cocoa/Cocoa.h>
2
+
3
+ // 用原生玻璃面板展示一个已经构建好的 NSMenu。系统菜单的材质不能换,Liquid Glass 主题下
4
+ // 消息列表会和旁边的玻璃状态卡风格割裂;这里只读菜单项的标题、启用、勾选、分隔线和
5
+ // target/action,调用方的菜单构建代码不用改。只支持平铺菜单(没有子菜单、自定义视图)。
6
+ @interface CCPetsGlassMenu : NSObject
7
+ // anchor 是玻璃状态卡;面板贴在它下方、右边与 alignView 右边对齐,屏幕下方放不下时放到上方。
8
+ + (void)showMenu:(NSMenu *)menu belowView:(NSView *)anchor alignRightTo:(NSView *)alignView;
9
+ + (void)dismiss;
10
+ @end