opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: add /usage usage tracking (codex/copilot/claude)

Open CasualDeveloper opened this issue 1 week ago • 3 comments

Problem

No way to view remaining plan usage/limits for authenticated providers (Codex, Copilot, Claude) inside the TUI.

Reproduction

  1. Authenticate at least one provider (e.g. opencode auth add codex / opencode auth add github-copilot / opencode auth add anthropic).
  2. Open the TUI.
  3. 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.

CasualDeveloper avatar Jan 18 '26 20:01 CasualDeveloper

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.

github-actions[bot] avatar Jan 18 '26 20:01 github-actions[bot]

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.

CasualDeveloper avatar Jan 18 '26 20:01 CasualDeveloper

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

improdead avatar Jan 18 '26 22:01 improdead