Skip to content

fix(menubar): find Copilot credentials beyond the legacy plugin files (#1198) - #1200

Merged
iamtoruk merged 4 commits into
mainfrom
fix/copilot-credential-discovery
Aug 31, 2026
Merged

iamtoruk merged 4 commits into
mainfrom
fix/copilot-credential-discovery

Conversation

@iamtoruk

@iamtoruk iamtoruk commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

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 ~/.copilot plus 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:

  1. hosts.json then apps.json (unchanged)
  2. ~/.copilot/config.json then settings.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 skipped
  3. COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN
  4. gh auth token (verified: a gh login token gets HTTP 200 from copilot_internal/user); cached 5 minutes, 5 s deadline, stdin /dev/null, never on the main thread
  5. A token pasted in Settings (fine-grained PAT with Plan: Read-only is enough), stored in CodeBurn's own provider-scoped keychain item like ClinePass

The Copilot CLI's own copilot-cli Keychain item is deliberately not read: it is written by a Node keyring library, so /usr/bin/security is 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 build clean; 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.md documents 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_interactions with entitlement 0 and 0% remaining, which both the menubar and the desktop decoder rendered as a 100% used ring. Windows with entitlement 0 or unlimited: true are now skipped in both readers (tests added; Swift 341 + 129, Electron 14, typecheck clean).

… 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.
@iamtoruk
iamtoruk merged commit 9ef77a1 into main Aug 31, 2026
11 checks passed
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.

Codeburn macOS menubar cannot find GitHub Copilot credentials

1 participant