Repository navigation
Account menu: Claude Code limits say why they are unavailable (#505) - #506
Open
MopigamesYT wants to merge 1 commit into
Open
MopigamesYT wants to merge 1 commit into
MopigamesYT wants to merge 1 commit into
Conversation
"Limits unavailable" hid the real reason. On the dev machine the cc-langloys login gets HTTP 429 with Retry-After ~48 min from /api/oauth/usage. Limits now show the reason in plain words (rate limited with the wait, sign in again, this login can't read usage, session expired, can't reach the provider...) beside the last good numbers. - Connections on one Claude login share one read and one pause, so a rate-limited login is no longer asked again every minute. - An own-login connection's expired token is refreshed with its refresh token (saved atomically, other fields kept); the system login is not, its refresh token is shared with the user's terminal. - Same reasons on the phone and headless server callers.
tpm28
approved these changes
Nov 18, 2026
This branch has not been deployed
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.
Closes #505
Summary
A Claude Code account that showed "Limits unavailable" now says why, in plain words, and keeps its last good numbers on screen:
.credentials.json.Screenshots
None: I could not drive the desktop UI here, and screenshots of the account menu show private account names and usage, so none are uploaded.
Technical details
Real cause on this machine (read-only checks, no token printed): the issue assumed cc-langloys is an own-login connection. It is not: it has no
claudeLogin: own, so it reads the system login (~/.claude, ateamplan, token valid for 2 h+).GET /api/oauth/usagefor that token answers 429rate_limit_errorwithRetry-After: 2864(about 48 min), and stays 429 on a second try. The own-login connection (cc-perso) answers 200 with its 5h/7d windows. So it was neither an expired token nor a missing file. Why that login is rate limited I can't tell: 1loop polled it often (menu every minute, after each turn, phone, and once per connection), but the same token is also used by other Claude Code processes.What changed
internal/agent/claude_limits_errors.go(new):limitsHTTPError(status +Retry-After, seconds or date),LimitsNote(err)(error → plain words),LimitsAfterError(last, err)(last good numbers + reason), a per-login-folder shared read (30 s) and pause (the server'sRetry-After, between 1 min and 6 h), and the OAuth refresh.internal/agent/account_limits.go:ConnectionLimitsgoes through the shared read for Claude Code; the usage request carriesRetry-After; refresh only after a 401 for own logins; the old "Claude session expired" note is gone.internal/ui/account_limits.go(desktop menu),internal/ui/phone_server.goandinternal/server/mobile_connections.go(phone/headless/api/limits) useLimitsNote/LimitsAfterErrorand keep the oldCheckedtime on an error;internal/ui/account_limits_controls.goshows the reason in the strip header when numbers are present. The phone gets the same note through the existingNotefield, no protocol change.Tests (
internal/agent/claude_limits_errors_test.go, httptest and fake credentials folders, no real tokens): error → message table,Retry-Afterparsing, last-good-numbers, own-login refresh (saved, other fields kept, no temp file left), refresh revoked (file untouched), system login never refreshed, 403/401/5xx/expired/bad JSON/missing file, 429 pause shared by two connections (one request), shared read (one request for three calls).Verified
gofmt -l internal cmdempty,go build ./...,go veton agent/server/ui,go test ./internal/agent ./internal/uipass.Not verified
platform.claude.com/v1/oauth/token, Claude Code's public client ID): no login here has an expired token and I did not spend a real refresh token. It is only tested against httptest.go test ./internal/serverhas one failure,TestProjectOnSSHMachine("no host key waits"); it fails the same way on a cleanorigin/dev, unrelated to this change.-racerun (project rule).Assisted-by: Sonnet 5.5 high
🤖 Generated with Claude Code