Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

fix(antigravity): unify local sources and parse CLI model labels - #75

Merged
makoMakoGo merged 4 commits into
personal/local-clientsfrom
fix/antigravity-weird-bug
Jun 23, 2026
Merged

fix(antigravity): unify local sources and parse CLI model labels#75
makoMakoGo merged 4 commits into
personal/local-clientsfrom
fix/antigravity-weird-bug

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented Jun 23, 2026

Copy link
Copy Markdown
Owner

What changed

  • Unify Antigravity IDE cache and Antigravity CLI SQLite usage under the single antigravity local source.
  • Parse Antigravity CLI model IDs from the user-visible model label instead of backend route aliases like gemini-pro-c.
  • Keep CLI database rows in the existing local adapter/cache pipeline, including fresh and warm-cache finalization.
  • Regenerate frontend client registry and update README references for the unified Antigravity source.

Why

Antigravity IDE and CLI are the same product surface for local usage reporting, matching the Kiro/Kiro CLI treatment. The CLI database stores backend route IDs that are not stable user-facing model IDs, so local reports should derive the model from the verified display label field.

Related cleanup issue: #74

Validation

  • cargo fmt --check
  • cargo clippy --locked --workspace --all-features -- -D warnings
  • cargo test --locked --workspace --all-features
  • cargo test -p tokscale-core antigravity --locked --all-features
  • cargo test -p tokscale-core pricing --locked --all-features
  • cargo test -p tokscale-core parse_all_messages_with_pricing --locked --all-features
  • Installed release binary locally and verified Antigravity reports no longer emit gemini-pro-c.

Summary by cubic

Unified Antigravity IDE cache and CLI into a single antigravity client, canonicalizing CLI models from display labels and preserving rows with unknown labels as unknown. Legacy antigravity-cli paths and settings continue to be scanned under antigravity.

  • Bug Fixes

    • CLI derives model IDs from display labels (e.g., “Gemini 3.5 Flash (Medium)”) and keeps unrecognized labels as unknown (no pricing); backend aliases like gemini-pro-c are no longer emitted.
    • IDE cache and CLI DB share one adapter under antigravity; cross-source dedupe uses shared response IDs.
  • Migration

    • Use --client antigravity; --client antigravity-cli is rejected. Persisted defaults of antigravity-cli are mapped to antigravity.
    • Existing custom roots still work: scannerSettings.extra_scan_paths.antigravity-cli and TOKSCALE_EXTRA_DIRS entries like antigravity-cli:/path are recognized by the unified adapter.
    • IDE still syncs via tokscale antigravity sync; CLI DB needs no sync. Both report as antigravity.
    • Cache schemas bumped (TUI 21; core message cache 30); refresh happens on next run.

Written for commit eb7af92. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

发布说明

  • 新功能

    • Antigravity 客户端现已整合 IDE 缓存和 CLI 会话数据支持。
  • 改进

    • 简化了客户端配置,将 Antigravity IDE 和 CLI 功能统一为单一客户端。
    • 增强了数据源发现和跨来源去重处理。
  • 文档

    • 更新说明文档,反映 Antigravity 统一的数据源支持。

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

antigravity-cli 从独立客户端合并进统一的 antigravity 客户端。新增 AntigravityAdapter 同时发现 IDE 缓存 jsonl 与 CLI SQLite 两类数据源,更新 display_model 规范化解析逻辑(从 field 21 提取),移除 AntigravityCliAdapterNonCachedFileAdapter 及所有 antigravity-cli 注册条目,并同步更新缓存版本常量与文档。

Changes

Antigravity 客户端合并

Layer / File(s) Summary
SourceUnitMeta 新变体与客户端注册表移除
crates/tokscale-core/src/adapters/mod.rs, crates/tokscale-core/client-catalog.json, packages/frontend/src/lib/clientRegistry.generated.ts, crates/tokscale-core/src/local_clients.rs, crates/tokscale-core/src/message_cache.rs, crates/tokscale-cli/src/tui/cache.rs
SourceUnitMeta 新增 AntigravityCacheJsonlAntigravityCliSqlite;从 client-catalog.json、前端生成注册表、LOCAL_CLIENTS 移除 antigravity-cli 条目;消息缓存 schema 版本 27→30,TUI 缓存版本 18→21。
antigravity_cli.rs:display_model 规范化解析
crates/tokscale-core/src/sessions/antigravity_cli.rs
模型解析切换为从 protobuf field 21 读取 display_model,经 canonical_antigravity_display_model 严格规范化;缺失时保留 token 并输出 unknownUnifiedMessage.client"antigravity-cli" 改为 "antigravity";全部相关测试同步更新。
response_dedup_key 辅助函数
crates/tokscale-core/src/sessions/antigravity.rs
新增 response_dedup_keyantigravity:{response_id} 哈希封装为统一入口,usage 行解析与测试中的去重键构造均切换为调用该函数。
AntigravityAdapter 实现(发现 + 解析 + 折叠)
crates/tokscale-core/src/adapters/antigravity.rs
新增 AntigravityAdapter 同时发现 IDE jsonl 与 CLI SQLite;fold 使用跨单元共享 HashSet 去重;antigravity_extra_roots 聚合 legacy extra_scan_pathsTOKSCALE_EXTRA_DIRS;附带完整发现与折叠单元测试。
移除旧适配器(AntigravityCliAdapter 与 NonCachedFileAdapter)
crates/tokscale-core/src/adapters/mod.rs, crates/tokscale-core/src/adapters/file.rs, crates/tokscale-core/src/adapters/antigravity_cli.rs
删除 AntigravityCliAdapterNonCachedFileAdapter 及原 ANTIGRAVITY_ADAPTER 静态实例;mod.rs 模块声明从 antigravity_cli 切换为 antigravityLOCAL_SOURCE_ADAPTERS 替换注册项。
其他适配器 match 分支补全(Kiro / OpenCode)
crates/tokscale-core/src/adapters/kiro.rs, crates/tokscale-core/src/adapters/opencode.rs
KiroAdapter::parseOpenCodeAdapter::parsematch unit.meta 中,将新增的两个 meta 变体纳入 unreachable! 分支,确保穷举匹配。
CLI 层:legacy antigravity-cli 路径映射与聚合
crates/tokscale-cli/src/main.rs, crates/tokscale-core/src/clients.rs
parse_default_client_filters 新增将 settings.json 中 antigravity-cli 映射为 ClientId::Antigravity 的逻辑;新增 antigravity_cli_conversations_pathparse_legacy_antigravity_cli_extra_dirs 辅助函数;新增 clap 拒绝与默认值映射的相关测试。
README 文档更新(中英文)
README.md, README.zh-cn.md
将客户端表格、功能列表、Windows 数据位置表与数据源章节中的 IDE 缓存与 CLI 条目合并为统一的 antigravity 描述。

Sequence Diagram(s)

sequenceDiagram
  rect rgba(173, 216, 230, 0.5)
    Note over tokscale-cli, AntigravityAdapter: 新的统一发现与解析流程
  end
  participant CLI as tokscale-cli
  participant Adapter as AntigravityAdapter
  participant IDECache as IDE 缓存 sessions/*.jsonl
  participant CLISQL as CLI SQLite conversations/*.db
  participant AntParser as sessions/antigravity (jsonl 解析)
  participant CliParser as sessions/antigravity_cli (sqlite 解析)
  participant Dedup as 跨单元 HashSet 去重

  CLI->>Adapter: discover(ctx)
  Adapter->>IDECache: 扫描 → SourceUnit{AntigravityCacheJsonl}
  Adapter->>CLISQL: 扫描(GEMINI_CLI_HOME fallback) → SourceUnit{AntigravityCliSqlite}
  Adapter-->>CLI: Vec<SourceUnit>

  CLI->>Adapter: parse(units)
  Adapter->>AntParser: parse_unit(AntigravityCacheJsonl)
  Adapter->>CliParser: parse_unit(AntigravityCliSqlite) + canonical_antigravity_display_model(field 21)
  Adapter-->>CLI: Vec<ParsedUnit>

  CLI->>Adapter: fold(units)
  Adapter->>Dedup: resolve_messages + response_dedup_key 去重
  Dedup-->>CLI: MessageSink (client="antigravity")
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • makoMakoGo/tokscale#60:该 PR 建立了 crates/tokscale-core/src/adapters/* 适配器管道与注册基础设施,本 PR 在同一 adapters/mod.rs 中将 antigravity_cli 注册项切换为新的 antigravity 适配器。

Poem

🐰 两路数据化为一,
IDE 缓存与 CLI 同归,
antigravity 统一旗帜飘,
display_model 严格规范化,
小兔跳过旧代码堆,
合并完毕,schema 版本升! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR标题准确总结了主要变更:统一Antigravity本地源并解析CLI模型标签,与raw_summary和pr_objectives完全对应。
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/antigravity-weird-bug

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.

@makoMakoGo
makoMakoGo marked this pull request as ready for review June 23, 2026 16:22
@makoMakoGo

Copy link
Copy Markdown
Owner Author

/juya review

@codspeed-hq

codspeed-hq Bot commented Jun 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing fix/antigravity-weird-bug (eb7af92) with personal/local-clients (e36da03)

Open in CodSpeed

@juya-review-bot juya-review-bot 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.

OpenCodeReview found 1 issue(s).

Comment thread crates/tokscale-core/src/sessions/antigravity_cli.rs Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/tokscale-core/src/sessions/antigravity_cli.rs`:
- Around line 143-184: The canonical_antigravity_display_model function silently
returns None when a display_model value does not match any expected pattern (in
the wildcard arm at line 183), which can hide data loss in billing records. Add
debug logging to capture the unrecognized display_model values when the function
returns None in the wildcard pattern match case, so that unexpected formats or
new models that need to be added to the whitelist can be identified and tracked
instead of being silently discarded.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d6af0833-afb4-45c5-84bb-5d3c2c1120d6

📥 Commits

Reviewing files that changed from the base of the PR and between e36da03 and d8d5867.

📒 Files selected for processing (16)
  • README.md
  • README.zh-cn.md
  • crates/tokscale-cli/src/main.rs
  • crates/tokscale-cli/src/tui/cache.rs
  • crates/tokscale-core/client-catalog.json
  • crates/tokscale-core/src/adapters/antigravity.rs
  • crates/tokscale-core/src/adapters/antigravity_cli.rs
  • crates/tokscale-core/src/adapters/file.rs
  • crates/tokscale-core/src/adapters/kiro.rs
  • crates/tokscale-core/src/adapters/mod.rs
  • crates/tokscale-core/src/adapters/opencode.rs
  • crates/tokscale-core/src/clients.rs
  • crates/tokscale-core/src/local_clients.rs
  • crates/tokscale-core/src/message_cache.rs
  • crates/tokscale-core/src/sessions/antigravity_cli.rs
  • packages/frontend/src/lib/clientRegistry.generated.ts
💤 Files with no reviewable changes (4)
  • crates/tokscale-core/client-catalog.json
  • crates/tokscale-core/src/adapters/antigravity_cli.rs
  • packages/frontend/src/lib/clientRegistry.generated.ts
  • crates/tokscale-core/src/local_clients.rs

Comment thread crates/tokscale-core/src/sessions/antigravity_cli.rs

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 16 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/tokscale-core/src/sessions/antigravity_cli.rs">

<violation number="1" location="crates/tokscale-core/src/sessions/antigravity_cli.rs:126">
P1: Client ID was unified to antigravity, but CLI dedup keys still use an antigravity-cli prefix. Shared response IDs from IDE cache and CLI DB will be treated as different messages and double-counted.</violation>
</file>

<file name="crates/tokscale-core/src/adapters/antigravity.rs">

<violation number="1" location="crates/tokscale-core/src/adapters/antigravity.rs:84">
P2: Unified Antigravity flow can double-count usage when the same response exists in IDE cache and CLI DB. Add cross-unit dedupe in this adapter and align dedup-key format across both parsers.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread crates/tokscale-core/src/sessions/antigravity_cli.rs
Comment thread crates/tokscale-core/src/adapters/antigravity.rs Outdated
@makoMakoGo
makoMakoGo force-pushed the fix/antigravity-weird-bug branch from d8d5867 to 4d06961 Compare June 23, 2026 16:47
@makoMakoGo

Copy link
Copy Markdown
Owner Author

Follow-up commit 831f517 addresses the remaining review items:

  • Antigravity CLI rows with nonzero usage are no longer dropped when the display label is missing or newly introduced; they are preserved as unpriced unknown rows with a warning, without falling back to backend aliases like gemini-pro-c.
  • Antigravity custom roots now scan both IDE JSONL and CLI SQLite sources, so scanner.extraScanPaths.antigravity and TOKSCALE_EXTRA_DIRS=antigravity:... work for archived CLI DBs.
  • Persisted settings defaultClients entries using the removed antigravity-cli id migrate to antigravity, while new --client antigravity-cli CLI usage remains rejected.
  • tokscale clients now lists the Antigravity CLI conversations directory as an additional Antigravity path.

The CodeRabbit docstring-coverage warning is intentionally not addressed here: it is not a repository CI gate, and broad docstring churn would be unrelated to this Antigravity behavior fix.

Validation run locally: cargo fmt --check; cargo clippy --locked --workspace --all-features -- -D warnings; cargo test --locked --workspace --all-features.

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 3 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread crates/tokscale-cli/src/main.rs Outdated
@makoMakoGo

Copy link
Copy Markdown
Owner Author

Follow-up commit 3523cbf addresses the re-review findings:

  • Bumped source-message cache schema from 29 to 30 so cached Antigravity CLI rows with the old dedup namespace or missing unknown-label rows are reparsed.
  • Bumped TUI cache schema from 20 to 21 so upgraded TUI views refresh immediately after the source-message cache behavior change.
  • Aligned the Antigravity CLI conversations path helper with scanner path resolution by using the shared PathRoot::EnvVar resolver; blank GEMINI_CLI_HOME now falls back to /home/travis/.gemini.

Validation run locally: cargo fmt --check; cargo clippy --locked --workspace --all-features -- -D warnings; cargo test --locked --workspace --all-features.

@makoMakoGo makoMakoGo left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

复审通过,未发现新的阻塞问题。

已检查 3523cbf4 的增量:

  • source-message cache schema 已从 29 升至 30,可强制重建旧的 Antigravity CLI parser/dedup 缓存;
  • TUI cache schema 已从 20 升至 21,避免继续展示旧聚合结果;
  • antigravity_cli_conversations_path() 复用了 core 的 PathRoot::EnvVar 解析,与 scanner 对缺失、空串和纯空白 GEMINI_CLI_HOME 的行为一致;
  • 空白 env 回归测试覆盖了该分支。

当前所有 review threads 均已 resolved。代码层面 LGTM。提交 review 时 Frontend CI、Test & Coverage、Core CI、CodSpeed 已通过,Build Native (Test Only) 仍在运行。

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/tokscale-cli/src/main.rs`:
- Around line 3406-3426: The settings path source inconsistency between core
scanning and CLI display needs to be resolved by ensuring the
run_clients_command function handles the "antigravity-cli" key from
scanner_settings.extra_scan_paths just like the core AntigravityAdapter does.
Currently, the CLI layer ignores paths stored under the "antigravity-cli" key
because ClientId::from_str("antigravity-cli") returns None, while the core
adapter reads this key directly. Update the ClientId::Antigravity branch in the
client display logic to explicitly retrieve and extend extra_paths with entries
from scanner_settings.extra_scan_paths.get("antigravity-cli") before combining
with legacy environment variable paths, ensuring all path sources are displayed
consistently with what the core scanner actually uses.

In `@crates/tokscale-cli/src/tui/cache.rs`:
- Line 973: The test fixture at line 973 hardcodes schemaVersion to 20, but the
actual SCHEMA_VERSION constant is 21 (defined at line 25). This causes
load_cache to return early at the schema validation check (line 650) before
reaching the group_by comparison branch (line 663) that the test is intended to
verify. Change the hardcoded schemaVersion value from 20 to 21 in the fixture so
that the schema version check passes and the test can actually exercise and
validate the group_by comparison logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5e4ed4be-7eee-4acd-a9fe-390851bea98c

📥 Commits

Reviewing files that changed from the base of the PR and between d8d5867 and 3523cbf.

📒 Files selected for processing (17)
  • README.md
  • README.zh-cn.md
  • crates/tokscale-cli/src/main.rs
  • crates/tokscale-cli/src/tui/cache.rs
  • crates/tokscale-core/client-catalog.json
  • crates/tokscale-core/src/adapters/antigravity.rs
  • crates/tokscale-core/src/adapters/antigravity_cli.rs
  • crates/tokscale-core/src/adapters/file.rs
  • crates/tokscale-core/src/adapters/kiro.rs
  • crates/tokscale-core/src/adapters/mod.rs
  • crates/tokscale-core/src/adapters/opencode.rs
  • crates/tokscale-core/src/clients.rs
  • crates/tokscale-core/src/local_clients.rs
  • crates/tokscale-core/src/message_cache.rs
  • crates/tokscale-core/src/sessions/antigravity.rs
  • crates/tokscale-core/src/sessions/antigravity_cli.rs
  • packages/frontend/src/lib/clientRegistry.generated.ts
💤 Files with no reviewable changes (4)
  • crates/tokscale-core/src/local_clients.rs
  • crates/tokscale-core/client-catalog.json
  • packages/frontend/src/lib/clientRegistry.generated.ts
  • crates/tokscale-core/src/adapters/antigravity_cli.rs
✅ Files skipped from review due to trivial changes (2)
  • crates/tokscale-core/src/clients.rs
  • README.zh-cn.md
🚧 Files skipped from review as they are similar to previous changes (5)
  • crates/tokscale-core/src/adapters/opencode.rs
  • crates/tokscale-core/src/message_cache.rs
  • crates/tokscale-core/src/adapters/kiro.rs
  • crates/tokscale-core/src/adapters/file.rs
  • crates/tokscale-core/src/adapters/mod.rs

Comment thread crates/tokscale-cli/src/main.rs
Comment thread crates/tokscale-cli/src/tui/cache.rs Outdated

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread crates/tokscale-cli/src/tui/cache.rs
@makoMakoGo
makoMakoGo merged commit 14bf6fc into personal/local-clients Jun 23, 2026
11 checks passed
@makoMakoGo
makoMakoGo deleted the fix/antigravity-weird-bug branch June 25, 2026 12:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant