Skip to content

ccusage opencode hangs on long-lived installs because --since/--until are ignored #1189

Description

@justi

What happened?

The opencode adapter accepts --since / --until at the CLI but ignores them in the loader. The SQLite query has no WHERE clause and the storage/message/*.json loop reads every file. On my install (large opencode.db, a lot of legacy JSON files from before the SQLite migration) ccusage opencode never returns; even bare ccusage gets stuck on the OpenCode loader step.

Steps to reproduce

ccusage opencode --since 2026-05-04 --until 2026-05-10
# never returns

A raw sqlite3 query with WHERE time_created BETWEEN ? AND ? against the same DB returns immediately. The message table already has a time_created index.

Expected behavior

With --since / --until set, the loader should only look at rows/files in that range and return in seconds.

Version

20.0.6

I have a patch + tests ready (it was auto-closed at #1188). Happy to wait for an OK before resubmitting it.

Activity

  1. github-actions commented on May 29, 2026

    @github-actions
    Contributor

    This issue was auto-closed. Issues from new contributors are auto-closed by default.

    Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

    Keep the issue short, concrete, and written in your own voice.

    If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

    See CONTRIBUTING.md.

  2. ryoppippi commented on May 29, 2026

    @ryoppippi
    Member

    i'll check it. thanks

  3. ryoppippi commented on Jun 6, 2026

    @ryoppippi
    Member

    @pullfrog work on this.

  4. pullfrog commented on Jun 6, 2026

    @pullfrog
    Contributor

    Implemented pre-filtering by --since/--until in the opencode loader at rust/crates/ccusage/src/adapter/opencode/loader.rs.

    • extract_message_timestamp quickly pulls the millis timestamp from raw JSON strings without full deserialization
    • timestamp_within_range compares against shared.since/shared.until using the same date-string comparison as filter_loaded_entries_by_date
    • Both the SQLite row loop and JSON file loop skip out-of-range entries before the expensive message_value_to_entry call
    • 6 new tests cover exclusion, inclusion, bracket, and exact-match scenarios
    • All 219 existing tests pass

    PR: #1220

    Task list (6/7 completed)
    • Explore codebase to understand opencode adapter loader and where --since/--until are parsed vs used
    • Add --since/--until filtering to opencode SQLite loader
    • Add --since/--until filtering to opencode JSON file loader
    • Add/update tests for filtered loading
    • Run tests and lint checks
    • Self-review and commit
    • Push branch and create PR

    Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

  5. josephgrice commented on Jun 29, 2026

    @josephgrice

    Any update on this? Mine does not hang when providing --until but it does result in No usage data found.

    Works - npx ccusage daily --since 2026-06-22
    No usage data found - npx ccusage daily --since 2026-06-22 --until 2026-06-26

  6. justi commented on Jun 29, 2026

    @justi
    ContributorAuthor

    @josephgrice
    Author of the issue here. On the opencode side: the fix is up in #1188 - it combines the indexed SQLite time_created push-down with content-based JSON filtering, and it's just waiting on a maintainer "Approve and run" for CI.

    Your case looks like a different one, though: ccusage daily (without an agent name) reads the Claude Code logs, not opencode, so the #1188 fix won't touch it. If --since X --until Y returns "No usage data found" on Claude data while --since X alone works, that sounds like a separate --until handling problem in the default adapter. Might be worth opening a separate issue with your ccusage version so it doesn't get tangled up with the opencode one here.

  7. ryoppippi commented on Jul 27, 2026

    @ryoppippi
    Member

    lgtm

  8. github-actions commented on Jul 27, 2026

    @github-actions
    Contributor

    @justi approved for issues and PRs. Your future issues and PRs will not be auto-closed.

    See CONTRIBUTING.md.

  9. ryoppippi commented on Aug 31, 2026

    @ryoppippi
    Member

    Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.

    Audit result: resolved. A later merged change or the current main implementation covers this request. This item is kept for history and does not need to be reopened.

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

    triage:resolvedResolved by a later change or current implementation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions