-
Notifications
You must be signed in to change notification settings - Fork 7.4k
feat(app): Add OAuth rate limits and usage dashboard #8912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Non-network errors seen in logs: - AI_APICallError (402 deactivated_workspace) - AI_APICallError (500 server_error) - AI_LoadAPIKeyError / OpenAI API key is missing - ProviderInitError - ConfigInvalidError - ProviderAuthOauthCallbackFailed - NotFoundError - EditBuffer is destroyed
- Add getUsage() to fetch OAuth account status and health - Add fetchAnthropicUsage() to fetch Claude Max rate limits from Anthropic API - Add GET /auth/usage endpoint to expose usage data
- Add DialogAuthUsage component with rate limit visualization - Display Anthropic 5-hour and 7-day limits with progress bars - Show OAuth account status, cooldown state, and request counts - Add button in sidebar to open the dialog
- Add AuthUsageCommand to display rate limit info in terminal - Show account status, cooldown state, and request counts - Display Anthropic rate limits when available
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found one potentially related PR: Related PR:
This PR is related because the current PR (#8912) explicitly mentions that it builds on the OAuth multi-account failover infrastructure, likely from this OAuth Marathon implementation. However, they serve different purposes - #8590 appears to handle the credential rotation logic, while #8912 adds the usage monitoring dashboard on top of that infrastructure. This is not a duplicate but rather a dependent feature. No exact duplicates found. |
The AI SDK's convertToModelMessages() does not accept 'step-start' as a valid UIMessagePart type. This caused AI_InvalidPromptError during session compaction. - Remove step-start from being added to UIMessage parts - Simplify the filter since step-start is no longer included - Fixes compaction breaking sessions with context overflow
|
@mguttmann screenshots please |
|
Closing to rework - will resubmit with improved documentation covering both features (multi-account OAuth rotation + usage dashboard) |
Summary
Adds visibility into OAuth rate limits and usage information for authenticated providers, particularly useful for Claude Max users to monitor their 5-hour and 7-day usage limits.
Closes #8911
Changes
Backend (
packages/opencode)src/auth/index.ts: AddgetUsage()andfetchAnthropicUsage()functions to OAuthPoolsrc/server/server.ts: AddGET /auth/usageAPI endpointsrc/cli/cmd/auth.ts: Addopencode auth usageCLI commandFrontend (
packages/app)src/components/dialog-auth-usage.tsx: New dialog component with:src/pages/layout.tsx: Add sidebar button to open usage dialogScreenshots
The dialog displays:
Testing
Note
This PR includes the OAuth multi-account failover commits from @gwizz as a foundation, since the usage dashboard builds on that infrastructure. Credit to gwizz for the excellent OAuth rotation system!