Files
magpie/docs
yetone 70ec514872 provider: a Copilot editor token GitHub refuses gives way to the Copilot CLI's sign-in of the same account, and a sign-in from magpie of that account is kept (#1238, eightHundreds)
A stale oauth_token for octocat left in ~/.config/github-copilot/apps.json
was read before everything else, so its 401 Bad credentials left Copilot
with no models although the Copilot CLI was signed in to octocat and
worked; signing in again from magpie didn't help, since the new token was
let go as the editors' own account.

- copilotToken remembers an editor token whose trade GitHub refuses (401 or
  403; tried again after an hour, or as soon as one trade works).
- copilotApp.session then uses the CLI's sign-in of the same login on the
  same host, sent as the CLI sends it, and copilotLogin reads that sign-in
  for the account from then on. A CLI signed in to another account is never
  used in its place; the error names the editors' file, and that the CLI is
  another account.
- The Usage card (loginQuota) reads the CLI's sign-in the same way when the
  editor token gets 401.
- The device sign-in asks GitHub about the editors' token of the same account
  first (copilotProbeEditor); refused, addCopilotLogin keeps magpie's token,
  standing for the account. With a working editor token it is let go as
  before.
- TestMain stubs copilotCLISecret, so no test reads the runner's keychain.

Tests: copilot_stale_editor_test.go (fake exchange, user and API servers,
temp HOME). Without the fix TestCopilotStaleEditorFallsBackToCLI and
TestCopilotStaleEditorNotAnotherAccount fail "Copilot is signed out (Bad
credentials); sign in to Copilot again", TestCopilotSignInKeptOverStaleEditor
lists octocat with the editors' gho_x, TestCopilotStaleEditorUsageReadsCLI
reads "Unauthorized". Not tried with a real stale apps.json or a real
Copilot CLI login.
2026-10-08 11:17:39 +08:00
..