Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
Reviewed by Codex gpt-6-luna (xhigh); verified and validated by Claude Thermo-nuclear review of #671 (OpenCode Go recorded local token counts). Findings:
Everything else matches the spec: the query and step-finish precedence, recorded-cost handling, daily and per-model aggregates, siloing, and test coverage. No locale, accessibility or bridge-type changes were needed. |
|
Follow-up: both findings above are fixed and pushed. Nothing left open. The one visible effect: the OpenCode Go 7-day and 30-day token columns in Usage & Spend now show "unknown" instead of a partial sum when some rows lack input or output counts. No layout or copy changed. Commands run (Rust 1.98.0, E-cores): |
Port review: OpenCode Go local token counts (#671, GAP-40 / 0.67.0 item 17)Reviewed the branch diff What I checked:
Result: no findings. The port matches the upstream semantics on the SQL guard, precedence, resolved-total rule, validity rule and never-invent-zero aggregation, with costs untouched. Files under the cap (tokens.rs 187, tokens_tests.rs 278, local.rs +49). No dependency, locale, bridge-shape or UI change; the UI already renders token columns for providers that have them. |
…ounts Conflict in rust/src/cost_scanner.rs: the release scanner resolves windows from its reporting period (calendar_window) and replaced get_claude_projects_dir with claude_projects_roots. The OpenCode Go summary helper now scans calendar_window(now, None).days, and the release Claude roots helper is kept next to scan_opencodego_usage_tokens_with_cancel. usage_spend.rs: the release cached_spend takes the reporting period; the OpenCode Go arm also fills period_tokens from the local history (7d/30d reuse the fixed scans, other periods scan once), like Grok and Antigravity.
Summary
OpenCode Go's local SQLite reader now reads the recorded
tokensobject, so daily and per-model local history carry tokens. Costs stay the recordedcostfield and are never derived from tokens.json_extract(data,'$.tokens')only whenjson_type(data,'$.tokens') = 'object'. Step-finish parts keep precedence over their parent message (no double count); message rows are used when no step-finish exists, as before.providers/opencodego/tokens.rs:RowTokens::parsedeserializes{total, input, output, reasoning, cache:{read, write}}with#[derive(Deserialize)].resolved_total = total, else the checked sum of the five components only when all five are present. A row is usable only when every present count (includingtotal) is >= 0 and a total resolves. Malformed JSON, non-integer counts, or overflow leave the row's tokens unknown (never zero).TokenSumsaggregates per day+model (DailyModelCost.tokens), per model, and per window (ModelCostSummary). It tracks completeness separately: any row without usable tokens makescomplete_total()/complete_reasoning()returnNone, while class sums keep what rows did record.CostScanner::scan_opencodego_with_cancelnow fillsinput_tokens,output_tokens,cached_tokens,reasoning_tokens(Some only when every row reports it) andby_model_tokens. Models with no usable row get noby_model_tokensentry.Upstream reference
opencodego-local-tokens.Sources/CodexBarCore/Providers/OpenCodeGo/[email protected](providerMessagesSQL,messageAndPartUsageSQL,TokenCounts,resolvedTotal,isValid,dailyEntries).OpenCodeGoLocalUsageReaderTests(daily entries carry message token counts per day and model):{"total":1600,"input":100,"output":20,"reasoning":30,"cache":{"read":1400,"write":50}}and the older no-total row{"input":10,"output":5,"reasoning":1,"cache":{"read":4,"write":0}}; expected day totals 1620 total / 110 input / 25 output / 31 reasoning / 1404 cache read / 50 cache write.Ported / Deferred
Ported: everything in the spec above.
Notes and deferrals:
CostSummaryandModelTokenCountshave no cache-write class, socached_tokens= cache read + cache write (the existing Claude/Pi convention). The exact read/write split andtotallive onTokenSums(daily / per-model / window) but are not surfaced in the shared summary; adding a cache-write field to the shared structs would touch every scanner and is left out of this micro PR.CostSummary.input_tokens/output_tokens/cached_tokensare plainu64, so a window with unusable rows shows the sum of the usable rows (andreasoning_tokens = None) rather than a distinct "unknown"; a model with no usable row is omitted fromby_model_tokens. The complete/unknown distinction is exact onTokenSums.daily_cost_series) still feeds cost only; there is no per-day token consumer on Windows yet.local.rswas already over 1000 lines (1229) before this PR; the new logic and tests live intokens.rsandlocal/tokens_tests.rs, andlocal.rsgrows by ~35 lines of query/plumbing.Validation
Toolchain
cargo +1.98.0, E-core wrappers, slot-3 target dir.cargo +1.98.0 fmt --all: cleancargo +1.98.0 clippy --workspace --all-targets -- -D warnings: passcargo +1.98.0 test -p codexbar opencodego -- --test-threads=4: 51 passed (7 new token tests + existing)cargo +1.98.0 test -p codexbar -- --test-threads=4(full, cost_scanner touched): 2167 passed, 0 failed, 1 ignoredcargo +1.98.0 test -p codexbar-desktop-tauri usage_spend -- --test-threads=4: 6 passed (1 new)New tests cover: total vs component-sum resolution, negative/malformed/non-integer/overflow rows, the upstream two-message day fixture, step-finish precedence over parent message tokens, message fallback, day/window incompleteness with unusable rows, per-model summaries, and the Usage & Spend unknown-vs-zero guard.
Affected areas
rust/src/providers/opencodego,cost_scanner.rs)usage_spend.rs, value plumbing only)docs/PROVIDERS.md)UI proof
Not applicable (the existing Usage & Spend token columns render the new values; no UI code changed).