-
Notifications
You must be signed in to change notification settings - Fork 7.1k
feat: add usage tracking API and /usage dialog #7837
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
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found 2 highly related PRs that appear to address similar or overlapping functionality: Potential Duplicates:
These PRs implement similar functionality (usage display for providers), though PR #7837 appears to be a more comprehensive solution with a dedicated |
518983a to
8504003
Compare
This update aligns Copilot usage tracking with the native OpenCode Copilot plugin by utilizing real-time rate-limit headers and token metadata rather than flaky internal API calls.
8504003 to
ce6605e
Compare
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
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
What does this PR do?
Adds a usage tracking API + TUI dialog for authenticated providers, including Codex and Copilot (rewritten for native Copilot plugin).
/usageserver route plus sharedUsagemodule for fetching, caching, and normalizing usage snapshots/usageautocomplete handling and a unified usage dialog (plan/quota parsing, scaling, reset display)How did you verify your code works?
bun run typecheck(fails inpackages/opencode/src/server/server.ts:202due to existing deep type instantiation error; unchanged from upstream)screenrecording-2026-01-11_18-37-51.mp4