Repository navigation
Look up the Claude OAuth email in the background - #923
Merged
Merged
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 3
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
added 3 commits
October 19, 2026 02:22
# Conflicts: # CHANGELOG.md
The profile lookup now starts after the token's expiry and user:profile scope checks, as upstream validates before its lookup, so an expired or scope-less token sends no /profile request. The checks move into check_usage_credentials, which fetch_usage still runs. Tests assert no profile request for those tokens and that a valid token's lookup reaches the endpoint.
# Conflicts: # CHANGELOG.md
…l-background # Conflicts: # CHANGELOG.md
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
The Claude OAuth account email no longer delays a usage refresh.
fetch_with_credentialsawaitedGET /api/oauth/profileinline after the usage request, with a 5-second timeout, before it returned the result. A slow profile endpoint held back the quota refresh by up to 5 s. A failed lookup was retried every 15 minutes.profile::display_emailnever waits. The first call for an access token starts one background lookup on the current Tokio runtime, bounded to 2 seconds for connect, response and body, and returnsNone. Later calls return the cached result. The lookup starts before the usage request, so a quick profile answer can still label the same refresh.user:profilescope checks now run before the lookup starts (check_usage_credentials, shared withfetch_usage). Upstream validates the token before its profile lookup, so an expired or scope-less token sends no/profilerequest. The error returned for those tokens is unchanged.UsageSnapshotfor the same token, and the cache is private toproviders/claude/oauth/profile.rs. No provider registration or shared code changed. Saved accounts (Show usage for every saved Claude account in the tray #910) each use their own token, so each gets its own email.Test seam
The profile URL is
https://api.anthropic.com/api/oauth/profile. In tests only, a thread-local override (TEST_PROFILE_URL) points it at the mockito server, so the tests can count/profilerequests. Production has no override path.Upstream reference
21dc8b66457813e98970573fda5c3b2bb22d726d(fix(claude): show the OAuth account email on ordinary refreshes; fixes Claude OAuth source still shows no account email (#567 regression / never fixed) — profile email is fetched but discarded steipete/CodexBar#4493). NewClaudeOAuthDisplayProfileCache.swift, wired fromClaudeUsageFetcher.swift.ClaudeUsageFetcher.swift(v0.77.0):validateRequiredOAuthScope, then the display-profile lookup, thenfetchOAuthUsage.Tests/CodexBarTests/ClaudeOAuthProfileIdentityTests.swiftat21dc8b664: same-token email cached and reused with one request, credential changes cannot borrow another token's email, a failed lookup is not retried for the same token, and a stalled lookup returns before its deadline and fails soft at the timeout with no retry. These run against a mockito server, plus a local TCP listener that accepts connections and never answers.expired_or_scope_less_tokens_send_no_profile_request(mockitoexpect(0)on/api/oauth/profile, with a 200 ms settle so a regression that starts a lookup would be caught) and its controla_valid_token_reaches_the_profile_endpoint(the same mock sees one request for a valid token).Docs
No doc in
docs/describes the email lookup or a 15-minute email retry, so no doc changed. The CHANGELOG bullet now says the lookup runs only for a token that passes the expiry and scope checks. The CHANGELOG conflict from the newerorigin/mainwas resolved by keeping both this bullet and main's new Settings bullet (settings.jsonunreadable file, #917).Commands run
Head
f54c5bf36(mergesorigin/mainthrough60b589ec8, which includes #917; the ordering change is in1c2a7340e):cargo fmt --all -- --check: cleancargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings: cleancargo clippy --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml --all-targets -- -D warnings: cleancargo test --manifest-path rust/Cargo.toml claude: 412 passed, 0 failed, 1 ignored (includesoauth::profileand the 2 new tests)Earlier on the previous head
1c2a7340e:oauth::profile10 passed;claude412 passed on rerun. The firstclauderun there had 2 flakes outside the profile and fetch path (providers::claude::accounts::tests::same_email_and_different_organizations_remain_distinct,providers::claude::oauth::usage_gate::tests::consecutive_429s_escalate_even_after_the_block_expired); both passed alone and on rerun, and neither appeared onf54c5bf36. Full runs on the pre-merge head (not repeated on the newest head):cargo test --manifest-path rust/Cargo.toml4795 passed;cargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml689 passed.UI impact
No layout or frontend change. The Claude card's email row, which already exists, may be empty on the first OAuth refresh for a token and filled in from the next refresh on. Refreshes no longer wait for the profile lookup.
Merge note
This branch and #919 (Claude OAuth reset credits) both branch from
bcdf20dd2. Both add aCHANGELOG.mdbullet at the top of## [Windows] Unreleased, and both editfetch_with_credentialsinrust/src/providers/claude/oauth/mod.rsin adjacent lines. Expect a small text conflict for whichever merges second. This branch was re-merged withorigin/mainafter60b589ec8landed; #919 has not yet been merged into this branch, so it is expected to need a re-merge once #919 lands.