feat: add /usage usage tracking (codex/copilot/claude)
Problem
No way to view remaining plan usage/limits for authenticated providers (Codex, Copilot, Claude) inside the TUI.
Reproduction
- Authenticate at least one provider (e.g. opencode auth add codex / opencode auth add github-copilot / opencode auth add anthropic).
- Open the TUI.
- There is no sidebar panel or /usage command to show remaining provider usage limits.
Analysis
Each provider exposes usage via a dedicated endpoint, but the UI currently has no unified surface for it. A single /usage API keeps sidebar + dialog consistent and avoids duplicating provider-specific logic in the UI.
Provider sources:
- codex: https://chatgpt.com/backend-api/wham/usage (include ChatGPT-Account-Id when present)
- claude: https://api.anthropic.com/api/oauth/usage (requires anthropic-beta: oauth-2025-04-20)
- copilot: https://api.github.com/copilot_internal/user (best-effort; enterprise via /api/v3/copilot_internal/user)
Proposed Fix
- Add GET /usage (operationId: usage.get) returning usage snapshots for authenticated providers only.
- TUI:
- /usage command opens a dialog (supports provider filter + --refresh / -r)
- Sidebar "Usage" section shows provider limits and refreshes after assistant turn completion.
Acceptance Criteria
- [ ] GET /usage returns entries only for authenticated providers (codex/copilot/claude)
- [ ] /usage dialog renders all returned windows (Codex: hourly/weekly; Claude: 5h/7d/Opus 7d; Copilot: quota + reset date)
- [ ] Sidebar renders the same data (SSoT via /usage) and refreshes after assistant turn completion
- [ ] OpenAPI + JS SDK regenerated/in sync
- [ ] Typecheck + tests pass
Related
- Closes #768
- Supersedes #6905
- Supersedes #7837
AI Assistance
- OpenCode + openai/gpt-5.2-codex; human reviewed.
This issue might be a duplicate of existing issues. Please check:
- #768: Github Copilot: Tracking Premium Requests - requests tracking for Copilot provider usage quota
Feel free to ignore if none of these address your specific case.
Thanks for the pointer. Related to #768 for Copilot quota visibility, but this issue is broader: adds a unified /usage API + TUI surfaces for codex/copilot/claude (including 5h/7d/Opus 7d windows) and is not limited to Copilot premium requests. I'll keep #768 referenced here.
AI Assistance: OpenCode + openai/gpt-5.2-codex; human reviewed.
Hey made an pr about this with images check it out :) so copilot we need a separate authentication flow since uage data is is not accessible through the one in auth.json and also added antigravity for the plugin Antigravity + Gemini CLI OAuth Plugin for Opencode due to large popularity