Repository navigation
fix(menubar): find Copilot credentials beyond the legacy plugin files (#1198) - #1200
Merged
Merged
Conversation
… gh, env, and a pasted token (#1198) Modern Copilot clients no longer write ~/.config/github-copilot/hosts.json or apps.json, so the menubar reported "No GitHub Copilot credentials found" even after signing in through VS Code and the Copilot CLI. Discovery now walks an ordered read-only chain, first hit wins, every rung tolerating an absent, locked, or malformed source: the legacy plugin files, the Copilot CLI keychain item (service copilot-cli, read via /usr/bin/security so no partition-list prompt can fire), ~/.copilot/config.json and settings.json, COPILOT_GITHUB_TOKEN / GH_TOKEN / GITHUB_TOKEN, `gh auth token`, and finally a token pasted into Settings. The two subprocess rungs are cached for five minutes so eligibility checks and the 30s refresh cadence never spawn per call, and hasCredential stays spawn-free. VS Code's encrypted secret storage is deliberately untouched. The no-credentials message now says usage tracking still works and names every way to connect, and the Copilot settings pane gains a token field.
…ry (#1198) The Copilot CLI's Keychain item is written by a Node keyring library, so /usr/bin/security is not in its partition list. Unlike the Claude Code item, every read would raise the macOS "allow access?" dialog, and with the probe cache a user who clicks Deny would be asked again every five minutes. `gh auth token` already reaches the same users, because the Copilot CLI itself falls back to gh, so the rung was risk without benefit. The chain is now legacy plugin files, ~/.copilot/config.json and settings.json, the environment variables, `gh auth token`, and a pasted token. No `security` subprocess remains in the adapter, and the probe cache collapses to the single gh answer.
…ad of showing 100% used A Free or Individual plan reports premium_interactions with entitlement 0 and 0% remaining, which both the menubar and the desktop decoder turned into a full 100% used ring. Verified against a live quota payload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1198.
Problem
The Copilot quota ring only looked for
~/.config/github-copilot/hosts.json/apps.json, which only the older editor plugins write. Modern VS Code keeps its GitHub login in encrypted secret storage and the Copilot CLI 1.0 uses~/.copilotplus the Keychain, so a fully signed-in user saw "No GitHub Copilot credentials found" with no hint that usage tracking was unaffected.Fix
Read-only discovery chain, first hit wins, every rung tolerant of absent or malformed data:
hosts.jsonthenapps.json(unchanged)~/.copilot/config.jsonthensettings.json: the token key is undocumented and has moved between releases, so the parser takes the first value with a GitHub access-token prefix (gho_,ghu_,ghp_,ghs_,github_pat_);ghr_refresh tokens are skippedCOPILOT_GITHUB_TOKEN,GH_TOKEN,GITHUB_TOKENgh auth token(verified: a gh login token gets HTTP 200 fromcopilot_internal/user); cached 5 minutes, 5 s deadline, stdin /dev/null, never on the main threadPlan: Read-onlyis enough), stored in CodeBurn's own provider-scoped keychain item like ClinePassThe Copilot CLI's own
copilot-cliKeychain item is deliberately not read: it is written by a Node keyring library, so/usr/bin/securityis outside its partition list and every read would raise the macOS access dialog. Rung 4 reaches the same users because the Copilot CLI itself falls back to gh.VS Code's encrypted secret storage is out of scope by design.
Messaging
No GitHub Copilot credentials found. Usage tracking still works. To show live quota, sign in with the Copilot CLI, run gh auth login, or paste a GitHub token in Settings.The existing Connect action opens the Copilot pane.Verification
swift buildclean;swift test: 341 swift-testing + 128 XCTest pass (10 net new tests: each rung present/absent/malformed, precedence, gh probe cache and TTL, refresh-token exclusion, message text)docs/providers/copilot.mddocuments the chain; the Electron surface still implements only rung 1 (noted, out of scope)Also in this PR
Verified against a live quota payload: a Free/Individual plan reports
premium_interactionswith entitlement 0 and 0% remaining, which both the menubar and the desktop decoder rendered as a 100% used ring. Windows with entitlement 0 orunlimited: trueare now skipped in both readers (tests added; Swift 341 + 129, Electron 14, typecheck clean).