Skip to content

fix(usage): read Antigravity's sign-in from the Linux desktop keyring - #1776

Merged
devswha merged 1 commit into
mainfrom
fix/antigravity-linux-keyring
Oct 23, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/antigravity-linux-keyring

Conversation

@devswha

@devswha devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Change

On Linux, the Antigravity usage meter now also finds its sign-in when the Antigravity CLI keeps it in the desktop keyring (GNOME Keyring / Secret Service) and there is no antigravity-oauth-token file.

Fixes #1103

Cause

fromKeychain() in server/usage.ts returns nothing unless the platform is macOS. Antigravity's discovery went through it, so on Linux only the token file was ever read. The CLI's go-keyring item on Linux is a Secret Service item with service=gemini and username=antigravity, the attributes the issue reports.

What changed

  • server/usage.ts: on Linux only, Antigravity reads that item with secret-tool lookup service gemini username antigravity, through the existing runCommand.
    • A missing secret-tool, a non-zero exit or the 5 s timeout gives no credential and no error.
    • The value goes through the same antigravitySignIn parser as the macOS keychain read, including its go-keyring-base64: form.
    • The token-file fallback stays, and so does the rule that the later-expiring credential wins.
    • macOS and the other providers are unchanged.
  • How often the lookup runs: it is part of usage discovery, which is cached: normally at most once every 5 minutes, and a forced refresh at most once every 30 seconds. If the keyring is locked, secret-tool may show the desktop's unlock prompt at that rate.

Checks

  • HERDR_TEST_MODE=unit bun test server/usage.test.ts: 62 pass, 0 fail. The new Linux cases are:

    • the keyring item with no token file;
    • secret-tool missing or failing, which gives no Antigravity and no error;
    • the later-expiring of the file and the keyring item winning, in both orders.

    With the old discovery restored, the keyring-only and keyring-preferred cases fail.

  • bun run typecheck: passes.

  • bun run check fast: passes (unit 6258 pass, 0 fail, 13 skip in 443 files, 8 at a time, 57.7s).

  • Not run against a real GNOME Keyring: the tests inject the secret-tool output, as the existing macOS keychain tests inject security.

Outside PRs that touch the same files

The outside PR #1678 (Gemini quotas from the Antigravity CLI) also edits server/usage.ts and server/usage.test.ts and will need a rebase after this one.

Read Antigravity's Secret Service item on Linux and retain the existing
file fallback and expiry-based selection. Add focused regression coverage
and a changelog entry.

Fixes #1103
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 54becbb and f6f5ebd.

📒 Files selected for processing: 3
  • changelog.d/antigravity-linux-keyring.md
  • server/usage.test.ts
  • server/usage.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where the Antigravity usage meter could be missing on Linux when sign-in credentials were stored in the desktop keyring.
    • The meter now uses the most recently expiring credentials when sign-in information is available from both the desktop keyring and the local credentials file. Other platforms continue to use their existing sign-in behavior.

On Linux, Antigravity sign-in discovery runs secret-tool lookup service gemini username antigravity and parses the result. It combines that sign-in with the token-file sign-in through keychainOrFile. Tests cover credential use, missing or empty lookup results, and later-expiring credential selection. The changelog records the fix.

Changes: Antigravity Linux keyring discovery

Layer / File(s) Summary
Read Linux keyring credentials
server/usage.ts
Linux Antigravity discovery reads the gemini credential for username antigravity through secret-tool. Other platforms continue to use fromKeychain, and the keyring result is combined with the file sign-in.
Validate lookup and credential selection
server/usage.test.ts, changelog.d/antigravity-linux-keyring.md
Tests cover returned credentials, missing or empty lookup results, command arguments, and choosing the credential with the later expiry. The changelog records the Linux keyring fix.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: diogo7dias, nahwan-kim

Merge Risk: 🔵 Low · up to f6f5e

An unreadable Linux keyring can make Antigravity usage disappear when no token file exists. This limited case is mergeable with owner awareness.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue [#1103] requires Linux Secret Service discovery when no token file exists. The PR implements the secret-tool lookup service gemini username antigravity path, preserves the file fallback, and p… Implement distinct Linux Secret Service result handling for a missing item, a locked collection, and an unavailable or failed service. Preserve the existing no-error behavior where required, and add regression tests for each distinct result…
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: reading Antigravity's sign-in from the Linux desktop keyring.
Description check Passed The description explains the problem, resulting behavior, implementation details, fallback behavior, limitations, related changes, and validation results. The "Checks" section provides the required va…
Out of Scope Changes check Passed The changes are limited to Antigravity usage discovery, its focused unit tests, and a changelog entry. The command uses the issue-specified Secret Service attributes. The fallback and expiry-selection…
Full details: Description check

Explanation

The description explains the problem, resulting behavior, implementation details, fallback behavior, limitations, related changes, and validation results. The "Checks" section provides the required validation information, although it uses a different heading from the template's "Validation" heading.

Full details: Out of Scope Changes check

Explanation

The changes are limited to Antigravity usage discovery, its focused unit tests, and a changelog entry. The command uses the issue-specified Secret Service attributes. The fallback and expiry-selection tests directly support [#1103]. No unrelated provider or product behavior is changed.

Full details: Linked Issues check

Explanation

Issue [#1103] requires Linux Secret Service discovery when no token file exists. The PR implements the secret-tool lookup service gemini username antigravity path, preserves the file fallback, and preserves later-expiry selection. The added tests cover keyring-only discovery and both expiry orders. However, [#1103] also requires missing items, locked collections, and unavailable Secret Service to be distinguished. UsageContext.run returns null for missing commands, failures, and hangs, and the Linux path maps all of these results to no credential. The tests cover missing and failing lookup only; they do not establish locked-keyring handling.

Resolution

Implement distinct Linux Secret Service result handling for a missing item, a locked collection, and an unavailable or failed service. Preserve the existing no-error behavior where required, and add regression tests for each distinct result, including a locked collection.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Merge pass. A gate reviewer on a different model from the author's reviewed this PR, and I checked it myself.

Approved, no blocking findings.

  • Tests: server/usage.test.ts gives 62 pass, 0 fail, and the typecheck passes.
  • Safe probes, with no real keyring touched:
    • discovery caching;
    • the go-keyring-base64: parse;
    • a missing secret-tool and a non-zero exit, each of which gives no credential and no error;
    • a hung child, which is gone after about 5 s on SIGTERM.
  • Credential handling: Linux reuses the macOS parser, the later-expiry selector and the Antigravity endpoints. No new place logs or sends the token.

Accepted tradeoff: the lookup isn't gated on Antigravity being installed, so every Linux discovery runs secret-tool.

  • libsecret only tries to unlock a matching locked item. A user with no Antigravity item in the keyring therefore gets no unlock prompt.
  • A user who has the Antigravity item, uses the usage meters, and leaves the login keyring locked (for example with autologin) can see the unlock prompt at most once every 5 min, or every 30 s on a forced refresh. This is the case the PR describes.
  • Follow-up if that bites: skip the lookup unless ~/.gemini/antigravity-cli (or ANTIGRAVITY_APP_DATA_DIR) exists.
  • A hung secret-tool holds the aggregate usage response for up to its 5 s timeout. Other providers discover concurrently.

Not tested against a real GNOME Keyring: the tests inject the secret-tool output, as the macOS tests do for security. Outside contributor #1678 also edits server/usage.ts and will need a rebase.

All required checks are green and no review thread is open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Antigravity usage meter missing on Linux when credentials are stored in GNOME Keyring

1 participant