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(agy): query official quota by default for Antigravity official cards

Jason38c960474973
diff --git a/docs/agy-integration-zh.md b/docs/agy-integration-zh.md
index 054bb1966..870a3ca72 100644
--- a/docs/agy-integration-zh.md
+++ b/docs/agy-integration-zh.md
@@ -47,7 +47,7 @@ agy(CLI 和 Antigravity 桌面版)启动时读 `~/.gemini/config/config.json
- **请求头**:表单用通用的请求头编辑器编辑 `gateway.customHeaders`;genai 协议下自动补的 `x-goog-api-key` 导入时去掉、不显示,用户自己填了同名头时以用户的为准。
- 当前卡指针存在设备级的 `current_provider_agy`;在用的卡删不掉。live 里已有网关时,首启导入成一张第三方卡(`category: custom`)。深链接 `enabled=true` 导入后直接切过去。
- CLI 每次启动都读这个文件;**桌面版只在启动时读**,切换后要重启桌面版。已经运行的 agy 进程不会热切换。
-- 托盘和 Gemini CLI 一样一行列供应商卡,点了直接切换;绑号的官方卡同时切 agy 登录,标题旁显示所绑账号,开了官方额度才查额度(只有 agy 现在登着的号会真的起 agy 查)。
+- 托盘和 Gemini CLI 一样一行列供应商卡,点了直接切换;绑号的官方卡同时切 agy 登录,标题旁显示所绑账号,官方卡(绑号或跟随 agy 当前登录)没存过用量配置时默认查官方额度,在卡片的用量配置里关掉就不查(只有 agy 现在登着的号会真的起 agy 查,别的号显示最后一次查到的)。
「打开终端」:
diff --git a/src-tauri/src/tray.rs b/src-tauri/src/tray.rs
index 6541dae0d..b7b50e0f6 100644
--- a/src-tauri/src/tray.rs
+++ b/src-tauri/src/tray.rs
@@ -1184,13 +1184,25 @@ enum TrayUsageSource {
/// Keep the tray's refresh and display paths on the same credentials and toggle.
fn tray_usage_source(app_type: &AppType, provider: &Provider) -> Option<TrayUsageSource> {
- // Antigravity 绑号的官方卡和卡片一样:开了官方额度才查(`agy -p /usage` 要起 agy),
- // 不像别家绑号卡那样默认开着
- if *app_type == AppType::Agy {
- if let Some(account_id) = agy_bound_account_id(provider) {
- return provider_uses_official_subscription(provider)
- .then_some(TrayUsageSource::AgyAccount(account_id));
+ // Antigravity 官方卡(同卡片):没存过用量配置时默认查官方额度,和 4.0.44 托盘默认实时查
+ // agy 当前登录的号一致;用户关掉了就不查。绑了号的按账号取,没绑的跟随 agy 当前登录,
+ // 读应用级订阅缓存。
+ if *app_type == AppType::Agy && crate::services::provider::agy_direct::is_official(provider) {
+ let enabled = match provider
+ .meta
+ .as_ref()
+ .and_then(|meta| meta.usage_script.as_ref())
+ {
+ None => true,
+ Some(_) => provider_uses_official_subscription(provider),
+ };
+ if !enabled {
+ return None;
}
+ return Some(match agy_bound_account_id(provider) {
+ Some(account_id) => TrayUsageSource::AgyAccount(account_id),
+ None => TrayUsageSource::Subscription,
+ });
}
// Copilot 反代卡(任意应用下,含聚合成员):卡片底部恒显示 Copilot 额度,这类卡的
// 「配置用量查询」入口也已隐藏、存不下开关(#10106),托盘同口径按 Copilot 路径查。
diff --git a/src-tauri/src/tray/tests.rs b/src-tauri/src/tray/tests.rs
index 43e3d79a9..4b2989f19 100644
--- a/src-tauri/src/tray/tests.rs
+++ b/src-tauri/src/tray/tests.rs
@@ -2564,10 +2564,19 @@ fn agy_official_card_hint_shows_only_its_bound_account() {
}
#[test]
-fn agy_bound_card_quota_is_opt_in_and_reads_that_account() {
- // 和卡片一样默认不查:`agy -p /usage` 要起 agy
+fn agy_official_card_quota_defaults_on_and_reads_that_account() {
+ // 没存过用量配置的官方卡默认查(自动导入的 default 卡就是这样,4.0.45 起托盘因此一家都不显示)
assert_eq!(
tray_usage_source(&AppType::Agy, &agy_official_provider(Some("acct-1"), None)),
+ Some(TrayUsageSource::AgyAccount("acct-1".to_string()))
+ );
+ assert_eq!(
+ tray_usage_source(&AppType::Agy, &agy_official_provider(None, None)),
+ Some(TrayUsageSource::Subscription)
+ );
+ // 用户关掉的不查
+ assert_eq!(
+ tray_usage_source(&AppType::Agy, &agy_official_provider(None, Some(false))),
None
);
assert_eq!(
diff --git a/src/components/UsageScriptModal.tsx b/src/components/UsageScriptModal.tsx
index bf413bf94..e444d5075 100644
--- a/src/components/UsageScriptModal.tsx
+++ b/src/components/UsageScriptModal.tsx
@@ -415,11 +415,13 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
PROVIDER_TYPES.XAI_OAUTH,
)?.trim() || null
: null;
- // 绑了账号的官方卡没保存过开关时默认开(卡片和托盘同一规则)
+ // 绑了账号的官方卡没保存过开关时默认开(卡片和托盘同一规则);Antigravity 官方卡
+ // 不论绑没绑号都默认开
const defaultsToEnabled =
isBoundCodexOfficial ||
Boolean(claudeBoundAccountId) ||
- Boolean(grokBoundAccountId);
+ Boolean(grokBoundAccountId) ||
+ (appId === "agy" && isOfficialSubscription);
const [script, setScript] = useState<UsageScript>(() => {
const savedScript = provider.meta?.usage_script;
diff --git a/src/components/providers/ProviderCard.tsx b/src/components/providers/ProviderCard.tsx
index 02753fc42..11c8bdcfc 100644
--- a/src/components/providers/ProviderCard.tsx
+++ b/src/components/providers/ProviderCard.tsx
@@ -289,17 +289,22 @@ export function ProviderCard({
PROVIDER_TYPES.XAI_OAUTH,
)?.trim() || null
: null;
+ // Antigravity 官方卡(绑号或跟随 agy 当前登录)没存过用量配置时默认查官方额度(同托盘)
+ const agyOfficialDefaultsOn =
+ appId === "agy" && isOfficial && !provider.meta?.usage_script;
// 绑了账号的官方卡(Codex / Claude / Grok)默认查额度,和 Kimi、agy 的账号卡一样(同托盘)
const usageEnabled =
provider.meta?.usage_script?.enabled ??
(isBoundCodexOfficial ||
Boolean(claudeBoundAccountId) ||
- Boolean(grokBoundAccountId));
+ Boolean(grokBoundAccountId) ||
+ agyOfficialDefaultsOn);
const supportsOfficialSubscription =
isOfficial && appHas(appId, "officialSubscription");
const isOfficialSubscriptionUsage =
+ agyOfficialDefaultsOn ||
provider.meta?.usage_script?.templateType ===
- TEMPLATE_TYPES.OFFICIAL_SUBSCRIPTION;
+ TEMPLATE_TYPES.OFFICIAL_SUBSCRIPTION;
const officialSubscriptionEnabled =
supportsOfficialSubscription && usageEnabled && isOfficialSubscriptionUsage;
// 没绑账号的 Claude 官方卡用 Claude Code 的默认登录:开了额度查询时,地址后面跟默认登录的套餐