-
Notifications
You must be signed in to change notification settings - Fork 7.1k
feat(tui): add /usage command and sidebar usage section #9301
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
base: dev
Are you sure you want to change the base?
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Found potential related PRs:
Why they're related: PRs #6905 and #7837 appear to address the same core feature set - displaying AI provider usage information through both a |
f952e83 to
3c7cb89
Compare
|
@thdxr |
|
tested github-copilot. banger |
|
can someone test claude I dont have it lol |
|
@improdead lol i created my issue in preparation of my own pr which i'm currently testing, because the previous prs didn't have linked issues. i'll check out your implementation |
oh lol |
bb80dea to
491dfdd
Compare
- Add DialogUsage component with progress bars for usage tracking - Support OpenAI, Anthropic, GitHub Copilot, and Antigravity providers - Add Tab toggle to switch between 'used' and 'remaining' view - Implement Copilot device flow auth for usage API access - Store Copilot usage token separately (different OAuth client ID) - Add graceful 401/403 error handling for all providers - Show 'Unlimited' for pay-per-use providers like OpenCode Zen Closes anomalyco#9281
491dfdd to
e0dcbfe
Compare
|
Duplicate of #7837 . May need to be combined. |
|
|
Tried this on codex mode. Works great! Good job |
Add /usage as the single source of truth for provider usage data with TUI integration and automatic token refresh for Codex, Copilot, and Claude. Core: - New usage module with fetchers for each provider's usage endpoint - GET /usage endpoint with provider filter and refresh options - Claude token auto-refresh on 401 via console.anthropic.com - usage.updated bus event for real-time sidebar sync Auth: - Second device-flow during Copilot login for copilot_internal/user token - Optional usage field in OAuth schema for provider-specific tokens - Service token exchange attempt via copilot_internal/v2/token TUI: - /usage command with --current and --all flags (always fetches fresh) - Usage dialog with progress bars, reset times, credits/quota display - Sidebar Usage panel refreshes on events and assistant turn completion - tui.show_usage_scope config setting for default scope Closes anomalyco#9281, anomalyco#728 Supersedes anomalyco#6905, anomalyco#7837 Alternate to anomalyco#9301
Add /usage as the single source of truth for provider usage data with TUI integration and automatic token refresh for Codex, Copilot, and Claude. Core: - New usage module with fetchers for each provider's usage endpoint - GET /usage endpoint with provider filter and refresh options - Claude token auto-refresh on 401 via console.anthropic.com - usage.updated bus event for real-time sidebar sync Auth: - Second device-flow during Copilot login for copilot_internal/user token - Optional usage field in OAuth schema for provider-specific tokens - Service token exchange attempt via copilot_internal/v2/token TUI: - /usage command with --current and --all flags (always fetches fresh) - Usage dialog with progress bars, reset times, credits/quota display - Sidebar Usage panel refreshes on events and assistant turn completion - tui.show_usage_scope config setting for default scope Closes anomalyco#9281, anomalyco#728 Supersedes anomalyco#6905, anomalyco#7837 Alternate to anomalyco#9301
|
Hey @improdead — I took a whack at my own implementation to close #9281 via an alternate approach in #9545. Key differences:
Thanks for the initial exploration! @rekram1-node Happy to accept and close if either PR covers the use case. |
Add /usage as the single source of truth for provider usage data with TUI integration and automatic token refresh for Codex, Copilot, and Claude. Core: - New usage module with fetchers for each provider's usage endpoint - GET /usage endpoint with provider filter and refresh options - Claude token auto-refresh on 401 via console.anthropic.com - usage.updated bus event for real-time sidebar sync Auth: - Second device-flow during Copilot login for copilot_internal/user token - Optional usage field in OAuth schema for provider-specific tokens - Service token exchange attempt via copilot_internal/v2/token TUI: - /usage command with --current and --all flags (always fetches fresh) - Usage dialog with progress bars, reset times, credits/quota display - Sidebar Usage panel refreshes on events and assistant turn completion - tui.show_usage_scope config setting for default scope Closes anomalyco#9281, anomalyco#728 Supersedes anomalyco#6905, anomalyco#7837 Alternate to anomalyco#9301
Summary
This PR adds the ability for users to view their AI provider quota usage directly within OpenCode. Users can now easily monitor how much of their rate limits they've consumed across different providers like OpenAI, Anthropic, GitHub Copilot, and Google/Antigravity.
With more and more people using plugins like GitHub Copilot and Antigravity (Google), having visibility into rate limits has become increasingly important. This feature helps users avoid hitting quota limits unexpectedly during their coding sessions.
What's New
/usageCommandA new dialog that shows detailed usage information for your current AI provider:
Sidebar Usage Section
A compact usage display in the sidebar that:
Sidebar Documentation
Added documentation for the TUI sidebar feature with screenshot showing how to toggle it with
ctrl+x b.Supported Providers
chatgpt.com/backend-api/wham/usageapi.anthropic.com/api/oauth/usageapi.github.com/copilot_internal/userGitHub Copilot
GitHub Copilot requires a separate authentication flow since usage data isn't accessible through the regular Copilot tokens. When you first try to view Copilot usage, you'll be prompted to authenticate with a device code flow using a Copilot-specific client ID. The token is stored separately at
~/.local/share/opencode/usage-copilot.jsonso it doesn't interfere with your regular Copilot authentication.Antigravity (Google)
This support was added because so many people use https://github.com/NoeFabris/opencode-antigravity-auth to connect to Antigravity
With Antigravity becoming a popular choice for accessing Google's models through OpenCode, this PR adds support for fetching usage data from Google's cloudcode API. This gives Antigravity users the same visibility into their quota consumption as other providers.
Screenshots
/usage

Sidebar Usage

Sidebar Usage (Copilot)

Usage Remaining View

Copilot Auth Flow

Sidebar Toggle

Implementation Details
@/usagemodule with provider-specific implementationsIv1.b507a08c87ecfe98) and stores tokens separatelyCloses #9281
Closes #768