feat(warp): parse local sqlite token usage - #124
Conversation
Allocate total-only Warp and Grok usage with fixed local-history bucket ratios, document the projection, and remove tracked empty TUI exports.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (5)
Walkthrough本次变更新增Warp本地SQLite解析与适配器接入,加入固定比例的total-only token归因模块并用于Warp与Grok,同时更新本地扫描、CLI行为、模型别名规范和相关文档说明,最后统一升级包版本到4.0.5。 ChangesWarp本地解析与Token固定桶归因
版本号发布提升
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
There was a problem hiding this comment.
2 issues found across 32 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Bump the Grok parser revision for the imputed bucket semantics, batch-round Grok total-only rows per source file, and stop counting Warp aggregate rows as turns.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
crates/tokscale-core/src/model_aliases.rs (1)
476-479: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
is_claude_tier_qualifier目前仅识别"max"当前实现足够满足本 PR 范围(仅 "max"),但如果未来出现其他 tier qualifier(如 "pro"、"plus"),需要记得在此处补充。可考虑用一个常量数组承载,便于扩展。
♻️ 可选的扩展写法
+const CLAUDE_TIER_QUALIFIERS: &[&str] = &["max"]; + fn is_claude_tier_qualifier(value: &str) -> bool { - matches!(value, "max") + CLAUDE_TIER_QUALIFIERS.contains(&value) }🤖 Prompt for 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. In `@crates/tokscale-core/src/model_aliases.rs` around lines 476 - 479, `is_claude_tier_qualifier` 目前只匹配单个字符串,扩展性较差;请在该函数中改为基于一个集中维护的常量集合/数组来判断 tier qualifier,并通过这个符号统一管理 `"max"` 以及未来可能加入的 `"pro"`、`"plus"` 等值,便于后续在 `model_aliases` 中扩展时只改一处。
🤖 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/adapters/warp.rs`:
- Around line 18-37: The Warp adapter discovery currently only scans the default
root from ClientId::Warp.local_def(), so it can miss the actual warp.sqlite
locations on macOS/Linux. Update discover() in warp.rs to add platform-specific
candidate roots before calling adapter_discover::scan_roots, alongside the
existing default_root and extra_roots_for_client handling. Keep the discovery
flow intact, but make sure the added roots cover Warp’s real data locations on
those platforms.
In `@crates/tokscale-core/src/sessions/warp.rs`:
- Around line 260-279: The parse_warp_timestamp helper currently interprets bare
timestamps through chrono::Local, which can shift last_modified_at/start_ts
based on host timezone and DST. Update parse_warp_timestamp in warp.rs so the
non-RFC3339 formats are treated as UTC by converting the parsed NaiveDateTime
with UTC semantics instead of Local, and add a test covering the bare timestamp
branch to verify the UTC millisecond result.
---
Nitpick comments:
In `@crates/tokscale-core/src/model_aliases.rs`:
- Around line 476-479: `is_claude_tier_qualifier`
目前只匹配单个字符串,扩展性较差;请在该函数中改为基于一个集中维护的常量集合/数组来判断 tier qualifier,并通过这个符号统一管理 `"max"`
以及未来可能加入的 `"pro"`、`"plus"` 等值,便于后续在 `model_aliases` 中扩展时只改一处。
🪄 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: 9ad267c0-95b8-405f-904d-88ca2d734b40
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (32)
Cargo.tomlREADME.mdcrates/tokscale-cli/src/commands/shared.rscrates/tokscale-cli/src/commands/wrapped.rscrates/tokscale-cli/src/main_tests.rscrates/tokscale-cli/tokscale-export-20260215-203203.jsoncrates/tokscale-cli/tokscale-export-20260215-203814.jsoncrates/tokscale-cli/tokscale-export-20260215-203901.jsoncrates/tokscale-cli/tokscale-export-20260215-203908.jsoncrates/tokscale-core/src/adapters/file.rscrates/tokscale-core/src/adapters/mod.rscrates/tokscale-core/src/adapters/warp.rscrates/tokscale-core/src/lib.rscrates/tokscale-core/src/local_clients.rscrates/tokscale-core/src/message_cache.rscrates/tokscale-core/src/model_aliases.rscrates/tokscale-core/src/scanner.rscrates/tokscale-core/src/sessions/grok.rscrates/tokscale-core/src/sessions/mod.rscrates/tokscale-core/src/sessions/warp.rscrates/tokscale-core/src/token_imputation.rsdocs/adr/0011-token-derived-local-cost.mddocs/adr/0017-fixed-token-bucket-imputation.mddocs/clients.mddocs/configuration.mddocs/fork.mddocs/pricing.mdpackages/cli-darwin-arm64/package.jsonpackages/cli-linux-x64-gnu/package.jsonpackages/cli-win32-x64-msvc/package.jsonpackages/cli/package.jsonpackages/tokscale/package.json
💤 Files with no reviewable changes (5)
- crates/tokscale-cli/tokscale-export-20260215-203901.json
- crates/tokscale-cli/tokscale-export-20260215-203814.json
- crates/tokscale-cli/tokscale-export-20260215-203203.json
- crates/tokscale-cli/tokscale-export-20260215-203908.json
- crates/tokscale-cli/src/main_tests.rs
Interpret Warp naive SQLite timestamps as UTC and fail fast when total-only batch imputation totals exceed i64::MAX.
Discover Warp databases from the official state-directory locations used by Warp itself, and keep extraScanPaths for cross-system roots such as WSL Windows data.
There was a problem hiding this comment.
1 issue found across 7 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Keep Warp clients diagnostics sessionsPathExists tied to the displayed sessionsPath while alternate roots remain listed separately.
|
/juya review |
Make Warp scan-root platform behavior explicit, cover cross-platform root expectations, and enforce token imputation invariants in release builds.
Summary
warp.sqliteusage from the local source adapter, includingscanner.extraScanPaths.warpi64::MAX, and remove tracked empty TUI export JSON artifactsValidation
cargo fmtcargo clippy --workspace --all-targets -- -D warningscargo test -p tokscale-core --libcargo test -p tokscale-clicargo testcargo build --release -p tokscale-clitokscale --no-spinner --client warp --json --group-by client,provider,modelreports 24 Windows Warp rows and 37,204,845 total tokenstokscale hourly --no-spinner --client warp --jsonreports Warp aggregate rows withturnCount: 0Summary by CodeRabbit
新功能
文档
Bug 修复