-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Open
Description
Problem
No way to view remaining plan usage/limits for authenticated providers (Codex, Copilot, Claude) inside the TUI.
Current State
- /usage API is the single source of truth (UsageRoutes factory), endpoint-only fetching (not via header parsing).
- /usage command opens a dialog and fetches latest data; sidebar shows usage and refreshes after assistant turns.
- /usage always fetches latest data for either current provider or all providers; pass
--currentand--allto override config of fetch scope. - Config:
tui.show_usage_scopedefaults tocurrentand controls sidebar + /usage default scope. - Sidebar refreshes on
usage.updatedevents from the server. - Fetchers return
{ snapshot, error }and surface status details in the dialog. - Copilot usage auth:
opencode auth loginprompts for a second device flow (VS Code client id) and storesusagetoken inauth.json;copilot_internal/useruses that token. - SDK/OpenAPI regenerated.
Open Threads
- Decide Claude 401 handling (reauth hint vs refresh flow).
- Decide whether to surface provider errors when another provider succeeds.
- Re-run
bun turbo typecheckandbun run --cwd packages/opencode test test/server/usage.test.tsafter latest UI/config changes.
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
- Config
tui.show_usage_scopecontrols default scope;/usage --current|--alloverrides - Typecheck + tests pass
Related
- Closes Github Copilot: Tracking Premium Requests #768
- Supersedes feat: display Anthropic and OpenAI OAuth usage in status dialog and sidebar #6905
- Supersedes feat: add usage tracking API and /usage dialog #7837
AI Assistance
- OpenCode + openai/gpt-5.2-codex; human reviewed.
borisnaidis, improdead, stevoland and berenar
Metadata
Metadata
Assignees
Labels
No labels