fix(antigravity): unify local sources and parse CLI model labels - #75
Conversation
Walkthrough将 ChangesAntigravity 客户端合并
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")
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
/juya review |
There was a problem hiding this comment.
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
📒 Files selected for processing (16)
README.mdREADME.zh-cn.mdcrates/tokscale-cli/src/main.rscrates/tokscale-cli/src/tui/cache.rscrates/tokscale-core/client-catalog.jsoncrates/tokscale-core/src/adapters/antigravity.rscrates/tokscale-core/src/adapters/antigravity_cli.rscrates/tokscale-core/src/adapters/file.rscrates/tokscale-core/src/adapters/kiro.rscrates/tokscale-core/src/adapters/mod.rscrates/tokscale-core/src/adapters/opencode.rscrates/tokscale-core/src/clients.rscrates/tokscale-core/src/local_clients.rscrates/tokscale-core/src/message_cache.rscrates/tokscale-core/src/sessions/antigravity_cli.rspackages/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
There was a problem hiding this comment.
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
d8d5867 to
4d06961
Compare
|
Follow-up commit 831f517 addresses the remaining review items:
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. |
There was a problem hiding this comment.
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
|
Follow-up commit 3523cbf addresses the re-review findings:
Validation run locally: cargo fmt --check; cargo clippy --locked --workspace --all-features -- -D warnings; cargo test --locked --workspace --all-features. |
makoMakoGo
left a comment
There was a problem hiding this comment.
复审通过,未发现新的阻塞问题。
已检查 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) 仍在运行。
There was a problem hiding this comment.
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
📒 Files selected for processing (17)
README.mdREADME.zh-cn.mdcrates/tokscale-cli/src/main.rscrates/tokscale-cli/src/tui/cache.rscrates/tokscale-core/client-catalog.jsoncrates/tokscale-core/src/adapters/antigravity.rscrates/tokscale-core/src/adapters/antigravity_cli.rscrates/tokscale-core/src/adapters/file.rscrates/tokscale-core/src/adapters/kiro.rscrates/tokscale-core/src/adapters/mod.rscrates/tokscale-core/src/adapters/opencode.rscrates/tokscale-core/src/clients.rscrates/tokscale-core/src/local_clients.rscrates/tokscale-core/src/message_cache.rscrates/tokscale-core/src/sessions/antigravity.rscrates/tokscale-core/src/sessions/antigravity_cli.rspackages/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
There was a problem hiding this comment.
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
What changed
antigravitylocal source.gemini-pro-c.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 --checkcargo clippy --locked --workspace --all-features -- -D warningscargo test --locked --workspace --all-featurescargo test -p tokscale-core antigravity --locked --all-featurescargo test -p tokscale-core pricing --locked --all-featurescargo test -p tokscale-core parse_all_messages_with_pricing --locked --all-featuresgemini-pro-c.Summary by cubic
Unified Antigravity IDE cache and CLI into a single
antigravityclient, canonicalizing CLI models from display labels and preserving rows with unknown labels asunknown. Legacyantigravity-clipaths and settings continue to be scanned underantigravity.Bug Fixes
unknown(no pricing); backend aliases likegemini-pro-care no longer emitted.antigravity; cross-source dedupe uses shared response IDs.Migration
--client antigravity;--client antigravity-cliis rejected. Persisted defaults ofantigravity-cliare mapped toantigravity.scannerSettings.extra_scan_paths.antigravity-cliandTOKSCALE_EXTRA_DIRSentries likeantigravity-cli:/pathare recognized by the unified adapter.tokscale antigravity sync; CLI DB needs no sync. Both report asantigravity.Written for commit eb7af92. Summary will update on new commits.
Summary by CodeRabbit
发布说明
新功能
改进
文档