Skip to content

feat(rate-limits): real Antigravity quota + multi-account switcher - #7952

Open
andrecristodev wants to merge 1 commit into
stablyai:mainfrom
andrecristodev:feat/antigravity-usage-meter
Open

andrecristodev wants to merge 1 commit into
stablyai:mainfrom
andrecristodev:feat/antigravity-usage-meter

Conversation

@andrecristodev

@andrecristodev andrecristodev commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #7996 (Antigravity status-bar slot). That PR mirrored Gemini OAuth usage under provider: 'antigravity'. This PR upgrades it to real Antigravity Code Assist quota, agy keyring credentials, and a multi-account switcher.

Why this is still needed after #7996

#7996 (on main) This PR
Mirrors Gemini usage snapshot Fetches Code Assist with ideType: ANTIGRAVITY
Requires Gemini CLI OAuth opt-in Reads ~/.gemini or OS keyring (gemini:antigravity from agy)
Single-account only Encrypted multi-account store + switcher
Gemini-style bucket labels Family groups: Gemini Models / Claude and GPT models (matches the Antigravity app)

User-visible behavior

  • When agy is on PATH and credentials exist, the Antigravity meter shows real remaining quota + reset window.
  • Popover groups usage into two families (not ~20 near-identical model rows).
  • Accounts section lists stored Google accounts with per-account usage; click to switch (on Windows also rewrites the agy keyring entry so the CLI follows).
  • Manage mode can remove accounts from Orca without breaking agy until the user signs out there.

Security

  • Usage reads are read-only against local credential stores (except explicit user switch → Windows keyring write).
  • Multi-account credentials encrypted at rest via Electron safeStorage (0600 store file).
  • Token blobs for CredWrite go on stdin (base64), never on the command line.
  • Tests use synthetic placeholders only.

Testing

  • Focused vitest: antigravity fetcher/keyring/account-store + visibility + rate-limit types (50 tests)
  • Rebased onto current main after feat(status-bar): Antigravity usage status #7996
  • Local typecheck: no new errors in touched files (pre-existing typescript-api fixture errors remain elsewhere)

Notes for reviewers

  • Status-bar item / PATH gating / defaults from feat(status-bar): Antigravity usage status #7996 are kept; this PR replaces the fetch source and adds accounts UI.
  • Visibility is snapshot-driven (like Kimi): no credentials → no dead -- bar; real data → show meter.
  • Fork PR: please Approve and run workflows if CI is waiting on first-time contributor approval.

X handle: andrecristodev

ELI5

Antigravity usage in the status bar uses real Code Assist quota and keyring credentials instead of only mirroring Gemini. You also get a multi-account switcher so Antigravity accounts are managed like other providers.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change adds Antigravity across main-process rate-limit fetching, account storage, IPC, shared types, renderer state, status-bar UI, settings search entries, and localized copy. It introduces Antigravity credential reading and writing plus quota retrieval with fallback and retry behavior, adds Antigravity account management, and updates status-bar visibility and rendering to show the new provider. Tests were added and updated for keyring parsing, account storage, fetch behavior, and visibility logic.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.84% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning It has a strong summary and testing notes, but it misses required template sections like Screenshots and AI Review Report. Add the missing Screenshots, AI Review Report, Security Audit, and Notes sections, and format Testing to match the template checklist.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: Antigravity quota support plus a multi-account switcher.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/components/settings/appearance-status-bar-search-entries.ts (1)

200-233: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Antigravity i18n keys deviate from the SHA1 auto-key convention used by every sibling entry.

All other entries in this catalog use SHA1-hash keys (e.g. 9dc15020d7, 51b0ccd6a2) generated by the localization sync tooling, but the new antigravity entries use hand-written keys (antigravityTitle, antigravityDescription, antigravityKeyword, antigravityGoogleKeyword). This could confuse pnpm run sync:localization-catalog (e.g. failing to detect that "google" already has key 51b0ccd6a2, resulting in a duplicate string with a different key).

Consider running the sync tool to auto-key these entries like the rest of the catalog, and reuse the existing 51b0ccd6a2 ("google") key instead of introducing antigravityGoogleKeyword.

Source: Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ea1b2fed-cb1d-47a1-b56b-068b6fc200a8

📥 Commits

Reviewing files that changed from the base of the PR and between 8adfef4 and f1b7ec10dc13244307cc6754e2f4612b4ab59c95.

📒 Files selected for processing (27)
  • src/main/rate-limits/antigravity-fetcher.test.ts
  • src/main/rate-limits/antigravity-fetcher.ts
  • src/main/rate-limits/antigravity-keyring.test.ts
  • src/main/rate-limits/antigravity-keyring.ts
  • src/main/rate-limits/service.ts
  • src/main/runtime/rpc/methods/client-ui.ts
  • src/renderer/src/components/settings/appearance-status-bar-search-entries.ts
  • src/renderer/src/components/settings/appearance-status-bar-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-system-entries.ts
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/components/status-bar/status-bar-agent-gating.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/store/slices/rate-limits.ts
  • src/renderer/src/store/slices/ui.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/rate-limit-types.test.ts
  • src/shared/rate-limit-types.ts
  • src/shared/status-bar-defaults.ts
  • src/shared/types.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/rate-limits/service.ts (1)

1310-1349: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy lift

Gate Antigravity account seeding behind CLI detection

refreshAntigravityAccounts() runs on every poll and still reads ~/.gemini/oauth_creds.json, calls Google userinfo, and rewrites antigravity-accounts even when Antigravity is hidden because agy isn’t on PATH. Plumb the same detection state into the service and skip this refresh unless Antigravity is actually available.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f1751ee2-d229-4b18-a117-b3e537998b02

📥 Commits

Reviewing files that changed from the base of the PR and between 2f4a497 and 4db655a.

📒 Files selected for processing (19)
  • src/main/ipc/rate-limits.ts
  • src/main/rate-limits/antigravity-account-store.test.ts
  • src/main/rate-limits/antigravity-account-store.ts
  • src/main/rate-limits/antigravity-fetcher.test.ts
  • src/main/rate-limits/antigravity-fetcher.ts
  • src/main/rate-limits/antigravity-keyring.ts
  • src/main/rate-limits/service.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/store/slices/rate-limits.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/rate-limit-types.test.ts
  • src/shared/rate-limit-types.ts
✅ Files skipped from review due to trivial changes (1)
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/renderer/src/store/slices/rate-limits.ts
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json

Comment thread src/main/rate-limits/antigravity-keyring.ts Outdated
Comment thread src/renderer/src/components/status-bar/StatusBar.tsx Outdated
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@andrecristodev

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Replace the Gemini-mirrored Antigravity snapshot (stablyai#7996) with a real Code
Assist ANTIGRAVITY fetch, OS keyring credential reads (agy), encrypted
multi-account store, and a status-bar account switcher.

Why: stablyai#7996 landed the status-bar slot but mirrored Gemini OAuth usage,
which does not match Antigravity quota and requires Gemini CLI login.
This upgrade reads agy/keyring credentials, groups family limits like
the Antigravity app, and lets users switch Google accounts from Orca.
@andrecristodev
andrecristodev force-pushed the feat/antigravity-usage-meter branch from ec8460d to 8633aac Compare July 11, 2026 14:05
@andrecristodev andrecristodev changed the title feat: add Antigravity usage meter to the status bar feat(rate-limits): real Antigravity quota + multi-account switcher Jul 11, 2026
@andrecristodev

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and reframed as a follow-up to #7996:

  • Real Code Assist ANTIGRAVITY quota (no longer mirrors Gemini)
  • agy OS keyring credential read + encrypted multi-account store
  • Status-bar account switcher (Windows keyring write on switch)

Ready for human review. If Actions are still pending for this fork PR, please approve the workflow runs.

@nwparker

Copy link
Copy Markdown
Contributor

Reviewed current head 8633aace546dbbe4da6db8650e7a7e7f617b0644 for the migration requested in #17345.

P1 — account storage silently falls back to plaintext credentials when OS encryption is unavailable. encryptCredential() returns the token JSON in that case, and upsertAccount() persists it with encrypted: false. The PR description currently promises encrypted credentials at rest without this exception.

I compiled the exact account-store module, supplied a temporary user-data directory and safeStorage.isEncryptionAvailable() === false, then added synthetic credentials. The written account file contained both synthetic access and refresh tokens in plaintext. The temporary store was removed; no real account/keyring data was read or written.

ELI5: on a machine without the required secret-storage service, adding an account silently saves reusable login credentials as readable text. File mode 0600 restricts readers but does not provide the claimed encryption. Account import should refuse persistence with an actionable error when secure storage is unavailable, rather than silently changing its storage guarantee; cover that path in tests.

There is also a migration scope gap: selectAntigravityAccount() changes Orca’s selected record before calling the keyring writer and ignores its boolean result. That writer returns false on non-Windows platforms, so selecting a quota account does not establish that the agy CLI switched identities. The body does mention Windows-only CLI switching, but this cannot yet satisfy #17345’s cross-platform account requirement. Windows write failure also needs to be surfaced rather than presented as a completed switch.

I have not adopted the credential store or switcher. Native /usage in draft #21654 and custom-executable follow-up #21678 avoid owning credential refresh/writeback, but do not provide multi-account support and do not close #17345.

This branch has not been deployed

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants