Skip to content

usage: dashboard shows 0 tokens for today with opencode CLI >= 2.0 #262

Closed

Description

@Davedes83

Summary

The usage dashboard shows 0 tokens for today when using opencode CLI >= 2.0, because the CLI SQLite history reader queries the wrong table with a stale providerID filter.

Environment

  • Extension: ltmoerdani.opencode-copilot-chat 0.7.9
  • opencode CLI: 2.0.32
  • OS: Linux (Omarchy)

Reproduction

  1. Use opencode CLI >= 2.0 (which writes sessions to session_v2 table, not message)
  2. Open the usage dashboard in VS Code
  3. "Today" shows 0 tokens despite active CLI usage

Expected Behavior

The dashboard should display today's token usage from the local opencode.db.

Actual Behavior

Today shows 0. The SQL in out/usage/history.js reads from the message table filtering providerID = 'opencode-go', but CLI >= 2.0 writes today's data to session_v2 (with flat columns) and uses providerID = 'opencode'.

Additional Context

The message table still has historical rows (pre-2.0) with providerID = 'opencode', but today's sessions only exist in session_v2. A UNION ALL across both tables resolves it. Patch applied locally and verified working.

Activity

  1. ltmoerdani commented on Oct 20, 2026

    @ltmoerdani
    Owner

    Confirmed and fixed in #263. You were right that the reader was stuck on the old message table — CLI 2.x moved per-message usage into session_message and we weren't reading it.

    One thing on the patch from the issue: I had to change the approach, because on a migrated database session_v2 holds one aggregated row per session (its Go total equals the per-message total), so UNION ALL against it doubles every dollar and token. Measured on my own DB: $5.34 reported vs $2.67 actual. The providerID = 'opencode' filter also picks up Zen free-model usage — Go rows use opencode-go. What shipped instead: a UNION over message + session_message (deduplicated by row), with the cwd joined from session_v2.directory, plus a fallback for fresh 2.x installs that never had the legacy table.

    The fix lands in v0.7.10 — it'll reach you through the normal extension update once we publish, no settings change needed on your side.

    Happy to hear you'd already patched it locally — the table layout in your report saved me some schema archaeology. If the numbers look off after v0.7.10, ping this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions