Skip to content

Fix Copilot CLI auth popups after Chamber sign-in#399

Open
ianphil wants to merge 5 commits into
masterfrom
fix/sdk-no-auto-login
Open

Fix Copilot CLI auth popups after Chamber sign-in#399
ianphil wants to merge 5 commits into
masterfrom
fix/sdk-no-auto-login

Conversation

@ianphil

@ianphil ianphil commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Stops bundled Copilot CLI auth prompts from appearing after Chamber has already authenticated the user.

Notable changes

  • Passes Chamber's active keytar-backed GitHub OAuth token into SDK-created Copilot clients via gitHubToken and forces useLoggedInUser: false so the SDK adds --no-auto-login.
  • Applies the same no-auto-login posture to desktop, loopback server, Genesis custom mind creation, and chamber-copilot ACP workers.
  • Reloads/reset auth-bound runtimes on login, account switch, and logout so stale child CLI processes cannot retain old token state.
  • Hardens ACP reset behavior against in-flight startup races and ambient COPILOT_SDK_AUTH_TOKEN fallback.
  • Adds changelog and regression coverage for SDK auth forwarding, auth lifecycle reset, and ACP stale-start/tool-availability behavior.

Issue

No tracking issue.

Validation

  • npm run lint
  • npm test — 194 files / 2004 tests passed
  • npm run smoke:sdk
  • Manual soak: Chamber left running for several hours with no repeated browser auth popups

Skipped smoke

  • Packaging smoke skipped: no packaging config, runtime pin, installer, or first-launch packaging path changed.

Ian Philpot and others added 5 commits June 23, 2026 09:50
The bundled @github/copilot CLI was spawned without useLoggedInUser: false,
which left it free to start its own GitHub device-flow whenever it couldn't
validate auth — opening a browser window on every CopilotClient restart.
Overnight retry loops produced ~100 open browser tabs.

Fix:
- Add getGitHubToken callback to CopilotClientFactoryOptions. When provided,
  the active OAuth token is forwarded to the SDK as gitHubToken (injected via
  COPILOT_SDK_AUTH_TOKEN env var). This implicitly sets useLoggedInUser to
  false (--no-auto-login) in the CLI args.
- Always set useLoggedInUser: false explicitly so the CLI never starts its
  own device flow regardless of whether a token is available. If the token
  is missing the CLI fails the operation cleanly; Chamber surfaces it in
  the chat UI rather than opening a browser.
- Wire the callback in main.ts via listStoredGitHubCredentials + the active
  login from ConfigService — same resolution logic already used by AuthService.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extend the no-auto-login invariant across the server composition root and the ACP bundled CLI path, and reload minds on logout so already-started SDK clients do not retain a copied token after credentials are removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Route Genesis custom mind creation through the token-aware SDK factory, restart server SDK clients after auth state changes, and reset ACP connections so prewarmed or long-lived CLI workers cannot keep stale auth state across login, switch, or logout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Invalidate in-flight ACP starts during auth resets, keep a freshly prewarmed ACP store available through mind reloads, and cover the stale-start race plus first-mind tool availability with regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Strip ambient COPILOT_SDK_AUTH_TOKEN from no-token ACP launches, only pass --auth-token-env when Chamber supplies the keytar token, and prevent stale yolo-start failures from assigning old safe-only connections after auth reset.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant