Repository navigation
feat(copilot): plan-usage chip row for the monthly premium-request quota - #662
opticon454 wants to merge 6 commits into
Conversation
|
Thanks @opticon454! This adds the Copilot row to the header plan-usage chip, reading the monthly premium-request quota from GitHub with the CLI's own token, and closes the gap left after #592. The code is careful: read-only, silent on every failure, redirects refused, admin-only on the wire, and the token never lands in state or logs. CI is green and the row renders correctly in all three header styles. A few things to fix before merge:
Smaller items, take them or leave them:
Once 1 to 4 are in, this is ready to merge. I will add the matching line to |
aa9e5ce to
89a6aec
Compare
|
Thanks @Ark0N, all four items and the smaller ones are in the new commit (rebased on current master first).
Smaller items, all taken: Typecheck, lint and the Copilot, usage-telemetry and plan-usage-latest tests pass locally. |
`node_modules/` with a trailing slash matches directories only, so a worktree that links node_modules to a shared install shows the link as untracked and a plain `git add` commits it. Two PR heads did (#658, #662), which also broke checking them out next to a real install. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Thanks @opticon454 for turning this round so quickly. One thing in the new commit ( It got in because master's The symlink also stopped my review checkout of that head, which is why the rework has not had its review yet. It runs once the new head is up. |
The Copilot CLI has no scriptable usage command (`copilot billing` exists only inside the TUI), but the quota the editors show is `GET https://api.github.com/copilot_internal/user`, readable with the CLI's own sign-in token. The header chip gets a `Copilot` row with one `mo` window (the calendar-month premium-request quota) beside Claude's and Codex's, with request counts and the reset in the tooltip. The host polls it every 10 minutes, read-only like the Codex poll, and only when the CLI is installed, a token resolves (COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN, then authTokens in <COPILOT_HOME or ~/.copilot>/config.json) and plan-usage display is on, so turning the chip off also stops the request. The endpoint is undocumented, so every failure (offline, 401, a changed shape, an unlimited quota) yields no row. The token is never logged and is sent only to api.github.com with redirects refused.
FAQ, Installation and Security said the only network traffic is browser to server. The plan-usage Copilot row asks api.github.com for the user's own quota, so each now states that one optional exception, when it happens (CLI installed and signed in, chip on) and how to stop it.
…quota read is on by default
89a6aec to
7cfd631
Compare
|
Thanks @Ark0N, and sorry about that: I share one install between my worktrees through a symlink and |
|
Thanks @opticon454 for the quick turnaround on both rounds. This adds the Copilot row to the header plan-usage chip, reading the monthly premium-request quota from GitHub with Copilot's own token, and every item from the last review is in: the signature carries the limit with its test, the Copilot merge case is tested, the docs say the read is on by default and how to stop it, the chip pages no longer call it Claude-only, and the symlink is gone. One thing came in with the switch to
Two small things:
I will apply these three at merge time together with the CLAUDE.md and architecture-invariants lines, so nothing more is needed from you unless you would like to push them yourself first. Thanks again for seeing this through. |
|
Thanks @Ark0N, good catch. All three are in the new commit.
Typecheck and the Copilot tests pass locally. I'll leave the |
|
Thanks @opticon454 for the third round. This adds a Copilot row to the header plan-usage chip with the monthly premium-request quota, read from GitHub with Copilot's own sign-in token. Everything from the last review is in: I will merge this and apply the following on top at merge time, so nothing more is needed from you:
Thanks again for seeing this through three rounds. |
…ota (#662) Squash of PR #662. The header plan-usage chip gains a Copilot row: the calendar-month premium-request quota, with the request counts and the reset in the tooltip, read every 10 minutes from GitHub's copilot_internal/user endpoint with the Copilot CLI's own sign-in token. It rides showPlanUsageLimits and is on by default while the CLI is installed and signed in; any failure leaves the chip without the row. Merge-time fixes by the maintainer: the gates (setting, then token, then the CLI probe) live in readCopilotPlanUsageIfEnabled() so a host with no Copilot sign-in never runs the login-shell probe each tick, with a test that Plan Usage Limits off means no request; the X-GitHub-Api-Version header the Copilot CLI itself does not send is dropped; and CLAUDE.md, architecture-invariants, README and copilot-integration describe the read. The hooks-config import in server.ts was merged with #666's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Merged and shipped in 1.44.0, squashed into one commit (34cf798) so the What I applied at merge, as promised:
|
What
A
Copilotrow in the header plan-usage chip: the calendar-month premium-request quota, with the request counts and the reset in the tooltip. #592 landed the Copilot run mode without it, so this is the split-off follow-up.Why
The Copilot CLI has no scriptable usage command (
copilot billingexists only inside the TUI). The quota the editors show isGET https://api.github.com/copilot_internal/user, readable with the CLI's own sign-in token.How
src/utils/copilot-plan-usage.tsreads the quota. The host polls it every 10 minutes, read-only like the Codex poll, and only when the CLI is installed, a token resolves (COPILOT_GITHUB_TOKEN,GH_TOKEN,GITHUB_TOKEN, thenauthTokensin<COPILOT_HOME or ~/.copilot>/config.json) and plan-usage display is on. Turning the chip off also stops the request.Tests
test/copilot-plan-usage.test.ts(parsing, token resolution order, each failure mode, no redirect) andtest/plan-usage-chip.test.ts(the row renders and is omitted when absent). Changeset included.