Skip to content

Add Copilot multi-account support#637

Open
ajmccall wants to merge 16 commits intosteipete:mainfrom
ajmccall:feat/copilot-multi-account
Open

Add Copilot multi-account support#637
ajmccall wants to merge 16 commits intosteipete:mainfrom
ajmccall:feat/copilot-multi-account

Conversation

@ajmccall
Copy link
Copy Markdown

@ajmccall ajmccall commented Apr 1, 2026

Summary

Refine Copilot multi-account support and UI. Similar to #613

This keeps legacy single-account Copilot configs working via apiKey, fixes re-auth so existing accounts are updated in place, scopes stacked multi-account cards to Copilot only and improves the settings/menu-bar account actions.

UI

Toolbar Settings
Screenshot 2026-04-01 at 23 18 14 Screenshot 2026-04-01 at 23 18 09

Changes

  • remove Copilot token-to-account migration
  • keep apiKey fallback for existing single-account users
  • update Copilot re-auth to preserve account identity/history
  • make stacked account cards Copilot-only
  • restore normal token-account menu behavior for other providers

Validation

  • ./Scripts/compile_and_run.sh

Note

  • pnpm check still hits a pre-existing unrelated SwiftLint file_length violation in Sources/CodexBar/StatusItemController+Menu.swift.

ajmccall and others added 15 commits April 1, 2026 20:50
Register .copilot in TokenAccountSupportCatalog with environment-based
injection (COPILOT_API_TOKEN), matching the existing env key used by
ProviderConfigEnvironment and ProviderTokenResolver. Uses
requiresManualCookieSource: false since Copilot authenticates via OAuth,
not cookies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add fetchGitHubUsername(token:) static method that calls GET /user with
the OAuth token to retrieve the GitHub login. Used for auto-labeling
token accounts during the multi-account add flow and migration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace single-token storage (settings.copilotAPIToken) with
multi-account storage via addTokenAccount(). After OAuth, fetches
GitHub username via /user and plan name via copilot_internal/user to
build a "username (Plan)" label. Detects duplicate accounts by
username prefix and refreshes the token instead of creating duplicates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace single-token secure field and login buttons with an "Add Account"
button that triggers OAuth device flow. The generic token accounts section
(account list, picker, remove, paste fallback) appears automatically now
that Copilot is in the TokenAccountSupportCatalog. Migration from config
apiKey is triggered via observeSettings().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When copilotAPIToken exists in config but no token accounts exist,
migrate the token to a ProviderTokenAccount with a fallback label
and clear the config key. An async Task enriches the label with the
GitHub username via /user. Migration is idempotent — guarded by
checking that token accounts are empty.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e tests

Cover the token account catalog entry (injection type, env override),
config-to-account migration (happy path, idempotent, no-op cases), and
environment precedence (token account overrides config API key). Uses
Swift Testing framework with InMemory stores matching existing patterns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ount

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the tab-style account switcher with stacked usage cards so each
account's quota is visible at once. Fix a race where switching accounts
rebuilt the menu before the async refresh completed, showing stale data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ajmccall ajmccall marked this pull request as draft April 1, 2026 22:30
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67f244ab7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ajmccall ajmccall marked this pull request as ready for review April 1, 2026 22:43
@ajmccall
Copy link
Copy Markdown
Author

ajmccall commented Apr 1, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4dadf7cb32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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