Repository navigation
Conversation
|
Warning Review limit reachedNext included review available in 11 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 793989ed75eeeff279f8278cdc7e9b042ac161ab and 8d6892d. 📒 Files selected for processing (2)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 47d107c and 793989ed75eeeff279f8278cdc7e9b042ac161ab. 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughOpenCode usage parsing now preserves the raw Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Cache-read tokens are included in OpenCode totals and older cached usage is rescanned. No actionable current-head risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the fix, scope, rationale, linked issue, regression trade-off, and automated test command. However, it does not follow the required template and omits several required sections, including ELI5, What Changed, Why, Visual Proof with an explicit N/A, Testing checkboxes and platform details, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Reformat the description using the repository template. Add the missing required sections, provide an explicit Visual Proof N/A with a reason, document manual testing and supported platforms, complete the testing and checklist items, and include the required cross-platform, SSH, compatibility, security, and performance notes. 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.
Important
The 2 → 3 schema bump invalidates the cache but also resets scanState.enabled to false, silently turning OpenCode usage tracking off for every existing user who had it on. Details inline.
Reviewed changes
- Cache-read tokens counted in totals —
opencode-usage-row-parsing.tsdrops theMath.min(cache.read, inputTokens)cap and setstotalTokens = Math.max(reportedTotal, partsTotal), wherepartsTotalincludescache.read. - Session-table path includes cache reads —
opencode-usage-row-queries.tsaddstokens_cache_readto the materializedtotalit feeds the parser. - Schema bump —
OPENCODE_USAGE_SCHEMA_VERSION2 → 3 so v2 caches are discarded and rescanned. - Tests — parser and database totals updated for the new arithmetic; store test now uses the schema constant and pins mismatch normalization.
I verified the underlying model against OpenCode's current source: persisted tokens.input is the non-cached input count (cache read/write are subtracted out), so cache.read is disjoint and adding it is correct; tokens.total already includes cache when present, which Math.max guards. Tests pass locally (24).
ℹ️ Nitpicks
tokens_cache_writeis still dropped (write: 0in the session-row query and not added topartsTotal), sototalTokensunderstates by the cache-write amount whenevertokens.totalis absent. Issue #21440 called this out; fine to defer, but worth a follow-up if the card is meant to reflect true volume.- The new "does not double-count cache.read when
tokens.totalalready includes it" test cannot fail under the current data model: its fixture haspartsTotal === reportedTotal(1000 + 250 + 100 + 400 = 1750), so an implementation that ignoresreportedTotalentirely still passes. It only rejectsreportedTotal + cachedInputTokens.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Stop capping cache.read at inputTokens, include cache reads in totalTokens, and bump the usage schema so existing caches rescan.
Schema mismatches still discard cached analytics, but scanState.enabled now survives like the Claude and Codex normalizers so existing tracking stays on after upgrade.
793989e to
8d6892d
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The follow-up commit resolves the prior review finding by preserving the persisted OpenCode tracking flag across the v3 schema bump.
- Preserved
scanState.enabledon schema mismatch —persisted-state-normalization.tsnow returns the default state withenabledcarried over from the stale state instead of resetting it tofalse, matching the Claude and Codex normalizers. - Regression test —
store.test.tsseeds a stale state withenabled: trueand asserts it survives normalization; the assertion fails against the previous wholesalegetDefaultState()reset.
The change is correct and the existing tests pass (24). The two previously raised nitpicks (tokens_cache_write omission and the non-falsifiable double-count test) remain author-scoped out and unchanged by this delta.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Closing as superseded by #21886, which includes the cache-write compatibility and regression coverage. |

Description
OpenCode usage totals now include
tokens_cache_readinstead of capping cache reads at input tokens and omitting them fromtotalTokens. Existing caches rescan after a schema bump.Focused fix
cachedInputTokenswithout the input cap, andOPENCODE_USAGE_SCHEMA_VERSION2 → 3.estimatedCostUsd: nulldisplay, Claude/Codex readers, and usage-card UI redesign.Preserves
estimatedCostUsdis unchanged; null free-model cost is not invented.tokens.totalalready includes cache reads, they are not double-counted.Evidence
pnpm exec vitest run --config config/vitest.config.ts src/main/opencode-usage/scanner.test.ts src/main/opencode-usage/store.test.ts src/main/opencode-usage/scanner-windows-data-directory.test.ts(24 tests)upstream/mainpassed.User-regression-tradeoffs
orca-opencode-usage.jsonv2 files are discarded and rescanned.Fixes #21440