Skip to content

feat(usage): show GitHub Copilot premium request usage - #25911

Draft
geoff-powell wants to merge 1 commit into
stablyai:mainfrom
geoff-powell:gpowel46/6892-copilot-usage-tracking
Draft

geoff-powell wants to merge 1 commit into
stablyai:mainfrom
geoff-powell:gpowel46/6892-copilot-usage-tracking

Conversation

@geoff-powell

Copy link
Copy Markdown

ELI5

Orca shows how much of your AI subscription you've used for Claude, Codex, Gemini, Kimi, and others — but not GitHub Copilot. This adds Copilot: if you're already signed in to Copilot, Orca shows your monthly premium-request usage in the status bar and in Settings → Accounts.

What Changed

  • New src/main/rate-limits/copilot-usage-fetcher.ts (+ tests):
    • Reads an existing Copilot login read-only: the shared github-copilot config dir (apps.json, then hosts.json; honors XDG_CONFIG_HOME / LOCALAPPDATA) first, then the macOS Keychain item copilot-cli.
    • Only github.com entries are used (a GHE token is never sent to github.com). Token is redacted from errors and never stored; account identity is an HMAC.
    • After one Keychain denial, Orca stops prompting until restart (no prompt loop).
    • GET https://api.github.com/copilot_internal/user → maps quota_snapshots.premium_interactions to the existing monthly window, with "used / entitlement" and the reset date. 401 → stale-token, 403/404 → no-subscription, 429 → rate-limited. No login → unavailable (no chip).
  • Service: fetched on its own promise alongside the others; stale snapshot is dropped when the GitHub account changes (same as Cursor).
  • 'copilot' threaded through shared types, defaults, RPC enum, persisted UI flag (_copilotStatusBarDefaultAdded, one-shot default-on migration).
  • Renderer: status-bar chip/tooltip ("Premium requests"), visibility menu, settings search entry, new CopilotAccountsSection in Accounts, en.json strings (other locales via the catalog sync script).
  • Moved the existing ZCode accounts search entries into accounts-zcode-search.ts so accounts-search.ts stays under the max-lines cap.

Why

Follows the #1022 / #4570 / ZCode (#23520) pattern. I used /copilot_internal/user rather than the POST /copilot_internal/v2/token suggested in the issue: both return quota_snapshots, but v2/token also mints a Copilot bearer, while /user keeps Orca strictly read-only (it is also what VS Code uses for its quota display). The chip is not PATH-gated on the copilot CLI because the login may come from copilot.vim / Zed / JetBrains.

Out of scope (follow-up): an Orca-owned GitHub device-flow login for macOS/SSH users without a readable token, and a Stats tab.

Linked Issue

Fixes #6892

Visual Proof

Pending — I haven't yet run the app against a real Copilot seat; will attach before/after of the status bar and Accounts pane before marking ready.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • copilot-usage-fetcher.test.ts: config-dir resolution, apps/hosts precedence, GHE filtering, window mapping (entitlement/percent/unlimited), HTTP error mapping, token redaction, Keychain-denial latch.

  • Existing service tests mock the new fetcher; hydration test updated for the new default-on item.

  • tsc (node/web/cli), oxlint, oxfmt, localization verify/extraction/coverage, max-lines ratchet: pass. Vitest over src/main/rate-limits, settings, status-bar, store: 724 files pass.

  • Still to verify against a live seat: the /copilot_internal/user response shape and the Keychain lookup by service name only (macOS).

AI Disclosure

Implemented with an AI coding agent (Claude, via OpenCode), reviewed by me.

Review

Agent skill upstream boundary

@wichopy

wichopy commented Oct 7, 2026

Copy link
Copy Markdown

@geoff-powell if i build the app locally i can help you verify? I want this feature badly :D

@jianfengzhang-maersk

Copy link
Copy Markdown

Is credit supported? We are using enterprise plan. Here's what in my copilot.

image

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add GitHub Copilot usage tracking (status-bar rate limits + Accounts pane)

3 participants