Repository navigation
fix(resets): confirm a reset with one limits read a few seconds later - #173
Merged
Merged
Conversation
A real reset on either provider gets one confirming limits read about 5s later, skipped when another lookup started since or is still running; Claude's shared 429 pause still applies. Kleis only ever shows limits the upstream reported. An answer that nothing needed a reset keeps the cached data and reads nothing.
rexdotsh
force-pushed
the
fix/refresh-after-reset
branch
from
October 22, 2026 13:32
13f10f4 to
2bd67a6
Compare
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.
Stack 1/4 · resets UX redo. Server only.
Problem
After a Claude claim, the admin kept showing the old limits until the next scheduled usage poll, up to ~3 minutes later (#139/#143 dropped the extra reads to Anthropic's rate-limited
/api/oauth/usage). Codex re-read its limits right away, but that read can still be stale.Change
Kleis only ever shows limits the upstream reported, so nothing is updated optimistically. Instead, a real reset gets one confirming read a few seconds later.
reset(confirmed)GET /api/oauth/usageabout 5s later; offer invalidated as beforereset,already_redeemedno_credit, errors, refusalsnothing_to_reset, Claudenot_limitedConfirming read rules. It goes through the existing loader, so it's single-flight and the shared Claude 429 pause applies (no request while paused). It's skipped if another lookup started after the reset or is still running, including an invalidated one, so it never overlaps a request. It never retries or loops. Polling cadence and backoff are unchanged.
Extra calls per reset: Claude, 1
/api/oauth/usage. Codex, 1 confirming reload:wham/usage+rate-limit-reset-credits+profiles/me(+accounts/checkonly when the daily profile check is due). None for a result that changed nothing.Tests
Failing first, through
claimClaudeReset/redeemCodexResetCreditand the tracking cache, with mocked fetch, an in-memory DB, and a capturedsetTimeouton the fake clock:bun lint,bun typecheck,bun run buildpass.bun test: 312 pass, 6 skip, 0 fail.--randomizealso passes.