OpenCode

OpenCode usage not showing: 5 fixes

OpenCode usage missing from the CLI or a tracker? Five causes, from the wrong XDG path to a version that moved from JSON to SQLite.

Quick answer

Find the data directory first: `~/.local/share/opencode` on macOS and Linux, `%APPDATA%\opencode` on Windows, or under `XDG_DATA_HOME`. If it is empty, OpenCode has not written a session or is using another path. If it has data, the reader is pointed at the wrong file or the wrong schema version.

Five causes

  1. XDG_DATA_HOME is set, so the data is not in the default folder.
  2. The app is pointed at storage/ while the version uses opencode.db.
  3. The session is still open and the final fields are not written yet.
  4. A container or WSL install writes to a different filesystem.
  5. File permissions block the reader under another user account.

Check the path

echo $XDG_DATA_HOME
ls -la ~/.local/share/opencode
ls -la ~/.local/share/opencode/storage 2>/dev/null

On Windows, check %APPDATA%\opencode and %LOCALAPPDATA%\opencode. A version upgrade can move or rename the database, so list the folder rather than assuming a filename.

Fix and verify

  • Point the tracker at the folder, not at a guessed file.
  • Restart the app after changing the path.
  • Open one session and confirm the token fields exist.
  • If the schema changed, update the tracker or use the app's newest build.

When OpenCode usage does not appear

SymptomCauseFix
Empty dashboardWrong data directoryPoint the tracker at the right path
Old totalsDatabase locked or cachedRestart, then refresh
Missing recent sessionsCLI running in a containerMount or copy the database
Costs at zeroNo cost field in messagesUse token-based estimates
Partial modelsProvider returned no usageCheck the provider response

Start with the path, because it explains most cases. The database location guide lists the defaults, and UsageAtlas reports which source it read.

Questions, answered

Why does OpenCode show no usage after an update?

The storage format may have changed between JSON files and SQLite. Point the reader at the current data folder and check for a database file.

Does OpenCode delete old sessions?

Not automatically in most versions. Cleanup scripts and reinstalls can remove them.

Can I recover missing OpenCode usage?

Only from a backup of the data folder. Once the records are gone, the token history is gone.

Browse by topic