Repository navigation
fix(usage): include Gemini quotas from the Antigravity CLI - #1678
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Configurable command timeout server/usage.ts, server/usage.test.ts |
UsageContext.run and runCommand accept an optional timeout. Tests cover timeout behavior, output-size limits, and null-byte output. |
CLI quota parsing and fallback server/usage.ts, server/usage.test.ts, changelog.d/antigravity-gemini-usage.md |
Antigravity runs the configured CLI with a 35-second timeout. The shared parser handles alternate field names for recognized quota buckets. When the CLI result has no usable windows, usage falls back to the quota API. Tests cover successful CLI output and fallback cases. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers: nahwan-kim
Merge Risk: 
Minimal · up to e91f1
-
No confirmed issue remains that should block merging after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description follows the required template. It has the Change section, which explains the Gemini-quota omission, the reproduction on Windows, the fix (HTTP first, CLI only when Gemini is missing, 35-second timeout), the parsing changes, the fallback behavior, the tests, and the changelog fragment. The Validation section lists the test, typecheck, and diff-check results, manual verification, and the CI limits. It does not link an issue, though the template asks for one for features; this change is a bug fix, so the link is not required. The test count (92 passed) differs from the PR objectives (86 passed), so the author should confirm the figure.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- 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.
Comment @coderabbitai help to get the list of available commands.
devswha
left a comment
There was a problem hiding this comment.
Thanks, the parsing is right. I ran agy --print /usage --output-format json --print-timeout 30s with agy 1.4.4: status: SUCCESS, num_turns: 0, zero tokens, and buckets with id / remaining_fraction / reset_time, which matches antigravityWindows. Gemini buckets came through.
One change requested before merge: the CLI call took about 8.3 s here, and UsageService.report() waits on every provider (Promise.all). So every usage refresh for anyone with agy installed now waits 8 s (up to 35 s), even when the HTTP endpoint would answer in under a second. Please ask the HTTP endpoint first and run the CLI only when its answer has no Gemini bucket, or otherwise keep the CLI off the common path.
Minor: AGY_BIN is a new, undocumented knob. Drop it, or name it where the other usage env vars are documented.
|
Thanks for verifying this with agy 1.4.4 and for catching the refresh latency. Addressed both requests in 65aa556:
Added regressions for both HTTP Gemini bucket types, HTTP error handling, HTTP-before-CLI ordering, and missing CLI output. All 92 targeted tests and both TypeScript checks pass on Windows. Full CI/integration/browser suites have not been run locally. |
…#1776) ## 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.
65aa556 to
6a2d3a9
Compare
|
Rechecked the contributor's HTTP-first revision against main
Pushed the verification rebase and the separate Linux test correction together once. The contributor's requested HTTP-first behavior needs no further runtime change. Review prepared with a code-review agent and checked against the code. The merge decision stays with the maintainer's merge pass. |
|
Merge pass review-work report. Overall: PASSED. This is an outside-contributor PR, and the maintainer approved merging it in this pass. The ext-pr-review lane verified it; see its comment above.
Gemini quotas come from the Antigravity CLI, with the HTTP reading tried first.
Follow-ups (MEDIUM/LOW):
CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it. |
Change
Antigravity usage could show only Claude/GPT quotas while omitting Gemini limits. Reproduced on Windows: both direct
retrieveUserQuotaSummaryhosts returned only third-party buckets, whereas the officialagy --print /usage --output-format jsoncommand returned Gemini and third-party buckets for the CLI account. This affects WebUI quota collection, not the Pi Antigravity Bridge plugin.--print-timeout 30s). No new environment variables.Validation
Rebased onto current
main, then checked on Windows with Bun 1.4.3:bun test ./server/usage.test.ts ./src/lib/usage.test.ts ./scripts/changelog-fold.test.ts: 92 passed, 0 failed.bun run typecheck: both application and tooling TypeScript checks passed.git diff --check: passed./api/usagereturned both Gemini windows and both third-party windows without a provider problem.Full CI, integration, and browser suites have not been run locally; fork CI may require maintainer approval. Existing expired-sign-in handling is unchanged. Only HTTP readings missing Gemini quotas incur the additional CLI latency.