fix: usage page OAuth token refresh and keychain access - #42
Merged
Conversation
The usage page showed "Claude Code login required" in release builds due to multiple issues: the macOS Keychain couldn't be accessed from the app bundle, and the OAuth access token expired without being refreshed. Key changes: - Switch Keychain access from `security` CLI subprocess to native `security-framework` crate with CLI fallback for account compatibility - Implement OAuth token refresh via platform.claude.com using the stored refresh token (5-min pre-expiry buffer, same as ClaudeBar) - Add CLI fallback (`claude /usage`) when the API probe fails - Add in-memory credential cache (5-min TTL) to avoid repeated I/O - Enhanced retry: reload from file/keychain on auth failure (picks up tokens refreshed externally by Claude Code CLI) - Preserve original Keychain account name on save to avoid duplicate entries - Add subscription type badge (MAX/PRO/API) to the usage page UI - Display subscription tier as a gradient banner in the main content Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…inux Add cfg_attr guards for KEYCHAIN_SERVICE, Keychain variant, and keychain_account field that are only used in #[cfg(target_os = "macos")] blocks but flagged as dead code on Linux CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
securityCLI subprocess to nativesecurity-frameworkcrate (with CLI fallback for account name compatibility)platform.claude.comusing the stored refresh token, with 5-min pre-expiry buffer and enhanced retry strategy (reload from file/keychain on auth failure to pick up externally refreshed tokens)claude /usage) when the OAuth API probe fails, with ANSI-stripping text parserTest plan
pnpm tauri:dev— usage page loads with refreshed token and shows subscription bannerpnpm tauri build— release.appprompts for Keychain access on first launch, then usage worksclaude /usageoutput is parsed🤖 Generated with Claude Code