Skip to content

fix(antigravity-cli): parse native conversation databases - #13

Open
heixxxa wants to merge 1 commit into
telemetry-dev:mainfrom
heixxxa:fix/antigravity-cli-usage
Open

heixxxa wants to merge 1 commit into
telemetry-dev:mainfrom
heixxxa:fix/antigravity-cli-usage

Conversation

@heixxxa

@heixxxa heixxxa commented Nov 26, 2026

Copy link
Copy Markdown

Problem

Antigravity CLI conversation databases under ~/.gemini/antigravity-cli/conversations/**/*.db do not have a usage_events table. They store generation
metadata as protobuf blobs across gen_metadata, steps, and trajectory_metadata_blob, so the adapter currently returns zero events for every native
database.

In addition, syncUsage only hashes the main .db file when checking for changes and parse stability. For SQLite databases in WAL mode, new commits
written to <db>-wal leave the main database file unchanged until a checkpoint occurs, causing syncs to skip updated databases.

Changes

  • Detect native Antigravity CLI conversation databases (gen_metadata present and usage_events absent) inside a read-only transaction while keeping
    the usage_events fallback unchanged.
  • Bump antigravityCliAdapter.version to 2 so previously synced empty sources are re-parsed automatically.
  • Decode the conversation protobuf metadata without adding dependencies:
    • Extract token counts from gen_metadata (ModelUsageStats), storing response output separately from reasoning tokens (#10, falling back to
      max(0, #3 - #9)).
    • Extract model, provider (google for gemini-*), responseId (identity / dedupKey), and local workspace project path from file:// URIs
      in trajectory_metadata_blob (ignoring remote URIs).
    • Resolve generation timestamps from gen_metadata, matched steps entries by responseId, or trajectory_metadata_blob session time.
  • Update sampleSourceHash in sync.server.ts to incorporate non-empty <db>-wal stat metadata (ino, size, mtimeNs, ctimeNs) for sqlite
    sources so uncheckpointed WAL commits trigger re-sync and stability retries.

Tests

  • Added an end-to-end sync test in src/lib/sync/sync.test.ts covering native Antigravity CLI protobuf parsing, WAL-only commits (wal_autocheckpoint = 0), unchanged skip behavior on re-sync, and extracted token/model/project/timestamp fields.
  • tsc --noEmit, vitest run (17 test files, 126 passed, 1 skipped), prettier --check on modified files, and eslint on antigravity-cli.ts /
    sync.test.ts pass.

Antigravity CLI conversation databases store generation metadata as protobuf blobs in gen_metadata, steps, and trajectory_metadata_blob rather than a usage_events table, so the adapter skipped every native database with zero events.

Parse those native tables inside a read-only transaction while keeping the usage_events fallback, and bump the adapter to version 2 so previously synced sources re-parse. Extract token counts (splitting reasoning out of total output), model, project path from file:// workspace URIs, responseId dedup keys, and generation timestamps from gen_metadata, steps, or session metadata.

Also include non-empty SQLite -wal file stat metadata in sampleSourceHash so sync detects commits that have not been checkpointed into the main database file yet.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 09:17

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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.

2 participants