Skip to content

[Bug]: Inaccurate Session usage data for Claude in v2.2.1 #96

Closed

Description

@guidi-injenia

Plugin version

2.2.1

Area

DankBar widget

Environment

DMS: dms v2.0.0 (dms-2.0.0-1.1)
Quickshell: 0.3.2 (quickshell-0.3.2-1.24, danklinux repo)
Qt: 6.12.0 (libQt6Qml6-6.12.0-2.1)
Compositor: Hyprland 0.57.0 (Lua config)
Distro: openSUSE Tumbleweed 20261030
Kernel: 7.3.0-1-default
bash: 5.3.20
jq: 1.8.2
curl: 8.23.0
Plugin: aiOverviewControl 2.2.1

Steps to reproduce

just using the widget and claude on cli

Expected behavior

The Session percentage displayed by the widget should reflect the current usage shown in Claude's web interface/account status.

Actual behavior

The Session metric does not match the actual remaining or consumed limit on Claude. It feels like the parsing or tracking logic for the session window might have broken recently (possibly due to an upstream change by Anthropic or something introduced in the latest release).

The weekly metric seems less affected (or at least the deviation is much more noticeable on the Session counter). Has anyone else reported discrepancies with Claude's session tracking on v2.2.1, or could an endpoint/HTML structure change on Claude's end have caused this?

I've tried to reload many times (no errors or something), remove the widget from the bar and adding it again. Same results

Image

Local checks

$ jq . plugin.json >/dev/null && echo ok
ok
$ bash -n providers/get-provider-usage providers/get-copilot-usage providers/get-claude-usage && echo ok
ok

$ ./providers/get-provider-usage "codex,claude,copilot,openrouter" | jq -c '.[] | {provider, source, error, primary: .usage.primary.usedPercent}'
{"provider":"codex","source":"codex-app-server","error":{"code":127,"kind":"runtime","message":"Codex CLI is not installed or is not available in PATH."},"primary":null}
{"provider":"claude","source":"claude-local","error":null,"primary":0}
{"provider":"copilot","source":"github-copilot-api","error":null,"primary":100}
{"provider":"openrouter","source":"openrouter-api","error":{"code":2,"kind":"provider","message":"OPENROUTER_API_KEY is not set and no local 9Router usage was found."},"primary":null}

$ ./providers/get-copilot-usage | jq -c '{provider, source, error, login: .usage.loginMethod}'
{"provider":"copilot","source":"github-copilot-api","error":null,"login":"github-token"}

Activity

  1. added
    bug
    on Nov 4, 2026
  2. guidi-injenia commented on Nov 4, 2026

    @guidi-injenia
    Author

    Found the cause: the parsing is fine. The widget is showing stale cached data.

    api.anthropic.com/api/oauth/usage was returning HTTP 429 (rate limited). On a 429, get-claude-usage silently falls back to the last cached snapshot, even when it is hours old. Mine was from 08:28 UTC, and its 5-hour window had already reset at 09:00. That's why Session showed 0% while claude.ai showed 16%.

    The rate limit was triggered by too many pollers on the same account: this widget (loaded twice), another quota plugin polling every 60 s, and Claude Code itself. I raised refreshInterval to 300 s and disabled the other plugin.

    Suggestions:

    • Show when the data is cached or stale (age or a badge).
    • Color differently when data is stale.
    • Back off on 429 instead of polling at the normal interval.

    Note: the widget is instantiated once per monitor (bar on "all" screens), each with its own timer. The 120 s cache normally dedupes them, but after a 429 the cache is never refreshed, so every instance re-hits the API on every tick, multiplying requests while already rate-limited.

  3. bernardopg commented on Nov 5, 2026

    @bernardopg
    Owner

    Thank you @guidi-injenia, both for the report and for the follow-up diagnosis. Tracing it to the 429 fallback, and noticing that the widget is instantiated once per monitor with its own timer, was exactly what was needed: you had already found the root cause.

    You're right on every point. 2.2.2 (#89) made the fallback snapshot keep its real fetch time, so the card turned Stale, but the adapter still asked again on every tick of every instance, and the bar kept showing the old numbers at full colour.

    #97 implements all three of your suggestions:

    • Back off on 429: after a 429 or 5xx the adapter waits one cache TTL (120 s), doubling per consecutive failure up to 30 minutes, or longer if the server sends Retry-After (capped at one hour). The backoff is stored in the account cache under the lock every run already takes, so all widget instances (one per monitor) and the credits request share it. The last good snapshot is served meanwhile. A manual refresh honours the backoff too, since asking again would only extend the limit.
    • Show that data is cached: the card's Updated line adds Rate limited · next try HH:MM, and the bar tooltip adds stale since HH:MM:SS plus the next try.
    • Color it differently: the bar pill fades a provider's percentage once its numbers are older than two refresh intervals, the same rule as the card's Stale badge.

    The troubleshooting docs also cover what you found: the limit is per account and shared with Claude Code and any other poller, so raising Refresh interval and stopping duplicate pollers is the fix when the backoff keeps coming back. Your fix will be credited in the changelog.

    It will ship in the next release. I'll update this issue when it's out.

  4. bernardopg commented on Nov 5, 2026

    @bernardopg
    Owner

    The backoff, the next-try notice on the card and the faded stale pill are out in v2.2.4. Update through Settings → Plugins → Check for updates; no restart is needed. Thanks again @guidi-injenia!

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions