Skip to content

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io

fix(tray): show Antigravity's weekly limits as their own rows

Jasonc646dc12ddf5
diff --git a/src-tauri/src/tray.rs b/src-tauri/src/tray.rs
index 9376e3777..9758e4e21 100644
--- a/src-tauri/src/tray.rs
+++ b/src-tauri/src/tray.rs
@@ -128,6 +128,13 @@ pub struct TrayTexts {
pub tier_gemini_flash: &'static str,
pub tier_gemini_flash_lite: &'static str,
pub tier_premium: &'static str,
+ /// Antigravity 各档(模型名不翻译,窗口照主界面 `subscription.agy*`);Claude/GPT 共用的那组
+ /// 照主界面短档名 `subscription.short.agyThirdParty*` 只写 Claude,长了面板一行放不下重置时间
+ pub tier_agy_gemini_five_hour: &'static str,
+ pub tier_agy_gemini_weekly: &'static str,
+ pub tier_agy_third_party_five_hour: &'static str,
+ pub tier_agy_third_party_weekly: &'static str,
+ pub tier_agy_argon_weekly: &'static str,
pub tier_left: &'static str,
pub tier_used: &'static str,
pub tier_used_up: &'static str,
@@ -242,6 +249,11 @@ impl TrayTexts {
tier_gemini_flash: "Flash",
tier_gemini_flash_lite: "Flash Lite",
tier_premium: "Credits",
+ tier_agy_gemini_five_hour: "Gemini 5-hour",
+ tier_agy_gemini_weekly: "Gemini weekly",
+ tier_agy_third_party_five_hour: "Claude 5-hour",
+ tier_agy_third_party_weekly: "Claude weekly",
+ tier_agy_argon_weekly: "Argon weekly",
tier_left: "{label} {value}% left",
tier_used: "{label} {value}% used",
tier_used_up: "{label} used up",
@@ -300,6 +312,11 @@ impl TrayTexts {
tier_gemini_flash: "Flash",
tier_gemini_flash_lite: "Flash Lite",
tier_premium: "프리미엄 요청",
+ tier_agy_gemini_five_hour: "Gemini 5시간",
+ tier_agy_gemini_weekly: "Gemini 주간",
+ tier_agy_third_party_five_hour: "Claude 5시간",
+ tier_agy_third_party_weekly: "Claude 주간",
+ tier_agy_argon_weekly: "Argon 주간",
tier_left: "{label} {value}% 남음",
tier_used: "{label} {value}% 사용",
tier_used_up: "{label} 소진됨",
@@ -360,6 +377,11 @@ impl TrayTexts {
tier_gemini_flash: "Flash",
tier_gemini_flash_lite: "Flash Lite",
tier_premium: "Credits",
+ tier_agy_gemini_five_hour: "Gemini 5 Stunden",
+ tier_agy_gemini_weekly: "Gemini wöchentlich",
+ tier_agy_third_party_five_hour: "Claude 5 Stunden",
+ tier_agy_third_party_weekly: "Claude wöchentlich",
+ tier_agy_argon_weekly: "Argon wöchentlich",
tier_left: "{label}: {value} % übrig",
tier_used: "{label}: {value} % verbraucht",
tier_used_up: "{label}: aufgebraucht",
@@ -418,6 +440,11 @@ impl TrayTexts {
tier_gemini_flash: "Flash",
tier_gemini_flash_lite: "Flash Lite",
tier_premium: "Credits",
+ tier_agy_gemini_five_hour: "Gemini, 5 часов",
+ tier_agy_gemini_weekly: "Gemini, неделя",
+ tier_agy_third_party_five_hour: "Claude, 5 часов",
+ tier_agy_third_party_weekly: "Claude, неделя",
+ tier_agy_argon_weekly: "Argon, неделя",
tier_left: "{label}: осталось {value}%",
tier_used: "{label}: использовано {value}%",
tier_used_up: "{label}: исчерпано",
@@ -476,6 +503,11 @@ impl TrayTexts {
tier_gemini_flash: "Flash",
tier_gemini_flash_lite: "Flash Lite",
tier_premium: "Credits",
+ tier_agy_gemini_five_hour: "Gemini 5 saatlik",
+ tier_agy_gemini_weekly: "Gemini haftalık",
+ tier_agy_third_party_five_hour: "Claude 5 saatlik",
+ tier_agy_third_party_weekly: "Claude haftalık",
+ tier_agy_argon_weekly: "Argon haftalık",
tier_left: "{label} %{value} kaldı",
tier_used: "{label} %{value} kullanıldı",
tier_used_up: "{label} tükendi",
@@ -536,6 +568,11 @@ impl TrayTexts {
tier_gemini_flash: "Flash",
tier_gemini_flash_lite: "Flash Lite",
tier_premium: "Credits",
+ tier_agy_gemini_five_hour: "Gemini 5時間",
+ tier_agy_gemini_weekly: "Gemini 週間",
+ tier_agy_third_party_five_hour: "Claude 5時間",
+ tier_agy_third_party_weekly: "Claude 週間",
+ tier_agy_argon_weekly: "Argon 週間",
tier_left: "{label} 残り {value}%",
tier_used: "{label} 使用済み {value}%",
tier_used_up: "{label} 使い切り",
@@ -594,6 +631,11 @@ impl TrayTexts {
tier_gemini_flash: "Flash",
tier_gemini_flash_lite: "Flash Lite",
tier_premium: "Credits",
+ tier_agy_gemini_five_hour: "Gemini 5 小時",
+ tier_agy_gemini_weekly: "Gemini 每週",
+ tier_agy_third_party_five_hour: "Claude 5 小時",
+ tier_agy_third_party_weekly: "Claude 每週",
+ tier_agy_argon_weekly: "Argon 每週",
tier_left: "{labelSp}剩餘 {value}%",
tier_used: "{labelSp}已用 {value}%",
tier_used_up: "{labelSp}已用完",
@@ -652,6 +694,11 @@ impl TrayTexts {
tier_gemini_flash: "Flash",
tier_gemini_flash_lite: "Flash Lite",
tier_premium: "Credits",
+ tier_agy_gemini_five_hour: "Gemini 5 小时",
+ tier_agy_gemini_weekly: "Gemini 每周",
+ tier_agy_third_party_five_hour: "Claude 5 小时",
+ tier_agy_third_party_weekly: "Claude 每周",
+ tier_agy_argon_weekly: "Argon 每周",
tier_left: "{labelSp}剩余 {value}%",
tier_used: "{labelSp}已用 {value}%",
tier_used_up: "{labelSp}已用完",
@@ -738,9 +785,12 @@ enum TierGroup {
GeminiFlash,
GeminiFlashLite,
Premium,
- /// Antigravity:Gemini 一组(5 小时 + 每周)、Claude 和 GPT 共用一组、Pro 档另有 Argon 每周
- AgyGemini,
- AgyThirdParty,
+ /// Antigravity:Gemini、Claude/GPT(共用额度)各有 5 小时和每周两档,Pro 档另有 Argon 每周。
+ /// 每档各一行,同主界面卡片(曾按模型合成一行只留用得多的那档,周限就看不到了)。
+ AgyGeminiFiveHour,
+ AgyGeminiWeekly,
+ AgyThirdPartyFiveHour,
+ AgyThirdPartyWeekly,
AgyArgon,
}
@@ -767,18 +817,20 @@ const TIER_GROUPS: &[(TierGroup, &[&str])] = {
(TierGroup::GeminiFlashLite, &[s::TIER_GEMINI_FLASH_LITE]),
(TierGroup::Premium, &["premium"]),
(
- TierGroup::AgyGemini,
- &[
- crate::services::subscription_agy::TIER_AGY_GEMINI_FIVE_HOUR,
- crate::services::subscription_agy::TIER_AGY_GEMINI_WEEKLY,
- ],
+ TierGroup::AgyGeminiFiveHour,
+ &[crate::services::subscription_agy::TIER_AGY_GEMINI_FIVE_HOUR],
),
(
- TierGroup::AgyThirdParty,
- &[
- crate::services::subscription_agy::TIER_AGY_THIRD_PARTY_FIVE_HOUR,
- crate::services::subscription_agy::TIER_AGY_THIRD_PARTY_WEEKLY,
- ],
+ TierGroup::AgyGeminiWeekly,
+ &[crate::services::subscription_agy::TIER_AGY_GEMINI_WEEKLY],
+ ),
+ (
+ TierGroup::AgyThirdPartyFiveHour,
+ &[crate::services::subscription_agy::TIER_AGY_THIRD_PARTY_FIVE_HOUR],
+ ),
+ (
+ TierGroup::AgyThirdPartyWeekly,
+ &[crate::services::subscription_agy::TIER_AGY_THIRD_PARTY_WEEKLY],
),
(
TierGroup::AgyArgon,
@@ -803,10 +855,11 @@ fn tier_label(texts: &TrayTexts, group: TierGroup, tier_name: &str) -> &'static
TierGroup::GeminiFlash => texts.tier_gemini_flash,
TierGroup::GeminiFlashLite => texts.tier_gemini_flash_lite,
TierGroup::Premium => texts.tier_premium,
- // 模型名,不翻译(同前端 `subscription.agyGemini` 等)
- TierGroup::AgyGemini => "Gemini",
- TierGroup::AgyThirdParty => "Claude/GPT",
- TierGroup::AgyArgon => "Argon",
+ TierGroup::AgyGeminiFiveHour => texts.tier_agy_gemini_five_hour,
+ TierGroup::AgyGeminiWeekly => texts.tier_agy_gemini_weekly,
+ TierGroup::AgyThirdPartyFiveHour => texts.tier_agy_third_party_five_hour,
+ TierGroup::AgyThirdPartyWeekly => texts.tier_agy_third_party_weekly,
+ TierGroup::AgyArgon => texts.tier_agy_argon_weekly,
}
}
@@ -825,9 +878,12 @@ fn tier_short_label(texts: &TrayTexts, group: TierGroup, tier_name: &str) -> &'s
TierGroup::GeminiFlash => "Flash",
TierGroup::GeminiFlashLite => "Lite",
TierGroup::Premium => "Credits",
- TierGroup::AgyGemini => "Gemini",
- TierGroup::AgyThirdParty => "Claude",
- TierGroup::AgyArgon => "Argon",
+ // Antigravity 每档一行,短名带上窗口才分得清(列宽随最长短名放宽,见面板 `shortLabelWidth`)
+ TierGroup::AgyGeminiFiveHour => "Gemini 5h",
+ TierGroup::AgyGeminiWeekly => "Gemini 7d",
+ TierGroup::AgyThirdPartyFiveHour => "Claude 5h",
+ TierGroup::AgyThirdPartyWeekly => "Claude 7d",
+ TierGroup::AgyArgon => "Argon 7d",
}
}
diff --git a/src-tauri/src/tray/tests.rs b/src-tauri/src/tray/tests.rs
index 595bc6492..bbd5fab67 100644
--- a/src-tauri/src/tray/tests.rs
+++ b/src-tauri/src/tray/tests.rs
@@ -2612,7 +2612,7 @@ fn agy_switch_feedback_says_the_desktop_app_needs_a_restart() {
}
#[test]
-fn agy_quota_groups_gemini_claude_and_argon_by_their_lowest_left() {
+fn agy_quota_shows_every_window_including_the_weekly_limits() {
use crate::services::subscription_agy as agy;
let quota = make_quota(
"agy",
@@ -2626,11 +2626,16 @@ fn agy_quota_groups_gemini_claude_and_argon_by_their_lowest_left() {
],
);
let (text, almost_out) = title(format_subscription_quota(&en(), &quota)).expect("lines");
+ // 每档各一行:周限不再被同模型的 5 小时档挤掉
assert_eq!(
text,
- "Gemini 40% left · Claude/GPT 5% left · Argon 100% left"
+ "Gemini 5-hour 90% left · Gemini weekly 40% left · Claude 5-hour 5% left · \
+ Claude weekly 70% left · Argon weekly 100% left"
);
assert!(almost_out);
+ let (text, _) = title(format_subscription_quota(&zh(), &quota)).expect("lines");
+ assert!(text.contains("Gemini 每周"), "{text}");
+ assert!(text.contains("Claude 每周"), "{text}");
}
#[test]
@@ -2768,7 +2773,9 @@ fn panel_quota_emits_short_labels_and_distinguishes_monthly_and_kimi_tiers() {
tier(s::TIER_GEMINI_FLASH, 20.0),
tier(s::TIER_GEMINI_FLASH_LITE, 30.0),
tier(agy::TIER_AGY_GEMINI_FIVE_HOUR, 15.0),
+ tier(agy::TIER_AGY_GEMINI_WEEKLY, 5.0),
tier(agy::TIER_AGY_THIRD_PARTY_FIVE_HOUR, 25.0),
+ tier(agy::TIER_AGY_THIRD_PARTY_WEEKLY, 45.0),
tier(agy::TIER_AGY_GEMINI_ARGON_WEEKLY, 35.0),
],
);
@@ -2789,9 +2796,11 @@ fn panel_quota_emits_short_labels_and_distinguishes_monthly_and_kimi_tiers() {
Some("Pro"),
Some("Flash"),
Some("Lite"),
- Some("Gemini"),
- Some("Claude"),
- Some("Argon"),
+ Some("Gemini 5h"),
+ Some("Gemini 7d"),
+ Some("Claude 5h"),
+ Some("Claude 7d"),
+ Some("Argon 7d"),
]
);
diff --git a/src/tray-panel/TrayPanel.tsx b/src/tray-panel/TrayPanel.tsx
index b0c99ce43..a781c5d8d 100644
--- a/src/tray-panel/TrayPanel.tsx
+++ b/src/tray-panel/TrayPanel.tsx
@@ -177,13 +177,32 @@ export function formatResetCompact(iso: string, now: Date): string | null {
function quotaHasReset(
quota: PanelQuota | null | undefined,
- compact: boolean,
now: Date,
): boolean {
if (!quota) return false;
- return quota.lines
- .slice(0, compact ? 2 : 3)
- .some((line) => line.resetsAt && formatResetCompact(line.resetsAt, now));
+ return quota.lines.some(
+ (line) => line.resetsAt && formatResetCompact(line.resetsAt, now),
+ );
+}
+
+/**
+ * 短档名列宽:同一块面板里的各应用 / 各账号共用一个宽度,进度条才对得齐;
+ * 按其中最长的短档名放宽(Antigravity 的「Gemini 7d」、Kimi 的「Mo total」),至少 50px。
+ * `ch` 按额度网格的字号算,多留 1ch 给粗体。
+ */
+function shortLabelWidth(quotas: Array<PanelQuota | null | undefined>): string {
+ const longest = Math.max(
+ 0,
+ ...quotas.flatMap(
+ (quota) => quota?.lines.map((line) => line.shortLabel?.length ?? 0) ?? [],
+ ),
+ );
+ return `max(50px, ${longest + 1}ch)`;
+}
+
+/** 进度条画多长:「已用」显示时画已用的部分,同主界面额度条。 */
+function barPercent(left: number, showsUsed: boolean | undefined): number {
+ return Math.max(showsUsed ? 100 - left : left, 2);
}
/** 单行正余额时收进标题行右侧纵向居中展示,省去一整行高度。 */
@@ -237,15 +256,18 @@ function QuotaBlock({
compact = false,
inlineResetCredits = false,
reserveResetCol = false,
+ labelWidth = "50px",
}: {
quota: PanelQuota;
texts: PanelTexts;
- /** 子面板里:最多两档 */
+ /** 子面板里:间距更紧 */
compact?: boolean;
/** 重置次数已内联到标题行,不再单独占一行 */
inlineResetCredits?: boolean;
/** 同面板有其它应用带重置时间时,无重置时间的块也保留第四列让进度条对齐 */
reserveResetCol?: boolean;
+ /** 短档名列宽(`shortLabelWidth`),同一面板共用 */
+ labelWidth?: string;
}) {
const showResetCredits =
!inlineResetCredits && quota.resetCredits != null && quota.resetCredits > 0;
@@ -253,7 +275,8 @@ function QuotaBlock({
return null;
}
const now = new Date();
- const lines = quota.lines.slice(0, compact ? 2 : 3).map((line) => ({
+ // 每档都显示,同主界面卡片(Antigravity 有 4–5 档,截断会丢掉周限);面板超高时滚动
+ const lines = quota.lines.map((line) => ({
...line,
when: line.resetsAt ? formatResetIn(line.resetsAt, now, texts) : null,
whenCompact: line.resetsAt ? formatResetCompact(line.resetsAt, now) : null,
@@ -269,12 +292,15 @@ function QuotaBlock({
<div
data-quota-grid={showResetCol ? "4col" : "3col"}
className={cn(
- "grid items-center gap-x-2 gap-y-1",
- showResetCol
- ? "grid-cols-[50px_minmax(1.5rem,1fr)_34px_60px]"
- : "grid-cols-[50px_minmax(1.5rem,1fr)_34px]",
+ // 字号同短档名,`labelWidth` 里的 ch 才按它算
+ "grid items-center gap-x-2 gap-y-1 text-[11.5px]",
compact ? "mt-1" : "mt-1.5",
)}
+ style={{
+ gridTemplateColumns: `${labelWidth} minmax(1.5rem,1fr) 34px${
+ showResetCol ? " 60px" : ""
+ }`,
+ }}
>
{lines.map((line, index) => {
const left = line.left ?? 0;
@@ -300,7 +326,7 @@ function QuotaBlock({
? "bg-amber-500"
: "bg-blue-500",
)}
- style={{ width: `${Math.max(left, 2)}%` }}
+ style={{ width: `${barPercent(left, quota.showsUsed)}%` }}
/>
</span>
<span
@@ -371,7 +397,9 @@ function QuotaBlock({
? "bg-amber-500"
: "bg-blue-500",
)}
- style={{ width: `${Math.max(line.left, 2)}%` }}
+ style={{
+ width: `${barPercent(line.left, quota.showsUsed)}%`,
+ }}
/>
</span>
)}
@@ -415,6 +443,7 @@ function AppRow({
active,
side,
reserveResetCol,
+ labelWidth,
onHover,
onLeave,
onOpen,
@@ -424,6 +453,7 @@ function AppRow({
active: boolean;
side: "left" | "right";
reserveResetCol: boolean;
+ labelWidth: string;
onHover: () => void;
onLeave: () => void;
onOpen: () => void;
@@ -510,6 +540,7 @@ function AppRow({
texts={texts}
inlineResetCredits
reserveResetCol={reserveResetCol}
+ labelWidth={labelWidth}
/>
</span>
)}
@@ -531,11 +562,13 @@ function SubRow({
row,
texts,
reserveResetCol,
+ labelWidth,
onAction,
}: {
row: PanelRow;
texts: PanelTexts;
reserveResetCol: boolean;
+ labelWidth: string;
onAction: (id: string) => void;
}) {
if (row.kind === "separator") {
@@ -629,6 +662,7 @@ function SubRow({
compact
inlineResetCredits
reserveResetCol={reserveResetCol}
+ labelWidth={labelWidth}
/>
</span>
)}
@@ -660,7 +694,10 @@ function SubPanel({
const providerCount = rows.filter((row) => row.kind === "provider").length;
const now = new Date();
const subHasReset = shown.some((row) =>
- quotaHasReset(row.provider?.quota, true, now),
+ quotaHasReset(row.provider?.quota, now),
+ );
+ const subLabelWidth = shortLabelWidth(
+ shown.map((row) => row.provider?.quota),
);
return (
@@ -699,6 +736,7 @@ function SubPanel({
row={row}
texts={texts}
reserveResetCol={subHasReset}
+ labelWidth={subLabelWidth}
onAction={onAction}
/>
))
@@ -1363,7 +1401,10 @@ export function TrayPanel() {
{(() => {
const now = new Date();
const mainHasReset = apps.some((entry) =>
- quotaHasReset(entry.quota, false, now),
+ quotaHasReset(entry.quota, now),
+ );
+ const mainLabelWidth = shortLabelWidth(
+ apps.map((entry) => entry.quota),
);
return apps.map((app) => (
<AppRow
@@ -1373,6 +1414,7 @@ export function TrayPanel() {
active={openEntry?.app === app.app}
side={placement.side}
reserveResetCol={mainHasReset}
+ labelWidth={mainLabelWidth}
onHover={() => hoverApp(app)}
onLeave={leaveApp}
onOpen={() =>
diff --git a/tests/components/TrayPanel.test.tsx b/tests/components/TrayPanel.test.tsx
index 8df34c006..30d2f33c8 100644
--- a/tests/components/TrayPanel.test.tsx
+++ b/tests/components/TrayPanel.test.tsx
@@ -1112,4 +1112,56 @@ describe("TrayPanel compact quota presentation", () => {
expect(grid).toHaveAttribute("data-quota-grid", "4col");
});
});
+
+ it("shows every Antigravity window, widens the label column for long short labels, and draws used-mode bars as used", async () => {
+ const line = (shortLabel: string, left: number) => ({
+ text: `${shortLabel} ${100 - left}%`,
+ shortLabel,
+ left,
+ warn: false,
+ resetsAt: new Date(Date.now() + 5 * 3600_000).toISOString(),
+ emphasis: null,
+ });
+ vi.mocked(trayPanelApi.layout).mockResolvedValue(undefined);
+ vi.mocked(trayPanelApi.placement).mockResolvedValue(windows);
+ vi.mocked(trayPanelApi.state).mockResolvedValue({
+ ...state,
+ apps: [
+ {
+ ...state.apps[0],
+ app: "agy",
+ name: "Antigravity",
+ current: "Google Official",
+ quota: {
+ lines: [
+ line("Gemini 5h", 91),
+ line("Gemini 7d", 98),
+ line("Claude 5h", 100),
+ line("Claude 7d", 0),
+ line("Argon 7d", 60),
+ ],
+ note: null,
+ resetCredits: null,
+ showsUsed: true,
+ },
+ },
+ ],
+ });
+
+ const { container } = renderPanel();
+
+ // 五档都在,周限不再被截掉
+ expect(await screen.findByText("Claude 7d")).toBeVisible();
+ expect(screen.getByText("Argon 7d")).toBeVisible();
+
+ // 列宽按最长的短名(9 个字符)放宽,至少 50px
+ const grid = container.querySelector("[data-quota-grid]") as HTMLElement;
+ expect(grid.style.gridTemplateColumns).toContain("max(50px, 10ch)");
+
+ // 「已用」显示:数字是已用,进度条也画已用的部分
+ expect(screen.getByText("9%")).toBeVisible();
+ const bars = grid.querySelectorAll<HTMLElement>(".rounded-full > span");
+ expect(bars[0].style.width).toBe("9%");
+ expect(bars[3].style.width).toBe("100%");
+ });
});