feat(provider): add usage limits tracking and display#34
Closed
feat(provider): add usage limits tracking and display#34
Conversation
- Persist provider rate limits when `account.rate-limits.updated` events arrive - Normalize Claude (five_hour/seven_day) and Codex (primary/secondary) limit payloads - Overlay persisted limits onto provider snapshots in registry - Display color-coded progress bars in Settings > Providers (green >50%, amber 20-50%, red <20%) - Real-time updates via WebSocket push when limits change - Added SQLite `provider_usage_limits` table (migration 022) - Added `UsageLimitsRepository` service with upsert, get, and `streamChanges` PubSub
- Show "Usage limits" label heading above usage window bars - Display "No usage data yet." message instead of hiding section - Improves UX clarity when awaiting first rate limit update
- Updated integration and unit tests to use inline stub implementations of UsageLimitsRepository - Removes dependency on UsageLimitsRepositoryLive layer in test fixtures - Simplifies layer composition and decouples tests from live implementation details
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
provider_usage_limits(migration 022) andUsageLimitsRepositoryservice for upsert/get/stream operations with stale-write protectionProviderService.processRuntimeEventnow persists usage limits whenaccount.rate-limits.updatedevents arrivenormalizeClaudeUsageLimits()andnormalizeCodexUsageLimits()innormalizeUsageLimits.tsto standardize provider-specific rate limit payloads intoServerProviderUsageWindow(session/weekly union)ProviderRegistry.syncProvidersnow overlays persisted limits onto provider snapshots; changes trigger WebSocket push viaUsageLimitsRepository.streamChangesPubSubProviderUsageLimitsSectionrenders color-coded progress bars (green >50%, amber 20-50%, red <20%) with relative reset times (e.g. "in 2h 30m") and absolute datesServerProviderUsageLimitsschema withwindowsarray andupdatedAttimestamp; added optionalusageLimitsfield toServerProviderTesting
UsageLimitsRepositoryLivelayer in all fixtures (ProviderService, ProviderRegistry, OrchestrationEngine)WHERE excluded.updated_at > ...to ignore out-of-order updatesUsageLimitsRepository.streamChangestriggers registry re-sync and WebSocket broadcast