Skip to content

OpenCode provider returns 0 sessions on fresh install. #346

Closed

Description

@aaguerreberre-indtx

Problem
On a fresh codeburn install (or after clearing ~/.cache/codeburn/session-cache.json), the OpenCode provider reports $0.00 / 0 calls despite having thousands of messages in the database.
Existing users with a pre-populated session cache are unaffected because cached data bypasses the fingerprint step.

Root Cause
SQLite-based providers (OpenCode, Goose) represent discovered sessions as compound paths:
/Users/me/.local/share/opencode/opencode.db:ses_abc123
In parseProviderSources, each source passes through fingerprintFile2(source.path), which calls stat() on the full compound path. No file exists at opencode.db:ses_abc123, so stat throws ENOENT, the function returns null, and the session is silently skipped:

const fp = await fingerprintFile2(source.path);
if (!fp) continue;

Since nothing ever gets parsed, nothing gets cached, and subsequent runs repeat the same failure indefinitely.

Why it's not widely reported
Once sessions are cached in ~/.cache/codeburn/session-cache.json, codeburn serves from cache and never calls fingerprintFile2 again for those entries. Users who:

  • Built up their cache on a prior version before this regression, or
  • Happen to have a populated cache from another install method
    ...never hit this path. Only fresh installs (e.g. Homebrew first-time users) or cache clears expose the bug.

Impact

Suggested Fix
When stat() fails on the full path, strip the :sessionId suffix and stat the underlying DB file:

async function fingerprintFile2(filePath) {
  try {
    const s = await stat21(filePath);
    return { dev: s.dev, ino: s.ino, mtimeMs: s.mtimeMs, sizeBytes: s.size };
  } catch {
    const colonIdx = filePath.lastIndexOf(':');
    if (colonIdx > 0) {
      const dbPart = filePath.slice(0, colonIdx);
      try {
        const s = await stat21(dbPart);
        return { dev: s.dev, ino: s.ino, mtimeMs: s.mtimeMs, sizeBytes: s.size };
      } catch {
        return null;
      }
    }
    return null;
  }
}

Reproduction

  1. Install codeburn 0.9.9 fresh (e.g. brew install codeburn)
  2. Ensure ~/.cache/codeburn/session-cache.json has no pre-existing opencode entries (or delete it)
  3. Have OpenCode data at ~/.local/share/opencode/opencode.db
  4. Run codeburn status --provider opencode → $0.00, 0 calls
  5. Apply the fix → shows actual usage

Environment

  • codeburn 0.9.9 (Homebrew)
  • Node.js v26.0.0
  • macOS
  • OpenCode DB: 5000+ messages, 100+ sessions

Activity

  1. added a commit that references this issue on May 18, 2026
    303c945
  2. iamtoruk commented on May 18, 2026

    @iamtoruk
    Member

    Fixed in #347. The compound paths that SQLite providers (OpenCode, Goose) use for session discovery were failing stat() on fresh installs since no file exists at db.path:sessionId. Now falls back to stat on the DB file itself.

    Please retry on main and let us know if it works for you.

  3. aaguerreberre-indtx commented on May 18, 2026

    @aaguerreberre-indtx
    Author

    It worked.

    Thank you!

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions