Repository navigation
fix(claude): back off a rate-limited usage endpoint and fade stale pills - #97
Merged
Merged
Conversation
Anthropic rate-limits the OAuth usage endpoint per account, and the limit is shared with Claude Code and any other tool polling it. After a 429 the adapter kept asking on every refresh of every widget instance: DMS builds one per bar screen, each with its own timer, and the 120 s cache that normally dedupes them is never refreshed while requests fail. The bar meanwhile showed the old snapshot at full colour, so a window that had reset since read 0% against claude.ai's 16% (#96). HTTP 429 and 5xx now record a backoff in the account cache, under the account lock every run already takes: one cache TTL, doubled per consecutive failure up to 30 minutes, or the server's Retry-After when longer (capped at an hour). No usage or credits request is sent until it ends; the last good snapshot is served with its own fetch time, and the item carries usage.retryAt and usage.retryReason so the card can name the next try. A network failure starts no backoff, and a deadline beyond the cap (clock moved back) is ignored. The DankBar pill fades a provider's percentage once its numbers are older than two refresh intervals, the same rule the card's Stale badge uses, and the tooltip adds since when and the next try. Signed-off-by: Bernardo Pinto Gomes <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Anthropic rate-limits
api/oauth/usageper account, shared with Claude Code and any other tool polling it. After a 429 the adapter kept asking on every refresh of every widget instance (DMS builds one per bar screen, each with its own timer), and the 120 s cache that normally dedupes them is never refreshed while requests fail. The bar meanwhile showed the old snapshot at full colour, so a window that had reset since read 0% against claude.ai's 16%.providers/get-claude-usage): HTTP 429 and 5xx recordclaude-usage-backoff.jsonin the account cache, under the accountflockevery run already takes. Delay: one cache TTL (120 s), doubled per consecutive failure up to 30 min, or the response'sRetry-After(seconds or HTTP date) when longer, capped at 1 h. No usage or credits request is sent until it ends; the last good snapshot is served with its own fetch time. A network failure (HTTP 000) starts none, a deadline beyond the cap (clock moved back) is ignored, a corrupt file is ignored, a 200 removes it.usage.retryAt(ISO) andusage.retryReason(rate_limited/server_error). Without a snapshot the error message names the next attempt.providerIsStale()helper); the tooltip addsstale since HH:MM:SSand the next try.Rate limited · next try HH:MM/Endpoint failing · next try HH:MM.architecture.md,usage.md,troubleshooting.md;CHANGELOG.mdUnreleased.Related issues
Closes #96
Type of change
Checklist
plugin.json.versionandCHANGELOG.mdare consistent (no release in this PR)i18n/en.jsonkeys have translations in every localegit commit -s) under the DCOLocal: every
tests/test-*.shpasses (includingtest-widget-runtime.shagainst the running DMS, with a new stale/backoff step),check-metadata,check-changelog,check-dco,shellcheck -S warning,qmllint,git diff --check. Local kcov 43 reads 94.12% because of its known line-tracking bug in the Hermes/OpenCode SQL files;get-claude-usageis at 96.7% with every new statement covered, and CI builds the pinned kcov.