cc-pets 2.4.0 → 2.6.0-beta.0

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.
Files changed (111) hide show
  1. package/CC_BRIDGE.md +93 -14
  2. package/CC_BRIDGE.zh-CN.md +71 -11
  3. package/CHANGELOG.md +55 -0
  4. package/CHANGELOG.zh-CN.md +56 -1
  5. package/CONTRIBUTING.md +1 -1
  6. package/CONTRIBUTING.zh-CN.md +1 -1
  7. package/PROVIDER_PROTOCOL.md +5 -1
  8. package/PROVIDER_PROTOCOL.zh-CN.md +4 -1
  9. package/README.md +116 -34
  10. package/README.zh-CN.md +99 -35
  11. package/Resources/AgentIcons/antigravity.icns +0 -0
  12. package/Resources/zh-Hans.lproj/Localizable.strings +99 -26
  13. package/Sources/CCPets/App/CCPetsAppDelegate+AgentEvents.m +51 -4
  14. package/Sources/CCPets/App/CCPetsAppDelegate+AgentStatus.m +120 -17
  15. package/Sources/CCPets/App/CCPetsAppDelegate+Bridge.m +24 -11
  16. package/Sources/CCPets/App/CCPetsAppDelegate+MenuBar.m +86 -0
  17. package/Sources/CCPets/App/CCPetsAppDelegate+Private.h +24 -1
  18. package/Sources/CCPets/App/CCPetsAppDelegate+Profiles.m +21 -11
  19. package/Sources/CCPets/App/CCPetsAppDelegate+Quota.m +33 -17
  20. package/Sources/CCPets/App/CCPetsAppDelegate+Settings.m +43 -7
  21. package/Sources/CCPets/App/CCPetsAppDelegate+Speech.m +7 -4
  22. package/Sources/CCPets/App/CCPetsAppDelegate+Update.m +7 -4
  23. package/Sources/CCPets/App/CCPetsAppDelegate+Workbench.m +24 -22
  24. package/Sources/CCPets/App/CCPetsAppDelegate.h +10 -0
  25. package/Sources/CCPets/App/CCPetsAppDelegate.m +18 -8
  26. package/Sources/CCPets/App/CCPetsVersion.h +4 -0
  27. package/Sources/CCPets/App/CCPetsVersion.m +34 -0
  28. package/Sources/CCPets/App/main.m +11 -0
  29. package/Sources/CCPets/Bridge/CCPetsBridge.m +41 -17
  30. package/Sources/CCPets/Bridge/CCPetsBridgeAntigravityApp.h +4 -0
  31. package/Sources/CCPets/Bridge/CCPetsBridgeAntigravityApp.m +119 -0
  32. package/Sources/CCPets/Bridge/CCPetsBridgeCLI.h +3 -1
  33. package/Sources/CCPets/Bridge/CCPetsBridgeCLI.m +272 -50
  34. package/Sources/CCPets/Bridge/CCPetsBridgeCore.h +12 -3
  35. package/Sources/CCPets/Bridge/CCPetsBridgeCore.m +341 -95
  36. package/Sources/CCPets/Bridge/CCPetsBridgeSetup.h +0 -2
  37. package/Sources/CCPets/Bridge/CCPetsBridgeSetup.m +227 -95
  38. package/Sources/CCPets/Bridge/CCPetsBridgeStore.h +35 -5
  39. package/Sources/CCPets/Bridge/CCPetsBridgeStore.m +310 -42
  40. package/Sources/CCPets/Bridge/CCPetsBridgeTerminalTitle.h +12 -0
  41. package/Sources/CCPets/Bridge/CCPetsBridgeTerminalTitle.m +105 -0
  42. package/Sources/CCPets/Integrations/CCPetsAntigravityConfig.h +17 -0
  43. package/Sources/CCPets/Integrations/CCPetsAntigravityConfig.m +462 -0
  44. package/Sources/CCPets/Integrations/CCPetsAntigravityEvents.h +5 -0
  45. package/Sources/CCPets/Integrations/CCPetsAntigravityEvents.m +180 -0
  46. package/Sources/CCPets/Integrations/CCPetsBridgeTitleRelay.h +3 -0
  47. package/Sources/CCPets/Integrations/CCPetsBridgeTitleRelay.m +463 -0
  48. package/Sources/CCPets/Integrations/CCPetsEvents.h +5 -0
  49. package/Sources/CCPets/Integrations/CCPetsEvents.m +68 -12
  50. package/Sources/CCPets/Integrations/CCPetsIntegrations.h +1 -1
  51. package/Sources/CCPets/Integrations/CCPetsIntegrations.m +38 -8
  52. package/Sources/CCPets/Integrations/CCPetsLaunchPreflight.m +15 -5
  53. package/Sources/CCPets/Integrations/CCPetsProfiles.h +2 -1
  54. package/Sources/CCPets/Integrations/CCPetsProfiles.m +112 -81
  55. package/Sources/CCPets/Integrations/CCPetsTerminalFocus.h +11 -1
  56. package/Sources/CCPets/Integrations/CCPetsTerminalFocus.m +217 -45
  57. package/Sources/CCPets/Pet/CCPetsPhrasesEditor.m +7 -0
  58. package/Sources/CCPets/Pet/CCPetsPreviews.m +16 -8
  59. package/Sources/CCPets/Pet/PetView+Menu.m +64 -5
  60. package/Sources/CCPets/Pet/PetView.h +7 -0
  61. package/Sources/CCPets/Pet/PetView.m +12 -1
  62. package/Sources/CCPets/Support/CCPetsDoctor.m +126 -37
  63. package/Sources/CCPets/Support/CCPetsPaths.h +5 -0
  64. package/Sources/CCPets/Support/CCPetsPaths.m +15 -0
  65. package/Sources/CCPets/Support/CCPetsPreferences.h +14 -1
  66. package/Sources/CCPets/Support/CCPetsPreferences.m +36 -0
  67. package/Sources/CCPets/UI/CCPetsMenuBarIcon.h +16 -0
  68. package/Sources/CCPets/UI/CCPetsMenuBarIcon.m +70 -0
  69. package/Sources/CCPets/UI/CCPetsMenuBarPanel.h +18 -0
  70. package/Sources/CCPets/UI/CCPetsMenuBarPanel.m +533 -0
  71. package/Sources/CCPets/UI/CCPetsMenuBarSummary.h +51 -0
  72. package/Sources/CCPets/UI/CCPetsMenuBarSummary.m +98 -0
  73. package/Sources/CCPets/UI/CCPetsSettingsPage.h +7 -1
  74. package/Sources/CCPets/UI/CCPetsSettingsPage.m +205 -8
  75. package/Sources/CCPets/UI/CCPetsStatusItem.h +28 -0
  76. package/Sources/CCPets/UI/CCPetsStatusItem.m +147 -0
  77. package/Sources/CCPets/UI/CCPetsUIStyle.m +3 -1
  78. package/Sources/CCPets/UI/CCPetsUsagePage.h +4 -3
  79. package/Sources/CCPets/UI/CCPetsUsagePage.m +69 -43
  80. package/Sources/CCPets/UI/CCPetsUsageStore.m +11 -1
  81. package/Sources/CCPets/UI/CCPetsWorkbenchPages.m +6 -4
  82. package/Sources/CCPets/Usage/CCPetsAntigravityQuota.m +115 -0
  83. package/Sources/CCPets/Usage/CCPetsNormalizedUsage.h +5 -0
  84. package/Sources/CCPets/Usage/CCPetsNormalizedUsage.m +43 -0
  85. package/Sources/CCPets/Usage/CCPetsProviderRegistry+Testing.h +13 -0
  86. package/Sources/CCPets/Usage/CCPetsProviderRegistry.h +25 -0
  87. package/Sources/CCPets/Usage/CCPetsProviderRegistry.m +94 -0
  88. package/Sources/CCPets/Usage/CCPetsQuotaHistory.h +1 -1
  89. package/Sources/CCPets/Usage/CCPetsQuotaHistory.m +11 -8
  90. package/Sources/CCPets/Usage/CCPetsUsage+Internal.h +2 -0
  91. package/Sources/CCPets/Usage/CCPetsUsage+Models.m +206 -14
  92. package/Sources/CCPets/Usage/CCPetsUsage+TokenTotals.m +4 -4
  93. package/Sources/CCPets/Usage/CCPetsUsage.h +7 -2
  94. package/Sources/CCPets/Usage/CCPetsUsageMode.h +2 -0
  95. package/Sources/CCPets/Usage/CCPetsUsageMode.m +29 -4
  96. package/Sources/CCPets/Usage/CCPetsUsageMonitor.h +4 -4
  97. package/Sources/CCPets/Usage/CCPetsUsageMonitor.m +90 -7
  98. package/Sources/CCPets/Usage/QuotaDashboardView+CompactRow.m +81 -0
  99. package/Sources/CCPets/Usage/QuotaDashboardView+Primitives.m +5 -8
  100. package/Sources/CCPets/Usage/QuotaDashboardView+Private.h +26 -4
  101. package/Sources/CCPets/Usage/QuotaDashboardView+Rendering.m +99 -99
  102. package/Sources/CCPets/Usage/QuotaDashboardView.h +9 -10
  103. package/Sources/CCPets/Usage/QuotaDashboardView.m +232 -79
  104. package/THIRD_PARTY_NOTICES.md +5 -4
  105. package/THIRD_PARTY_NOTICES.zh-CN.md +6 -5
  106. package/bin/agy-with-pet +82 -0
  107. package/bin/cc-pets +1 -1
  108. package/bin/claude-with-pet +15 -0
  109. package/bin/codex-with-pet +17 -2
  110. package/package.json +5 -3
  111. package/scripts/install-shell-integration.sh +5 -0
@@ -0,0 +1,81 @@
1
+ #import "QuotaDashboardView+Private.h"
2
+
3
+ @implementation QuotaDashboardView (CompactRow)
4
+ - (void)drawCompactRowForProvider:(NSString *)name usage:(NSDictionary *)normalized rect:(NSRect)rect {
5
+ CGFloat x = NSMinX(rect), mid = NSMidY(rect), right = NSMaxX(rect);
6
+ NSRect row = NSMakeRect(x, mid - 22, NSWidth(rect), 44);
7
+ NSColor *color = [self colorForProvider:name];
8
+ NSBezierPath *background = [NSBezierPath bezierPathWithRoundedRect:row xRadius:10 yRadius:10];
9
+ if (self.usesLiquidGlass) [self fillLiquidScrim:background];
10
+ else [self fillRoundedRect:row radius:10 color:[NSColor colorWithWhite:1 alpha:0.075]];
11
+
12
+ NSRect icon = NSMakeRect(x + 10, mid - 14, 28, 28);
13
+ NSString *displayName = [self displayNameForProvider:name];
14
+ NSImage *logo = self.logoByProvider[name];
15
+ if (logo) {
16
+ [NSGraphicsContext saveGraphicsState];
17
+ [[NSBezierPath bezierPathWithRoundedRect:icon xRadius:7 yRadius:7] addClip];
18
+ [logo drawInRect:icon fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1];
19
+ [NSGraphicsContext restoreGraphicsState];
20
+ } else {
21
+ [self fillRoundedRect:icon radius:7 color:color];
22
+ NSString *initial = displayName.length
23
+ ? [displayName substringWithRange:[displayName rangeOfComposedCharacterSequenceAtIndex:0]] : @"";
24
+ [initial drawInRect:NSInsetRect(icon, 1, 4) withAttributes:
25
+ [self centeredTextAttributesWithSize:15 color:NSColor.whiteColor weight:NSFontWeightBold]];
26
+ }
27
+ [self drawText:displayName inRect:NSMakeRect(x + 48, mid - 10, 116, 20)
28
+ size:15 weight:NSFontWeightSemibold color:self.primaryColor dotColor:nil];
29
+ NSDictionary *state = [self accountStateForProvider:name profile:[self selectedProfileForProvider:name] normalized:normalized];
30
+ NSColor *statusColor = [self statusColorForState:state];
31
+ NSString *status = [state[@"status"] stringByReplacingOccurrencesOfString:@"● " withString:@""];
32
+ if (!self.usesLiquidGlass) {
33
+ CGFloat width = [status sizeWithAttributes:[self textAttributesWithSize:12 color:statusColor
34
+ weight:NSFontWeightMedium]].width + 24;
35
+ [self fillRoundedRect:NSMakeRect(x + 168, mid - 10, width, 20)
36
+ radius:10 color:[statusColor colorWithAlphaComponent:0.13]];
37
+ }
38
+ [statusColor setFill];
39
+ [[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(x + 174, mid - 3, 6, 6)] fill];
40
+ [self drawText:status inRect:NSMakeRect(x + 185, mid - 9, 126, 18)
41
+ size:12 weight:NSFontWeightMedium color:statusColor dotColor:nil];
42
+
43
+ NSDictionary *tokens = normalized[@"tokens"];
44
+ NSString *today = [self formattedTokenCount:[self quota:tokens key:@"today"]];
45
+ [self drawText:[NSString stringWithFormat:L(@"Today %@"), today] inRect:NSMakeRect(x + 316, mid - 9, 134, 18)
46
+ size:13 weight:NSFontWeightMedium color:self.secondaryColor dotColor:nil];
47
+
48
+ NSString *billing = normalized[@"billing"];
49
+ NSRect metric = NSMakeRect(x + 456, mid - 9, right - (x + 456) - 32, 18);
50
+ if ([billing isEqualToString:@"subscription"]) {
51
+ NSDictionary *tightest = nil;
52
+ for (NSDictionary *window in normalized[@"windows"]) {
53
+ NSNumber *used = window[@"used"];
54
+ if (used && (!tightest || used.doubleValue > [tightest[@"used"] doubleValue])) tightest = window;
55
+ }
56
+ if (tightest) {
57
+ double remaining = 100 - [tightest[@"used"] doubleValue];
58
+ [self drawText:L(tightest[@"titleKey"]) inRect:NSMakeRect(NSMinX(metric), mid - 9, 96, 18)
59
+ size:12 weight:NSFontWeightMedium color:self.secondaryColor dotColor:nil];
60
+ NSRect bar = NSMakeRect(NSMinX(metric) + 102, mid - 3, 48, 6);
61
+ [self fillRoundedRect:bar radius:3 color:[color colorWithAlphaComponent:0.2]];
62
+ bar.size.width *= remaining / 100;
63
+ if (bar.size.width > 0) [self fillRoundedRect:bar radius:3 color:color];
64
+ metric.origin.x += 156;
65
+ metric.size.width -= 156;
66
+ [self drawText:[NSString stringWithFormat:@"%.0f%%", remaining] inRect:metric
67
+ size:13 weight:NSFontWeightSemibold color:self.primaryColor dotColor:nil];
68
+ } else {
69
+ [self drawText:@"--" inRect:metric size:13 weight:NSFontWeightMedium color:self.secondaryColor dotColor:nil];
70
+ }
71
+ } else {
72
+ NSString *text = L(@"No quota data");
73
+ NSString *month = [self formattedTokenCount:[self quota:tokens key:@"month"]];
74
+ if ([billing isEqualToString:@"api"]) text = [NSString stringWithFormat:L(@"API · This month %@"), month];
75
+ if ([billing isEqualToString:@"credits"]) text = [NSString stringWithFormat:L(@"Credits · This month %@"), month];
76
+ [self drawText:text inRect:metric size:13 weight:NSFontWeightMedium color:self.primaryColor dotColor:nil];
77
+ }
78
+ [self drawText:@"›" inRect:NSMakeRect(right - 21, mid - 12, 14, 24)
79
+ size:18 weight:NSFontWeightMedium color:self.secondaryColor dotColor:nil];
80
+ }
81
+ @end
@@ -8,10 +8,11 @@
8
8
  // 没有深色底托着时,0.68 的灰在亮壁纸上会发虚。
9
9
  return [NSColor colorWithWhite:self.usesLiquidGlass ? 0.84 : 0.68 alpha:1];
10
10
  }
11
- // 原生玻璃背后只有一层压暗,原来的紫在上面偏暗,提亮到和青色相近的明度。
12
- - (NSColor *)claudeColor {
13
- return self.usesLiquidGlass ? [NSColor colorWithRed:0.80 green:0.66 blue:1.00 alpha:1]
14
- : [NSColor colorWithRed:0.66 green:0.43 blue:0.94 alpha:1];
11
+ - (NSColor *)colorForProvider:(NSString *)name {
12
+ CCPetsProviderDescriptor *provider = CCPetsProviderForName(name);
13
+ NSArray<NSNumber *> *rgb = self.usesLiquidGlass ? provider.glassColorRGB : provider.standardColorRGB;
14
+ if (rgb.count != 3) return self.secondaryColor;
15
+ return [NSColor colorWithRed:rgb[0].doubleValue green:rgb[1].doubleValue blue:rgb[2].doubleValue alpha:1];
15
16
  }
16
17
  - (NSColor *)accentColor { return [NSColor colorWithRed:0.30 green:0.82 blue:0.90 alpha:1]; }
17
18
  // 有 Agent 在线才用绿色,否则整块转灰,避免"暂无 Agent 在线"配一个绿点。
@@ -89,10 +90,6 @@
89
90
  return [self formattedTokenSplit:[self tokenTotals:usage key:key] ?: @{}
90
91
  wantsOutput:wantsOutput];
91
92
  }
92
- - (NSNumber *)usedForQuota:(NSDictionary *)quota usedKey:(NSString *)usedKey {
93
- NSNumber *used = [quota[usedKey] isKindOfClass:NSNumber.class] ? quota[usedKey] : nil;
94
- return used ? @(fmax(0, fmin(100, used.doubleValue))) : nil;
95
- }
96
93
  - (NSString *)refreshAgeText {
97
94
  if (self.lastUpdatedAt <= 0) return L(@"Waiting for data");
98
95
  NSTimeInterval age = fmax(0, NSDate.date.timeIntervalSince1970 - self.lastUpdatedAt);
@@ -2,12 +2,17 @@
2
2
  #import "QuotaDashboardView.h"
3
3
  #import "CCPetsL10n.h"
4
4
  #import "CCPetsUsageMode.h"
5
+ #import "CCPetsNormalizedUsage.h"
5
6
 
6
7
  // 面板高度按"检测到几家 CLI"变化,所以纵向布局不再是一堆绝对坐标,而是自上而下的分段:
7
8
  // 标题区 → 汇总条 → N × 额度卡,块之间统一留 QuotaBlockGap。
8
9
  // QuotaLogicalHeight 保留为两家都装时的高度(590),既是历史默认值,也是预览图尺寸。
9
10
  static const CGFloat QuotaHeaderHeight = 106;
10
11
  static const CGFloat QuotaSummaryHeight = 112;
12
+ static const CGFloat QuotaSummaryRowHeight = 38;
13
+ static const NSUInteger QuotaSummaryRowsPerPage = 2;
14
+ static const NSUInteger QuotaCollapsedCardCount = 2;
15
+ static const CGFloat QuotaCardsDisclosureHeight = 20;
11
16
  static const CGFloat QuotaBaseCardHeight = 152;
12
17
  static const CGFloat QuotaBlockGap = 12;
13
18
  // 原脚注区占用 44px;保留 12px 外边距,其余空间平均分给可见卡片。
@@ -31,6 +36,9 @@ static inline CGFloat QuotaCardHeightForProviderCount(NSUInteger count) {
31
36
  @property(copy) NSString *animatingCarouselProvider;
32
37
  @property NSTimeInterval carouselAnimationStartedAt;
33
38
  @property NSInteger carouselAnimationDirection;
39
+ @property(copy) NSArray<NSString *> *animatingCardOrder;
40
+ @property NSUInteger selectedSummaryPage;
41
+ @property BOOL quotaCardsExpanded;
34
42
  @property(copy) NSString *dragCarouselProvider;
35
43
  @property NSPoint dragCarouselStartPoint;
36
44
  @property BOOL dragCarouselDidSwitch;
@@ -41,10 +49,19 @@ static inline CGFloat QuotaCardHeightForProviderCount(NSUInteger count) {
41
49
  // 主文件里实现、绘图 category 也要用的方法。
42
50
  - (NSArray<NSDictionary *> *)profilesForProvider:(NSString *)name;
43
51
  - (NSDictionary *)summaryUsageForProvider:(NSString *)name;
52
+ - (NSDictionary *)summaryUsageForAntigravityApp;
44
53
  - (NSString *)displayNameForProvider:(NSString *)name;
45
54
  - (NSUInteger)selectedIndexForProvider:(NSString *)name;
55
+ - (NSUInteger)summaryPageCount;
56
+ - (NSUInteger)summaryPageIndex;
57
+ - (NSRect)logicalSummaryPageArrowRectForDirection:(NSInteger)direction;
58
+ - (NSRect)logicalSummaryPageDotRectAtIndex:(NSUInteger)index;
46
59
  - (NSRect)logicalSummaryRect;
47
60
  - (NSRect)logicalSummaryCellRectAtIndex:(NSUInteger)index;
61
+ - (NSArray<NSString *> *)displayedCardProviders;
62
+ - (BOOL)areQuotaCardsExpanded;
63
+ - (NSRect)logicalCardsDisclosureRect;
64
+ - (NSRect)logicalCardRectForProvider:(NSString *)target;
48
65
  - (NSDictionary *)quota:(NSDictionary *)usage key:(NSString *)key;
49
66
  - (NSDictionary *)tokenTotals:(NSDictionary *)usage key:(NSString *)key;
50
67
  - (NSString *)formattedTokenValue:(double)value;
@@ -55,20 +72,21 @@ static inline CGFloat QuotaCardHeightForProviderCount(NSUInteger count) {
55
72
  - (NSString *)formattedTokenSplit:(NSDictionary *)totals wantsOutput:(BOOL)wantsOutput;
56
73
  - (NSString *)resetText:(NSDictionary *)quota showDate:(BOOL)showDate;
57
74
  - (NSString *)recentWeekUsageLabel;
58
- - (NSDictionary *)accountStateForProvider:(NSString *)name profile:(NSDictionary *)profile usage:(NSDictionary *)usage;
75
+ - (NSDictionary *)normalizedUsageForProvider:(NSString *)name profile:(NSDictionary *)profile usage:(NSDictionary *)usage;
76
+ - (NSDictionary *)accountStateForProvider:(NSString *)name profile:(NSDictionary *)profile normalized:(NSDictionary *)normalized;
77
+ - (NSColor *)statusColorForState:(NSDictionary *)state;
59
78
  @end
60
79
 
61
80
  // 绘图基础:配色、文字排版、系统指标、圆角块和用量曲线。
62
81
  @interface QuotaDashboardView (Primitives)
63
82
  - (NSColor *)primaryColor;
64
83
  - (NSColor *)secondaryColor;
65
- - (NSColor *)claudeColor;
66
84
  - (NSColor *)accentColor;
85
+ - (NSColor *)colorForProvider:(NSString *)name;
67
86
  - (NSColor *)agentStatusColor;
68
87
  - (void)drawSystemMetricsEndingAtX:(CGFloat)rightEdge y:(CGFloat)y;
69
88
  - (NSString *)formattedTokenSplitForUsage:(NSDictionary *)usage key:(NSString *)key
70
89
  wantsOutput:(BOOL)wantsOutput;
71
- - (NSNumber *)usedForQuota:(NSDictionary *)quota usedKey:(NSString *)usedKey;
72
90
  - (NSString *)refreshAgeText;
73
91
  - (NSFont *)fontWithSize:(CGFloat)size weight:(NSFontWeight)weight;
74
92
  - (void)drawText:(NSString *)text inRect:(NSRect)rect size:(CGFloat)size
@@ -96,8 +114,12 @@ static inline CGFloat QuotaCardHeightForProviderCount(NSUInteger count) {
96
114
  // 卡片、汇总条和整块面板的绘制。
97
115
  @interface QuotaDashboardView (Rendering)
98
116
  - (void)drawProvider:(NSString *)name displayName:(NSString *)displayName
99
- usage:(NSDictionary *)usage usedKey:(NSString *)usedKey color:(NSColor *)color
117
+ usage:(NSDictionary *)usage color:(NSColor *)color
100
118
  cardRect:(NSRect)card profileCount:(NSUInteger)profileCount selectedIndex:(NSUInteger)selectedIndex;
101
119
  - (void)drawSummaryForProviders:(NSArray<NSString *> *)providers primary:(NSColor *)primary
102
120
  secondary:(NSColor *)secondary accent:(NSColor *)cyan;
103
121
  @end
122
+
123
+ @interface QuotaDashboardView (CompactRow)
124
+ - (void)drawCompactRowForProvider:(NSString *)name usage:(NSDictionary *)normalized rect:(NSRect)rect;
125
+ @end
@@ -2,34 +2,25 @@
2
2
 
3
3
  @implementation QuotaDashboardView (Rendering)
4
4
  - (void)drawProvider:(NSString *)name displayName:(NSString *)displayName
5
- usage:(NSDictionary *)usage usedKey:(NSString *)usedKey color:(NSColor *)color
5
+ usage:(NSDictionary *)usage color:(NSColor *)color
6
6
  cardRect:(NSRect)card profileCount:(NSUInteger)profileCount selectedIndex:(NSUInteger)selectedIndex {
7
7
  NSColor *primary = self.primaryColor;
8
8
  NSColor *secondary = self.secondaryColor;
9
- NSDictionary *five = [self quota:usage key:@"fiveHour"];
10
- NSDictionary *week = [self quota:usage key:@"week"];
11
- NSDictionary *fiveTokens = [self tokenTotals:usage key:@"fiveHour"];
12
- NSDictionary *weekTokens = [self tokenTotals:usage key:@"week"];
13
- NSDictionary *monthTokens = [self tokenTotals:usage key:@"month"];
14
- // 同比两侧都只数到最后一个完整自然日(见 CalendarMonthWindows),因此不能拿含今天的
15
- // monthTokens 去比不含同日的上月——那样每天都会凭空多出小半天的增量。
16
- NSDictionary *monthComparable = [self tokenTotals:usage key:@"monthComparable"];
17
- NSDictionary *previousMonthTokens = [self tokenTotals:usage key:@"previousMonthToDate"];
18
- NSDictionary *tokenUsage = [usage[@"tokenUsage"] isKindOfClass:NSDictionary.class]
19
- ? usage[@"tokenUsage"] : nil;
20
- NSArray<NSDictionary *> *monthDaily = [tokenUsage[@"monthDaily"] isKindOfClass:NSArray.class]
21
- ? tokenUsage[@"monthDaily"] : @[];
22
9
  NSDictionary *profile = [self selectedProfileForProvider:name];
23
- NSDictionary *state = [self accountStateForProvider:name profile:profile usage:usage];
10
+ NSDictionary *normalized = [self normalizedUsageForProvider:name profile:profile usage:usage];
11
+ NSDictionary *state = [self accountStateForProvider:name profile:profile normalized:normalized];
12
+ NSDictionary *tokens = normalized[@"tokens"];
13
+ NSDictionary *monthTokens = [self quota:tokens key:@"month"];
14
+ NSDictionary *monthComparable = [self quota:tokens key:@"monthComparable"];
15
+ NSDictionary *previousMonthTokens = [self quota:tokens key:@"previousMonthToDate"];
16
+ NSArray *monthDaily = [tokens[@"monthDaily"] isKindOfClass:NSArray.class] ? tokens[@"monthDaily"] : @[];
24
17
  BOOL apiMode = [state[@"apiMode"] boolValue];
25
- NSNumber *fiveUsed = [self usedForQuota:five usedKey:usedKey];
26
- NSNumber *weekUsed = [self usedForQuota:week usedKey:usedKey];
27
- // usage_limit_exceeded 只能说明某次请求被额度限制,不能说明耗尽的是 5 小时还是
28
- // 7 天窗口;切到 credits 后请求还能继续成功,但 rate_limits 可能一直为空。因此把它
29
- // 作为独立的“额度受限”状态,不再拿一个无窗口归属的事件覆盖两个官方百分比。
30
- BOOL exhausted = [usage[@"exhaustedAt"] isKindOfClass:NSNumber.class];
31
- BOOL hasData = [state[@"hasData"] boolValue];
32
- BOOL online = [state[@"online"] boolValue];
18
+ BOOL antigravity = [name isEqualToString:@"Antigravity"];
19
+ BOOL exhausted = [normalized[@"exhausted"] boolValue];
20
+ if (apiMode && antigravity && [displayName caseInsensitiveCompare:@"Antigravity CLI"] != NSOrderedSame) {
21
+ displayName = [displayName caseInsensitiveCompare:name] == NSOrderedSame ? @"Antigravity CLI"
22
+ : [NSString stringWithFormat:@"%@ · CLI", displayName];
23
+ }
33
24
 
34
25
  NSBezierPath *cardPath = [NSBezierPath bezierPathWithRoundedRect:card xRadius:18 yRadius:18];
35
26
  // 经典主题的浅色渐变放到玻璃上会变成磨砂;原生玻璃下改垫一层深色衬底托住文字。
@@ -63,7 +54,7 @@
63
54
  card.size.height = QuotaBaseCardHeight;
64
55
 
65
56
  NSRect icon = NSMakeRect(NSMinX(card) + 12, NSMinY(card) + 41, 70, 70);
66
- NSImage *logo = [name isEqualToString:@"Codex"] ? self.codexLogo : self.claudeLogo;
57
+ NSImage *logo = self.logoByProvider[name];
67
58
  if (logo) {
68
59
  [NSGraphicsContext saveGraphicsState];
69
60
  [[NSBezierPath bezierPathWithRoundedRect:icon xRadius:18 yRadius:18] addClip];
@@ -91,8 +82,7 @@
91
82
  // 四态:额度被拒 → 额度受限(百分比仍是上次官方快照);没有任何额度数据 → 等待数据;
92
83
  // 有数据但客户端已退出 → 离线;两者都有 → 在线。
93
84
  NSString *statusText = state[@"status"];
94
- NSColor *statusColor = (!apiMode && exhausted) ? NSColor.systemOrangeColor
95
- : (online && hasData ? NSColor.systemGreenColor : secondary);
85
+ NSColor *statusColor = [self statusColorForState:state];
96
86
  if (self.usesLiquidGlass) {
97
87
  // 原生玻璃下不画彩色底标签,状态色交给字前的圆点;文字里自带的"●"去掉,免得两个点。
98
88
  NSString *plain = [statusText stringByReplacingOccurrencesOfString:@"● " withString:@""];
@@ -226,17 +216,11 @@
226
216
 
227
217
  // 层级:官方剩余额度是订阅限额的权威值,占主位;本机 Token 是参考量,降一级并用
228
218
  // 强调色区分;重置时间最小。反过来会让最抢眼的数字恰好是最不该照着做决定的那个。
229
- NSArray<NSDictionary *> *windows = @[
230
- @{@"x": @(NSMinX(card) + 244), @"title": L(@"5h window"), @"quota": five ?: @{},
231
- @"tokens": fiveTokens ?: @{}, @"used": fiveUsed ?: NSNull.null,
232
- @"showDate": @NO, @"rolling": L(@"Waiting for refresh")},
233
- @{@"x": @(NSMinX(card) + 414), @"title": L(@"7d window"), @"quota": week ?: @{},
234
- @"tokens": weekTokens ?: @{}, @"used": weekUsed ?: NSNull.null,
235
- @"showDate": @YES, @"rolling": L(@"Waiting for refresh")}
236
- ];
237
- for (NSDictionary *window in windows) {
238
- CGFloat x = [window[@"x"] doubleValue];
239
- [window[@"title"] drawInRect:NSMakeRect(x, NSMinY(card) + 114, 130, 20)
219
+ NSArray<NSDictionary *> *windows = normalized[@"windows"];
220
+ for (NSUInteger index = 0; index < MIN(windows.count, 2); index++) {
221
+ NSDictionary *window = windows[index];
222
+ CGFloat x = NSMinX(card) + 244 + 170 * index;
223
+ [L(window[@"titleKey"]) drawInRect:NSMakeRect(x, NSMinY(card) + 114, 130, 20)
240
224
  withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
241
225
  NSNumber *used = [window[@"used"] isKindOfClass:NSNumber.class] ? window[@"used"] : nil;
242
226
  double remaining = used ? 100.0 - used.doubleValue : 0;
@@ -262,14 +246,17 @@
262
246
  NSString *resetValue = [self resetText:window[@"quota"]
263
247
  showDate:[window[@"showDate"] boolValue]];
264
248
  NSString *reset = [resetValue isEqualToString:@"--"]
265
- ? window[@"rolling"] : [NSString stringWithFormat:L(@"Reset %@"), resetValue];
249
+ ? L(@"Waiting for refresh") : [NSString stringWithFormat:L(@"Reset %@"), resetValue];
266
250
  [self drawText:reset inRect:NSMakeRect(x, NSMinY(card) + 46, 160, 18)
267
251
  size:11 weight:NSFontWeightRegular color:secondary dotColor:nil];
268
252
  // 两个主题统一使用紧凑文案;脚注里已说明 Token 即本机统计的已用量。
269
- NSString *tokenText = [NSString stringWithFormat:L(@"Used %@"),
270
- [self formattedTokenCount:window[@"tokens"]]];
271
- [self drawText:tokenText inRect:NSMakeRect(x, NSMinY(card) + 22, 142, 22) size:14
272
- weight:NSFontWeightSemibold color:color dotColor:color];
253
+ // Antigravity 额度是账号窗口,CLI 和 App 的本机 Token 用量分别显示在上方。
254
+ if (!antigravity) {
255
+ NSString *tokenText = [NSString stringWithFormat:L(@"Used %@"),
256
+ [self formattedTokenCount:window[@"tokens"]]];
257
+ [self drawText:tokenText inRect:NSMakeRect(x, NSMinY(card) + 22, 142, 22) size:14
258
+ weight:NSFontWeightSemibold color:color dotColor:color];
259
+ }
273
260
  }
274
261
 
275
262
  CGFloat trendX = NSMinX(card) + 574;
@@ -278,8 +265,15 @@
278
265
  withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
279
266
  NSString *profileID = [self selectedProfileForProvider:name][@"id"];
280
267
  NSArray<NSDictionary *> *history = profileID.length > 0 ? (self.profileHistories[profileID] ?: @[])
281
- : ([name isEqualToString:@"Codex"] ? self.codexHistory : self.claudeHistory);
282
- NSNumber *currentUsed = weekUsed;
268
+ : self.historyByProvider[name];
269
+ NSDictionary *trend = CCPetsTrendWindow(windows);
270
+ if (!trend) {
271
+ [self drawText:@"--" inRect:NSMakeRect(trendX, NSMinY(card) + 74, 130, 34)
272
+ size:25 weight:NSFontWeightBold color:secondary dotColor:nil];
273
+ [NSGraphicsContext restoreGraphicsState];
274
+ return;
275
+ }
276
+ NSNumber *currentUsed = trend[@"used"];
283
277
  NSArray<NSDictionary *> *points = [self curvePointsFromHistory:history currentUsed:currentUsed];
284
278
  // 趋势这一列算的是 7 天窗口(currentUsed 取 weekUsed)。而 exhaustedAt 来自
285
279
  // rateLimitReachedType,没有窗口归属,实际撞墙的通常是 5 小时窗口——拿它一票否决
@@ -289,7 +283,7 @@
289
283
  NSDictionary *pace = weekUnknown
290
284
  ? @{ @"label": L(@"Stale"), @"tip": L(@"Awaiting refresh"),
291
285
  @"color": NSColor.systemOrangeColor }
292
- : [self paceStatusForQuota:week currentUsed:currentUsed color:color];
286
+ : [self paceStatusForWindow:trend color:color];
293
287
  NSColor *paceColor = pace[@"color"];
294
288
  // 档位讲的是 7 天趋势,脚注讲的是此刻为什么发不出请求:受限但 7 天窗口尚有余量时
295
289
  // 两者都要说清,所以脚注单独取色,不跟着档位走。
@@ -337,6 +331,7 @@
337
331
  [scale scaleBy:QuotaScale];
338
332
  [scale concat];
339
333
  NSArray<NSString *> *visibleProviders = [self visibleProviders];
334
+ NSArray<NSString *> *cardProviders = [self displayedCardProviders];
340
335
  const CGFloat height = [self logicalHeight];
341
336
  NSRect logicalBounds = NSMakeRect(0, 0, QuotaLogicalWidth, height);
342
337
  NSRect outer = NSInsetRect(logicalBounds, 1, 1);
@@ -426,22 +421,10 @@
426
421
  [self drawSummaryForProviders:visibleProviders primary:primary secondary:secondary
427
422
  accent:cyan];
428
423
  }
429
- NSDictionary *cardSpecs = @{
430
- @"Codex": @{@"usage": [self usageForProvider:@"Codex"], @"usedKey": @"used_percent",
431
- @"color": cyan},
432
- @"Claude": @{@"usage": [self usageForProvider:@"Claude"], @"usedKey": @"used_percentage",
433
- @"color": self.claudeColor}
434
- };
435
- // 卡片从汇总条下方依次向下排;原脚注空间按可见卡片数平分。这里的分段账必须和
436
- // QuotaLogicalHeightForProviderCount 完全一致,否则面板会多出或少掉一段空白。
437
- CGFloat cardTop = height - QuotaHeaderHeight - QuotaSummaryHeight;
438
- CGFloat cardHeight = QuotaCardHeightForProviderCount(visibleProviders.count);
439
- for (NSString *name in visibleProviders) {
440
- NSDictionary *spec = cardSpecs[name];
441
- cardTop -= QuotaBlockGap;
424
+ // 绘制、tooltip 和轮播点击使用同一个逻辑画框。
425
+ for (NSString *name in cardProviders) {
442
426
  NSArray<NSDictionary *> *profiles = [self profilesForProvider:name];
443
- NSRect cardRect = NSMakeRect(20, cardTop - cardHeight,
444
- QuotaLogicalWidth - 40, cardHeight);
427
+ NSRect cardRect = [self logicalCardRectForProvider:name];
445
428
  BOOL animating = [self.animatingCarouselProvider isEqualToString:name];
446
429
  if (animating) {
447
430
  NSTimeInterval elapsed = NSDate.date.timeIntervalSince1970 - self.carouselAnimationStartedAt;
@@ -455,11 +438,16 @@
455
438
  [transform concat];
456
439
  }
457
440
  [self drawProvider:name displayName:[self displayNameForProvider:name]
458
- usage:spec[@"usage"] usedKey:spec[@"usedKey"] color:spec[@"color"]
441
+ usage:[self usageForProvider:name] color:[self colorForProvider:name]
459
442
  cardRect:cardRect
460
443
  profileCount:profiles.count selectedIndex:[self selectedIndexForProvider:name]];
461
444
  if (animating) [NSGraphicsContext restoreGraphicsState];
462
- cardTop -= cardHeight;
445
+ }
446
+ NSRect disclosure = [self logicalCardsDisclosureRect];
447
+ if (!NSIsEmptyRect(disclosure)) {
448
+ NSString *title = [self areQuotaCardsExpanded] ? L(@"Show less") : L(@"Expand all");
449
+ [title drawInRect:disclosure withAttributes:
450
+ [self centeredTextAttributesWithSize:12 color:secondary weight:NSFontWeightRegular]];
463
451
  }
464
452
  if (visibleProviders.count == 0) {
465
453
  // 官方 Home 自动发现;自定义 Home 必须由用户明确选择,不能扫描接管。
@@ -477,10 +465,7 @@
477
465
  [NSGraphicsContext restoreGraphicsState];
478
466
  }
479
467
 
480
- // 今日与最近 7 天都按 Provider 分开展示。底层本来就是两套独立的自然日统计,
481
- // 不在展示层相加,避免用户无法判断 Token 来自 Codex 还是 Claude。
482
- // 每格内是一张 2×2 表:标题独占一行,每个 Provider 独占一行;输入/输出标签放在
483
- // 对应数值上方。这样既能完整展示 7 天统计起期,也不会挤乱两家的数据行。
468
+ // 今日与最近 7 天按本机 Token 来源分别显示。Antigravity 的两种来源仍共用一张账号额度卡。
484
469
  - (void)drawSummaryForProviders:(NSArray<NSString *> *)providers primary:(NSColor *)primary
485
470
  secondary:(NSColor *)secondary accent:(NSColor *)cyan {
486
471
  NSRect summary = [self logicalSummaryRect];
@@ -500,26 +485,22 @@
500
485
  @{@"icon": @"◉", @"headerSymbol": @"calendar.badge.clock", @"key": @"recentWeek",
501
486
  @"label": [self recentWeekUsageLabel]}
502
487
  ];
503
- BOOL hasMultipleAccounts = [self profilesForProvider:@"Codex"].count > 1 ||
504
- [self profilesForProvider:@"Claude"].count > 1;
505
- NSDictionary *rowSpecs = @{
506
- @"Codex": @{@"usage": [self summaryUsageForProvider:@"Codex"], @"color": cyan},
507
- @"Claude": @{@"usage": [self summaryUsageForProvider:@"Claude"],
508
- @"color": self.claudeColor}
509
- };
510
- // 两行版的槽位是写死的。只装了一家时改用居中的单行槽位,否则汇总条会空出半格,
511
- // 看着像数据没加载出来。
512
- NSArray<NSDictionary *> *slots = providers.count == 1
513
- ? @[@{@"iconY": @24, @"nameY": @33, @"labelY": @49, @"valueY": @28}]
514
- : @[@{@"iconY": @43, @"nameY": @52, @"labelY": @68, @"valueY": @47},
515
- @{@"iconY": @5, @"nameY": @14, @"labelY": @30, @"valueY": @9}];
516
488
  NSMutableArray<NSDictionary *> *rows = [NSMutableArray array];
517
- for (NSUInteger index = 0; index < providers.count && index < slots.count; index++) {
518
- NSMutableDictionary *row = [slots[index] mutableCopy];
519
- [row addEntriesFromDictionary:rowSpecs[providers[index]]];
520
- row[@"name"] = providers[index];
521
- [rows addObject:row];
489
+ for (NSString *provider in providers) {
490
+ BOOL antigravity = [provider isEqualToString:@"Antigravity"];
491
+ NSColor *color = [self colorForProvider:provider];
492
+ [rows addObject:@{@"name": antigravity ? @"Antigravity CLI" : provider,
493
+ @"usage": [self summaryUsageForProvider:provider], @"color": color}];
494
+ if (antigravity) {
495
+ [rows addObject:@{@"name": @"Antigravity App", @"usage": [self summaryUsageForAntigravityApp], @"color": color}];
496
+ }
522
497
  }
498
+ NSUInteger pageCount = [self summaryPageCount];
499
+ NSUInteger pageIndex = [self summaryPageIndex];
500
+ NSUInteger firstRow = MIN(rows.count, pageIndex * QuotaSummaryRowsPerPage);
501
+ NSUInteger rowCount = MIN((NSUInteger)QuotaSummaryRowsPerPage, rows.count - firstRow);
502
+ NSArray<NSDictionary *> *pageRows = [rows subarrayWithRange:NSMakeRange(firstRow, rowCount)];
503
+ CGFloat headerY = NSMinY(summary) + QuotaSummaryHeight - 23;
523
504
 
524
505
  [[NSColor colorWithWhite:1 alpha:0.10] setStroke];
525
506
  for (NSUInteger index = 1; index < cells.count; index++) {
@@ -559,28 +540,24 @@
559
540
  initWithString:@" " attributes:headerAttributes]];
560
541
  [header appendAttributedString:[[NSAttributedString alloc]
561
542
  initWithString:cell[@"label"] attributes:titleAttributes]];
562
- [header drawInRect:NSMakeRect(x + 24, NSMinY(summary) + 89,
543
+ [header drawInRect:NSMakeRect(x + 24, headerY,
563
544
  NSWidth([self logicalSummaryCellRectAtIndex:index]) - 48, 18)];
564
- if (hasMultipleAccounts) {
565
- [L(@"All accounts") drawInRect:NSMakeRect(x + 230, NSMinY(summary) + 89, 120, 18)
566
- withAttributes:[self rightAlignedTextAttributesWithSize:10 color:secondary
567
- weight:NSFontWeightRegular]];
568
- }
569
- for (NSDictionary *row in rows) {
545
+ for (NSUInteger rowIndex = 0; rowIndex < pageRows.count; rowIndex++) {
546
+ NSDictionary *row = pageRows[rowIndex];
570
547
  NSDictionary *usage = row[@"usage"];
571
548
  NSColor *rowColor = row[@"color"];
572
- CGFloat iconY = NSMinY(summary) + [row[@"iconY"] doubleValue];
573
- CGFloat nameY = NSMinY(summary) + [row[@"nameY"] doubleValue];
574
- CGFloat labelY = NSMinY(summary) + [row[@"labelY"] doubleValue];
549
+ CGFloat iconY = NSMinY(summary) + 5 + (pageRows.count - rowIndex - 1) * QuotaSummaryRowHeight;
550
+ if (pageRows.count == 1) iconY += QuotaSummaryRowHeight / 2;
551
+ CGFloat nameY = iconY + 9;
552
+ CGFloat labelY = iconY + 25;
575
553
  if (CCPetsLanguageIsSource()) labelY += 2 / QuotaScale;
576
- CGFloat valueY = NSMinY(summary) + [row[@"valueY"] doubleValue];
554
+ CGFloat valueY = iconY + 4;
577
555
  // 这是图标字形不是文字,原生玻璃下也保留颜色:它负责标出这一行是哪一家。
578
556
  [cell[@"icon"] drawInRect:NSMakeRect(x + 20, iconY, 42, 42)
579
557
  withAttributes:@{NSFontAttributeName: [NSFont systemFontOfSize:30
580
558
  weight:NSFontWeightRegular], NSForegroundColorAttributeName: rowColor}];
581
- [row[@"name"] drawInRect:NSMakeRect(x + 66, nameY, 76, 22)
582
- withAttributes:[self textAttributesWithSize:14 color:rowColor
583
- weight:NSFontWeightMedium]];
559
+ [self drawText:row[@"name"] inRect:NSMakeRect(x + 66, nameY, inputX - (x + 66) - 6, 22)
560
+ size:14 weight:NSFontWeightMedium color:rowColor dotColor:nil];
584
561
  [L(@"Input") drawInRect:NSMakeRect(inputX, labelY, 76, 16)
585
562
  withAttributes:headerAttributes];
586
563
  [L(@"Output") drawInRect:NSMakeRect(outputX, labelY, 76, 16)
@@ -593,6 +570,29 @@
593
570
  drawInRect:NSMakeRect(outputX, valueY, 76, 23) withAttributes:valueAttributes];
594
571
  }
595
572
  }
596
-
573
+ if (pageCount > 1) {
574
+ for (NSInteger direction = -1; direction <= 1; direction += 2) {
575
+ NSRect rect = [self logicalSummaryPageArrowRectForDirection:direction];
576
+ if (NSIsEmptyRect(rect)) continue;
577
+ CGFloat centerX = NSMidX(rect), centerY = NSMidY(rect);
578
+ CGFloat halfWidth = MIN(4, NSWidth(rect) / 4);
579
+ CGFloat halfHeight = MIN(6, NSHeight(rect) / 4);
580
+ NSBezierPath *arrow = [NSBezierPath bezierPath];
581
+ [arrow moveToPoint:NSMakePoint(centerX - direction * halfWidth, centerY + halfHeight)];
582
+ [arrow lineToPoint:NSMakePoint(centerX + direction * halfWidth, centerY)];
583
+ [arrow lineToPoint:NSMakePoint(centerX - direction * halfWidth, centerY - halfHeight)];
584
+ arrow.lineWidth = 2.5;
585
+ arrow.lineCapStyle = NSLineCapStyleRound;
586
+ arrow.lineJoinStyle = NSLineJoinStyleRound;
587
+ [[secondary colorWithAlphaComponent:0.95] setStroke];
588
+ [arrow stroke];
589
+ }
590
+ for (NSUInteger index = 0; index < pageCount; index++) {
591
+ NSRect rect = [self logicalSummaryPageDotRectAtIndex:index];
592
+ if (NSIsEmptyRect(rect)) continue;
593
+ [(index == pageIndex ? cyan : [secondary colorWithAlphaComponent:0.35]) setFill];
594
+ [[NSBezierPath bezierPathWithOvalInRect:rect] fill];
595
+ }
596
+ }
597
597
  }
598
598
  @end
@@ -1,4 +1,5 @@
1
1
  #import <Cocoa/Cocoa.h>
2
+ #import "CCPetsNormalizedUsage.h"
2
3
 
3
4
  // 额度面板按逻辑尺寸绘制后整体缩放,保证离屏渲染和实时显示是同一套代码。
4
5
  extern const CGFloat QuotaLogicalWidth;
@@ -13,13 +14,13 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName);
13
14
  @property BOOL usesLiquidGlass;
14
15
  // 原生玻璃下卡片和汇总区衬底的不透明度,由 App 按压暗档位设置。
15
16
  @property CGFloat cardScrimAlpha;
16
- @property NSDictionary *codexUsage;
17
- @property NSDictionary *claudeUsage;
17
+ @property(copy) NSDictionary<NSString *, NSDictionary *> *usageByProvider;
18
+ @property(copy) NSDictionary<NSString *, NSArray<NSDictionary *> *> *historyByProvider;
19
+ @property(copy) NSDictionary<NSString *, NSImage *> *logoByProvider;
20
+ @property(copy) NSDictionary<NSString *, NSNumber *> *showsAPIUsageByProvider;
18
21
  @property NSArray<NSDictionary *> *profiles;
19
22
  @property NSDictionary<NSString *, NSDictionary *> *profileUsages;
20
23
  @property NSDictionary<NSString *, NSArray<NSDictionary *> *> *profileHistories;
21
- @property NSArray<NSDictionary *> *codexHistory;
22
- @property NSArray<NSDictionary *> *claudeHistory;
23
24
  @property NSInteger activeAgentCount;
24
25
  // 仍在运行的客户端所属的 provider("Codex" / "Claude")。卡片的在线徽章据此判定,
25
26
  // 而不是看有没有额度数据——额度会一直缓存着,拿它当在线信号会恒亮。
@@ -37,7 +38,9 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName);
37
38
  // 按两家都有渲染。
38
39
  @property NSSet<NSString *> *detectedProviders;
39
40
  - (NSArray<NSString *> *)visibleProviders;
41
+ - (NSArray<NSString *> *)orderedQuotaProviderKeys;
40
42
  - (CGFloat)logicalHeight;
43
+ - (void)refreshQuotaCardLayout;
41
44
  @property NSTimeInterval lastUpdatedAt;
42
45
  @property BOOL systemCPUEnabled;
43
46
  @property BOOL systemTemperatureEnabled;
@@ -45,8 +48,6 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName);
45
48
  @property NSNumber *systemCPUPercent;
46
49
  @property NSNumber *systemTemperatureCelsius;
47
50
  @property NSNumber *systemMemoryPercent;
48
- @property BOOL codexShowsAPIUsage;
49
- @property BOOL claudeShowsAPIUsage;
50
51
  - (BOOL)isProviderOnline:(NSString *)name;
51
52
  - (NSDictionary *)selectedProfileForProvider:(NSString *)name;
52
53
  - (NSDictionary *)usageForProvider:(NSString *)name;
@@ -54,9 +55,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName);
54
55
  - (NSDictionary *)accountSnapshotForProvider:(NSString *)name profile:(NSDictionary *)profile;
55
56
  // 本周额度的节奏判断,主窗口概览页的额度卡和面板用同一份。返回 label、tip、color,
56
57
  // 有数据时还有 level(0 充足 / 1 平稳 / 2 需关注 / 3 高风险)。
57
- - (NSDictionary *)paceStatusForQuota:(NSDictionary *)quota currentUsed:(NSNumber *)currentUsed
58
- color:(NSColor *)providerColor;
59
- @property NSImage *codexLogo;
60
- @property NSImage *claudeLogo;
58
+ - (NSDictionary *)paceStatusForWindow:(NSDictionary *)window color:(NSColor *)providerColor;
61
59
  @property(copy) void (^hoverChanged)(BOOL hovering);
60
+ @property(copy) void (^layoutChanged)(void);
62
61
  @end