Add macOS widget extension for Claude usage monitoring#1
Add macOS widget extension for Claude usage monitoring#1leo-levin wants to merge 1 commit intoRISCfuture:mainfrom
Conversation
- Medium-sized widget with circular gauge and progress bars - Shows 5-hour session, 7-day all, Opus, and Sonnet utilization - Displays reset times for each limit - Tap anywhere to refresh widget data - Auto-refreshes every 15 minutes - Reads OAuth token from Claude Code keychain - Local signing configuration (no provisioning profile required) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| private var preferredTokenSource: TokenSource { | ||
| // App Groups not configured - default to Claude Code | ||
| return .claudeCode | ||
| } |
There was a problem hiding this comment.
Bug: Widget fails to retrieve API tokens from keychain due to missing keychain sharing entitlements and kSecAttrAccessGroup in queries.
Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The widget's KeychainService cannot retrieve API tokens from the keychain because it lacks proper keychain sharing configuration. Both the main app and widget entitlements files are missing keychain-access-groups, and keychain queries in KeychainService.readClaudeCodeToken() and KeychainService.readManualToken() do not specify kSecAttrAccessGroup. This prevents the widget from accessing tokens stored by the main app or Claude Code, leading to UsageTimelineProvider.fetchUsageEntry() always returning .error("No API token configured").
💡 Suggested Fix
Enable Keychain Sharing capability for both main app and widget targets. Add keychain-access-groups to both entitlements files. Include kSecAttrAccessGroup in all keychain store and retrieve operations for shared items.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: Claude Monitor Widget/UsageTimelineProvider.swift#L16-L19
Potential issue: The widget's `KeychainService` cannot retrieve API tokens from the
keychain because it lacks proper keychain sharing configuration. Both the main app and
widget entitlements files are missing `keychain-access-groups`, and keychain queries in
`KeychainService.readClaudeCodeToken()` and `KeychainService.readManualToken()` do not
specify `kSecAttrAccessGroup`. This prevents the widget from accessing tokens stored by
the main app or Claude Code, leading to `UsageTimelineProvider.fetchUsageEntry()` always
returning `.error("No API token configured")`.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 5706316
Summary
Test plan
🤖 Generated with Claude Code