Skip to content

Add Antigravity local spend and usage history - #1139

Merged
robinebers merged 8 commits into
mainfrom
codex/antigravity-spend-felixisaac
Aug 24, 2026
Merged

Add Antigravity local spend and usage history#1139
robinebers merged 8 commits into
mainfrom
codex/antigravity-spend-felixisaac

Conversation

@robinebers

@robinebers robinebers commented Aug 24, 2026

Copy link
Copy Markdown
Owner

TL;DR

Add Antigravity usage history, local token counts, and estimated API-equivalent spend to Today, Yesterday, Last 30 Days, and Total Spend. This is the reviewed, hardened replacement for #1058 and preserves @FelixIsaac as the feature commit's Git author.

Fixes #1120.

What was happening

  • Antigravity displayed its Session, Weekly, Claude, and Claude Weekly quotas but never contributed to Total Spend because its token-accounting data was not being scanned.
  • Antigravity's JSONL transcripts contain no token counts; the usable generation records live in local SQLite conversation databases as protobuf blobs.
  • The original contribution correctly identified that data source, but its all-rows SQLite query could expand enormous blobs into memory, its decoder could trap on malformed values, and its pricing overrides conflicted with existing catalog rates.

What this changes

  • Read generation records from ~/.gemini/antigravity-cli/conversations/*.db in bounded SQLite batches and decode only the protobuf fields needed for model names, timestamps, billable system-prompt and input tokens, output tokens, and cached tokens.
  • Keep previously decoded conversation history directly on the scanner actor and read only newly appended generation rows on refresh, including changes written to SQLite WAL files.
  • Add Antigravity's Usage Trend, Today, Yesterday, and Last 30 Days metrics, export machine-local usage history, and include Antigravity in the Total Spend card.
  • Enable the new metrics by default, keep Usage Trend above the fold, place spend rows On Demand, and preserve existing menu-bar pins.
  • Resolve Antigravity-specific Gemini model variants through the shared pricing supplement without overriding established model rates or inventing prices for unknown models.
  • Warn once for unreadable databases or oversized generation blobs, reject malformed protobuf lengths/counts safely, and document the new provider behavior.
  • Preserve Felix Isaac Lim (@FelixIsaac) as the author of the feature commit and explicitly credit the original contribution in the provider documentation.

Heads-up

  • Antigravity spend is an estimated API-equivalent value derived from measured local token counts; it is not a charge reported by the user's subscription.
  • Generation blobs larger than 1 MiB are skipped with a warning so unusually large conversation snapshots cannot exhaust memory.
  • This replaces closed PR feat(antigravity): add transcript log scanner and cost estimation #1058, whose source branch was deleted.

Tests

  • swift test -Xlinker -rpath -Xlinker /Users/rebers/.codex/worktrees/7bc2/openusage/.build/out/Products/Debug: 1,331 app tests, four CLI tests, and three Swift Testing cases passed; three existing tests were skipped.
  • Added focused coverage for bounded SQL pagination, incremental database and WAL updates, expired-cache eviction, cancellation without partial history, billable system prompts, oversized blobs, malformed protobufs, missing/unpriced models, Gemini aliases, default layout migration, machine-local history classification, and Total Spend aggregation.
  • Validated the bounded read-only SQLite query against a real local Antigravity conversation database without exposing conversation contents.

Screenshots

Before: quota meters only

Before: Antigravity quota meters without spend history

After: quota meters, Usage Trend, and local spend history

After: Antigravity quota meters, usage trend, and Today, Yesterday, and Last 30 Days spend

Thanks to @FelixIsaac for identifying the conversation-database source, reverse-engineering the generation records, and contributing the original implementation in #1058.


Note

Medium Risk
Reads local SQLite conversation DBs and undocumented protobufs, then feeds estimated costs into Total Spend. Bounded queries and skip-on-oversize reduce memory risk, but decoder/pricing mistakes would misreport spend.

Overview
Adds local token usage and estimated API-equivalent spend for Antigravity (Usage Trend, Today, Yesterday, Last 30 Days, and Total Spend). Quota meters stay as they are; spend comes from ~/.gemini/antigravity-cli/conversations/*.db, not JSONL transcripts.

AntigravityDbUsageScanner pages gen_metadata in small SQLite batches, skips blobs over 1 MiB before hex expansion, and incrementally reuses decoded history (including WAL fingerprinting). AntigravityProtoDecoder pulls model, system-prompt + input, output, cache-read, and timestamp fields, treating missing/unpriced models as unknown instead of inventing rates.

Gemini slug aliases in the pricing supplement now cover Antigravity variants (none/a|b|c/preview) without new rate overrides. Default layout enables the new metrics, keeps trend above the fold, and tucks spend rows On Demand.

Reviewed by Cursor Bugbot for commit 2fd4fb0. Bugbot is set up for automated code reviews on this repo. Configure here.

FelixIsaac and others added 2 commits August 24, 2026 10:12
Adapt FelixIsaac’s SQLite/protobuf implementation from PR #1058. Bound conversation reads, reject malformed generation records, preserve canonical Gemini prices, and enable the standard spend/history layout.

Thanks to @FelixIsaac for identifying the conversation database format and contributing the original implementation.

Closes #1120
Render the existing and updated Antigravity cards with OpenUsage’s actual SwiftUI share-card renderer for the visual PR review.
Address automated review on #1139 while preserving FelixIsaac as the original feature author.
Comment thread Sources/OpenUsage/Providers/Antigravity/AntigravityDbUsageScanner.swift Outdated
…ases

Keep FelixIsaac’s original feature authorship while removing redundant cache, decoding, and test machinery.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9118579. Configure here.

Comment thread Sources/OpenUsage/Resources/pricing_supplement.json Outdated
@robinebers robinebers added the gate-passed Passed the automated PR gatekeeper checks (gatekeeper skips it on later runs) label Aug 24, 2026 — with Cursor
@robinebers
robinebers merged commit 7adda61 into main Aug 24, 2026
3 checks passed
@robinebers
robinebers deleted the codex/antigravity-spend-felixisaac branch August 24, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs gate-passed Passed the automated PR gatekeeper checks (gatekeeper skips it on later runs) provider tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Antigravity: estimate Today/Yesterday/30d spend from local conversation DBs

2 participants