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): skip keychain quota precheck for file-backed sign-in (#10248)

Ruixia Zhong38e762afd473
diff --git a/src-tauri/src/services/subscription_agy.rs b/src-tauri/src/services/subscription_agy.rs
index 171c89362..6162251dc 100644
--- a/src-tauri/src/services/subscription_agy.rs
+++ b/src-tauri/src/services/subscription_agy.rs
@@ -224,6 +224,17 @@ fn build_usage_command(bin: &std::path::Path) -> tokio::process::Command {
command
}
+fn uses_file_token_storage(is_set: impl FnMut(&str) -> bool) -> bool {
+ [
+ "SSH_CONNECTION",
+ "SSH_CLIENT",
+ "SSH_TTY",
+ "AGY_CLI_FORCE_FILE_TOKEN_STORAGE",
+ ]
+ .into_iter()
+ .any(is_set)
+}
+
fn keychain_quota_failure(read: Result<Option<String>, AppError>) -> Option<SubscriptionQuota> {
let raw = match read {
Ok(raw) => raw,
@@ -277,9 +288,10 @@ pub(crate) async fn get_agy_subscription_quota() -> Result<SubscriptionQuota, St
return Ok(SubscriptionQuota::not_found(TOOL));
};
// 查额度是后台操作,缺少可用的钥匙串凭据时别让 agy 回退到交互式登录。
- // 显式选择 ADC 的 CLI 不依赖这个钥匙串条目。
+ // ADC 和文件凭据模式不依赖这个钥匙串条目。
if keychain::supported()
&& !std::env::var("AGY_ADC_AUTH").is_ok_and(|value| value.eq_ignore_ascii_case("true"))
+ && !uses_file_token_storage(|name| std::env::var_os(name).is_some())
{
let failure =
tokio::task::spawn_blocking(|| keychain_quota_failure(SystemKeychain::agy().read()))
@@ -358,6 +370,19 @@ fn now_millis() -> i64 {
mod tests {
use super::*;
+ #[test]
+ fn ssh_or_explicit_file_storage_skips_keychain_precheck() {
+ assert!(!uses_file_token_storage(|_| false));
+ for name in [
+ "SSH_CONNECTION",
+ "SSH_CLIENT",
+ "SSH_TTY",
+ "AGY_CLI_FORCE_FILE_TOKEN_STORAGE",
+ ] {
+ assert!(uses_file_token_storage(|candidate| candidate == name));
+ }
+ }
+
#[test]
fn quota_requires_a_usable_local_login() {
for raw in [