Repository navigation
feat(antigravity): plan-usage chip rows for the 5-hour and weekly limits - #870
henriqueleite42 wants to merge 1 commit into
Conversation
The header plan-usage chip gains up to two Antigravity rows, AG Gemini and AG Claude/GPT: Antigravity meters its models in those two groups, each with its own 5-hour and weekly window, which map onto the chip's 5h/7d slots. The numbers come from a running Antigravity language server on this host, over loopback only. Each hub (the Antigravity app or editor extension) registers ~/.gemini/<appDataDir>/daemon/hub_<port>.json with its pid, HTTP port and CSRF token; findAntigravityHubs() keeps the live ones and readAntigravityPlanUsage() asks the first that answers for LanguageServerService/RetrieveUserQuotaSummary, the same snapshot the app's own usage view shows. Codeman never touches the Google sign-in: agy only refreshes its on-disk token in memory, so that file is normally expired, and renewing it would need Antigravity's private OAuth client. Polled every 5 minutes, gated by showPlanUsageLimits like the Codex and Copilot polls, and silent on any failure (no hub, refused, changed shape). parseAntigravityQuotaSummary() is pure and handles proto3 JSON omitting a zero remainingFraction on an exhausted bucket. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you for this, @henriqueleite42, and welcome to Codeman. This PR adds Antigravity's per-group 5-hour and weekly limits to the header plan-usage chip, reading them from a running Antigravity hub on loopback. It follows the Copilot row closely, and the gates, the pure parser with its fixture, and the docs updated alongside the code made it easy to review. The wire routing stays admin-only, as it should. Two things need fixing before it can go in.
One optional change: Everything else passed here: typecheck, lint, format, the frontend checks and the full |
Adds Antigravity to the header plan-usage chip, next to the Claude, Codex and Copilot rows. It follows the shape of the Copilot row from #662. I didn't find an existing issue or PR for this, so I'm opening the PR directly and I'm happy to move the design question to a Discussion if you'd rather.
What it shows
Antigravity meters its models in two groups, and each group has its own 5-hour and weekly limit. That maps onto the chip's existing
5h/7dwindows, so the chip gets up to two rows:The tooltip gives the reset time of each window. The labels are fixed literals (
AG Gemini,AG Claude/GPT, short formsAG/AC). Server-supplied group names are never rendered.Where the numbers come from
agyhas no scriptable usage command. It also refreshes its sign-in token only in memory, so~/.gemini/jetski-standalone-oauth-tokenon disk is normally expired. Renewing that token would mean shipping Antigravity's private OAuth client credentials, so this PR doesn't touch it.Instead it asks a running Antigravity language server, which already holds a live sign-in:
~/.gemini/<appDataDir>/daemon/hub_<port>.jsonwith{ pid, httpPort, csrfToken }. Hubs leave the file behind when they exit, sofindAntigravityHubs()keeps only files whose pid is alive, sorts newest first and bounds the scan.readAntigravityPlanUsage()POSTs Connect JSON tohttp://127.0.0.1:<httpPort>/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummarywith that hub'sX-Codeium-Csrf-Token. It usesredirect: 'error'and a 5 s timeout, and tries at most three hubs. This is the same snapshot the Antigravity app's own usage view reads.parseAntigravityQuotaSummary()(pure, inusage-telemetry.ts) maps buckets by id prefix (gemini-*,3p-*), falling back to the group name, intoantigravity.{gemini,thirdParty}. Each value is a normal 5h/7dStatusTelemetry. proto3 JSON omits a zero, so an exhausted bucket arrives with noremainingFraction. When it still has aresetTime, the parser reads it as 100% used.Nothing leaves the host: the request goes to loopback only, and the CSRF token is never logged, stored or broadcast. The FAQ and Security "no phone-home" text therefore stays accurate.
Wiring
refreshAntigravityPlanUsage()inserver.tspolls every 5 minutes. Like the Codex and Copilot polls, it is off undertestMode.readAntigravityPlanUsageIfEnabled()checksshowPlanUsageLimitsfirst, then looks for a live hub. A null result clears the rows.plan-usage-latest.tscarries theantigravitykey across Claude statusline samples. It reuses the existingsession:statusTelemetryevent and init snapshot, so the multi-user admin-only routing applies unchanged.Limitation
Rows appear only while an Antigravity hub is running. The
agyCLI on its own keeps its language server private to each run: the port appears only in its log, and there is no token file. A CLI-only host therefore shows no Antigravity rows. This is documented in the wiki's Antigravity section.Testing
test/antigravity-plan-usage.test.ts. It covers the parser (fixture taken from a live agy 1.5.19 hub), hub discovery against a temp dir, the loopback reader with an injected fetch, and the order of the gates.plan-usage-chip.test.tsandplan-usage-latest.test.ts.typecheck,lint,format:check,check:frontend-syntax,check:frontend-dead,check:browser-excludesandknipare clean, andnpm testpasses.antigravityrows, and Playwright loaded the page and found both rows rendered with the right values and tooltip, with no page errors.Docs: README, wiki (Agent CLIs, Keeping Agents Running, The Dashboard),
CLAUDE.mdandarchitecture-invariants.md. Aminorchangeset is included.🤖 Generated with Claude Code