## Problem
- Original implementation sends webhook notification on EVERY request when
account reaches 5-hour limit warning status
- Users receive hundreds of duplicate notifications within same 5-hour window
## Solution
- Add `maxFiveHourWarningsPerWindow` config (default: 1, max: 10)
- Track warning count per session window with metadata:
- fiveHourWarningWindow: identifies current window
- fiveHourWarningCount: tracks notifications sent
- fiveHourWarningLastSentAt: last notification timestamp
- Only send notification if count < max limit
- Auto-reset counters when entering new 5-hour window
## Changes
- Add warning limit control in constructor
- Add `_clearFiveHourWarningMetadata()` helper method
- Update `updateSessionWindowStatus()` with notification throttling
- Clear warning metadata on window refresh and manual schedule recovery
## Configuration
- Environment: CLAUDE_5H_WARNING_MAX_NOTIFICATIONS (1-10)
- Config: config.claude.fiveHourWarning.maxNotificationsPerWindow
- Default: 1 notification per window
## Testing
- Tested with accounts reaching 5h limit
- Verified single notification per window
- Confirmed counter reset on new window
Replace direct token decryption with getValidAccessToken call to
enable automatic token expiration check and refresh. This fixes
authentication_error when fetching OAuth usage data with expired
access tokens.
Add OAuth usage visualization for Claude OAuth accounts while maintaining
existing Setup Token session window display. Accounts show different UI
based on authorization type detected via scopes.
Changes:
- Add loadClaudeUsage() for async OAuth usage data loading
- Add isClaudeOAuth() to detect auth type (checks user:profile + user:inference scopes)
- Add OAuth helpers: formatClaudeUsagePercent, getClaudeUsageWidth,
getClaudeUsageBarClass, formatClaudeRemaining
- Display three OAuth windows (5h, 7d, 7d-Opus) for OAuth accounts
- Maintain original session window display for Setup Token accounts
- Color-coded progress bars (blue < 60%, yellow 60-90%, red >= 90%)
- Update tooltip with OAuth documentation
- Remove duplicate Claude fallback branch
- Apply to desktop and mobile views
Add dedicated API endpoint to fetch Claude account OAuth usage data
asynchronously, improving user experience by eliminating the need for
multiple page refreshes to view session window statistics.
Backend changes:
- Add GET /admin/claude-accounts/usage endpoint for batch fetching
- Implement fetchOAuthUsage() to call Claude API /api/oauth/usage
- Add buildClaudeUsageSnapshot() to construct frontend data structure
- Add updateClaudeUsageSnapshot() to persist data to Redis
- Add _toNumberOrNull() helper for safe type conversion
- Update getAllAccounts() to return claudeUsage from Redis cache
Data structure:
- Store three window types: 5h, 7d, 7d-Opus
- Track utilization percentage and reset timestamps
- Calculate remaining seconds for each window
Performance optimizations:
- Concurrent batch requests using Promise.allSettled
- Graceful error handling per account
- Non-blocking async execution