fix(claude): sync OAuth cache on keychain changes#305
Draft
ratulsarna wants to merge 3 commits intomainfrom
Draft
fix(claude): sync OAuth cache on keychain changes#305ratulsarna wants to merge 3 commits intomainfrom
ratulsarna wants to merge 3 commits intomainfrom
Conversation
Detect and sync Claude OAuth credentials when the macOS keychain entry changes. Adds a ClaudeKeychainFingerprint struct, non-interactive keychain fingerprinting and data loaders, SHA-256 prefix hashing, and throttling to avoid frequent prompts. Integrates a syncWithClaudeKeychainIfChanged path into the existing load flow so cached credentials are updated only when the keychain token actually changes (and avoids regressing to expired tokens). Provides debug/testing overrides and reset helpers, and adds unit tests covering fingerprint-change-driven sync and no-op when the fingerprint is unchanged.
Improve Claude OAuth keychain handling and avoid unwanted keychain prompts. Renamed the stored fingerprint key to V2 and proactively remove the legacy V1 entry (which contained the account string) to reduce identifying data. Removed the account field from the fingerprint struct and added logic to read a legacy keychain candidate when needed. Load logic now consults only the newest candidate (matching fingerprint semantics) and preserves silent-probe behavior by honoring a new respectKeychainPromptCooldown gate when callers request no prompts. Updated callers (UsageStore, Provider descriptor, UsageFetcher) to pass the cooldown flag for silent loads. Added tests to cover expired keychain vs cached credentials and to ensure the prompt-cooldown gate is respected. Also added helpers and test cleanup for legacy fingerprint handling.
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.
Addresses the Claude OAuth cache/keychain mismatch case by re-detecting Claude keychain changes non-interactively on cache hits and syncing CodexBar's cached OAuth credentials when the access token changed.
Repro this fixes: create a newer
Claude Code-credentialsitem with a different token; CodexBar used to keep servingcom.steipete.codexbar.cacheuntil expiry; now it syncs.Commands run: