Skip to content

fix(agy): skip quota queries without usable local sign-in - #10233

Merged
farion1231 merged 2 commits into
farion1231:mainfrom
ruixiazS2023:fix/agy-quota-keychain-preflight
Dec 2, 2026
Merged

farion1231 merged 2 commits into
farion1231:mainfrom
ruixiazS2023:fix/agy-quota-keychain-preflight

Conversation

@ruixiazS2023

Copy link
Copy Markdown
Contributor

Human Note / 本人说明

在查询Agy额度前,先检查本地登录状态。钥匙串没有可用凭证时,在应用内提示并跳过查询。

Summary / 概述

Checking official Antigravity quota starts agy --print /usage. When the local keychain has no usable sign-in, that command can fall back to interactive sign-in and open a browser.

Check the keychain in the shared quota launcher before starting the CLI. An absent, malformed, or expired login with no usable token produces an in-app sign-in error. A read failure produces a retryable message without exposing credentials or underlying keychain error details. A usable login can be queried even if it has not been imported into CC Switch. Explicit ADC sessions keep their existing path.

This guards failures detectable from local credentials. OAuth renewal can still fail at runtime after the check.

Related Issue / 关联 Issue

Refs #10066. This change is independent of the timeout cache in #10232.

Verification / 验证

  • Ran six tests locally on macOS using the quota service in an isolated harness with a fake keychain. The signed-out launch regression failed against upstream and passed with the patch.
  • Ran rustfmt and checked the patch for whitespace errors.
  • Full desktop build and Windows/Linux end-to-end behavior have not been checked locally.

Checklist / 检查清单

  • pnpm typecheck
  • pnpm format:check
  • cargo clippy
  • Existing quota failure UI displays the result.

@github-actions github-actions Bot added the backend Backend (Rust/Tauri) label Dec 2, 2026
# Conflicts:
#	src-tauri/src/services/subscription_agy.rs
@farion1231

Copy link
Copy Markdown
Owner

Thanks @ruixiazS2023! This fixes a real annoyance: with agy installed but signed out (or after /logout), the background quota check used to launch agy and pop a browser sign-in page. Reading the same keychain entry first, keeping read failures retryable without exposing error details, and letting ADC sessions through is a tidy, well-scoped fix. The regression test that fails on upstream is appreciated too.

I merged the latest main into your branch to resolve a conflict with #10103 (in-app agy sign-in); CI is green on the result.

Two non-blocking follow-ups, if you're interested:

  • agy 1.5 stores tokens in a file instead of the keychain when SSH_CONNECTION / SSH_CLIENT / SSH_TTY or AGY_CLI_FORCE_FILE_TOKEN_STORAGE is set (see the env handling in src-tauri/src/services/agy_account/acp_login.rs). The quota command keeps those variables, so a signed-in user in that environment would be reported as signed out. Skipping the precheck when any of them is set would match agy's own behavior.
  • Keychain entries in a format we don't recognize are currently treated as "not signed in". Passing those through to agy would be safer if agy changes its storage format again.

#10066 stays open for the main case (token refresh failing and falling back to browser sign-in).

@farion1231
farion1231 merged commit 80113bf into farion1231:main Dec 2, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend (Rust/Tauri)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants