fix(usage): show opencode tokens and models on usage page - #1
Open
Mina-Sayed wants to merge 12 commits into
Open
fix(usage): show opencode tokens and models on usage page#1Mina-Sayed wants to merge 12 commits into
Mina-Sayed wants to merge 12 commits into
Conversation
Usage page only scanned claude/codex/grok transcripts, so opencode sessions showed zero tokens and no model breakdown even though the SDK exposes tokens/cost on every assistant message. The live adapter also never emitted thread.token-usage.updated, so the context window bar stayed empty. - Add opencode to UsageProviderKind and bump USAGE_CONTRACT_VERSION to 6 (compatible since 4) - Add OpenCode presentation for web and mobile - Emit live token usage from OpenCode adapter (message.updated, step-finish parts, session.updated, generic step events) and include usage in turn.completed - Scan opencode's SQLite DB (~/.local/share/opencode/opencode.db) for historical buckets with caching and dedup - Update docs, scan cache guard, and chart tests Verified with real opencode.db (4085 messages) and vp test run for usage, OpenCodeAdapter, and chart suites. Model: muse-spark-1.2-contributor-free Harness: opencode
|
Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔 |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 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 |
- Fix cache double subtraction: opencode input is exclusive of cache, so uncached should be input directly (not input - cache) - Fix session.updated overwriting: session tokens are cumulative, do not emit as thread.token-usage or store for turn.completed - Fix WAL cache staleness: stat now includes opencode.db-wal size/mtime, busting cache on WAL writes - Add V2 session_message table scan alongside legacy message table - Fix null vs empty: preserve readOpenCodeDbRecords null failure, reporting source as failed instead of ok - Thread HostProcessEnvironment into resolveOpenCodeDbPath instead of module-global process.env - Use Path service (path.join/dirname) instead of node:path import, removing suppression comment - Fix as never cast on turn.completed payload, spreading only defined keys with proper typing
- Fix V2 session_message parsing: handle role in type column, nested model.id/providerID, and column times - Fix blocking DB read: use iterate() with setImmediate yields every 100 rows instead of all() - Fix diagnostic suppression comment to include rationale - Add focused tests for parseOpenCodeMessage covering all easy-to-regress behaviors Addresses Macroscope high blocking and Cursor V2 findings
…support # Conflicts: # apps/server/src/provider/Layers/OpenCodeAdapter.ts
…#9292) Co-authored-by: Julius Marminge <julius@mac.lan> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Usage page only scanned claude/codex/grok transcripts, so opencode sessions showed zero tokens and no model breakdown even though the SDK exposes tokens/cost on every assistant message. The live adapter also never emitted thread.token-usage.updated, so the context window bar stayed empty.
How I fixed it:
Verification:
Model: muse-spark-1.2-contributor-free
Harness: opencode