Skip to content

Add macOS widget extension for Claude usage monitoring#1

Open
leo-levin wants to merge 1 commit intoRISCfuture:mainfrom
leo-levin:feature/widget
Open

Add macOS widget extension for Claude usage monitoring#1
leo-levin wants to merge 1 commit intoRISCfuture:mainfrom
leo-levin:feature/widget

Conversation

@leo-levin
Copy link

@leo-levin leo-levin commented Dec 5, 2025

Summary

  • Medium-sized macOS widget with circular gauge and progress bars
  • Shows 5-hour session, 7-day all, Opus, and Sonnet utilization with reset times
  • Tap anywhere to refresh; auto-refreshes every 15 minutes
  • Reads OAuth token from Claude Code keychain

Test plan

  • Build and run the main app
  • Add widget via right-click desktop → Edit Widgets → "Claude Usage"
  • Verify gauge and progress bars display correctly
  • Tap widget to confirm refresh works

🤖 Generated with Claude Code

- 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>
Comment on lines +16 to +19
private var preferredTokenSource: TokenSource {
// App Groups not configured - default to Claude Code
return .claudeCode
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants