Skip to content

Multiple OpenAI/Codex Accounts#569

Open
Rag30 wants to merge 13 commits intosteipete:mainfrom
Rag30:main
Open

Multiple OpenAI/Codex Accounts#569
Rag30 wants to merge 13 commits intosteipete:mainfrom
Rag30:main

Conversation

@Rag30
Copy link

@Rag30 Rag30 commented Mar 18, 2026

Multi-Account Codex Support with Per-Account Dashboard

What it does
Adds full multi-account support for Codex — add, manage, and monitor multiple OpenAI accounts from a single CodexBar instance. Accounts with the same email but different workspaces are fully isolated.

Account Management
Add accounts via OAuth (codex auth) or API key, each with its own CODEX_HOME
Drag-to-reorder, rename (pencil icon), delete (edit mode), set default
"CodexBar accounts only" mode — ignore ~/.codex, use only explicitly added accounts

Per-account Session/Weekly/Code Review usage bars in the menu dropdown with account switcher tabs
Per-Account OpenAI Dashboard
OpenAI Web Dashboard" toggle controls dashboard button visibility
Each account row shows "Dashboard" or "Login to Dashboard" based on login state
Per-account cookie isolation keyed by CODEX_HOME path — same-email accounts on different workspaces get separate sessions
"Usage Dashboard" / "Login to OpenAI Dashboard" in menu dropdown reflects active account state
Logout option available in account edit mode

Screenshot 2026-03-22 at 10 33 01 PM

Copy link

@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: 9ee0530c99

ℹ️ 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".

@ratulsarna
Copy link
Collaborator

@codex review

Copy link

@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: c99e55a00b

ℹ️ 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".

@Rag30
Copy link
Author

Rag30 commented Mar 20, 2026

@codex review

Copy link

@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: ec149a8ca4

ℹ️ 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".

@Rag30
Copy link
Author

Rag30 commented Mar 20, 2026

@codex review

Copy link

@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: 9f1c28541c

ℹ️ 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".

Rag30 added 4 commits March 21, 2026 13:19
Token-account and other provider config updates bump configRevision; rebuilding
every NSStatusItem via removeStatusItem reflows the system menu bar and makes
other apps' extras flicker. Rebuild only when provider order changes.

Made-with: Cursor
Resolve menu/icon/widget credits from codexActiveMenuCredits using
allAccountCredits for add-on accounts; primary keeps RPC/dashboard store.
Remove primary-only notice; show unlimited and loading states; add tests.

Made-with: Cursor
…rimary missing

- Use TokenAccountSupportCatalog envOverride for per-account credit refresh; load OPENAI_API_KEY-only env as API-key creds
- isDefaultTokenAccountActive + display index for fetches/UI when ~/.codex primary is gone
- Tests for env load and Claude token-account selection

Made-with: Cursor
Rag30 and others added 4 commits March 21, 2026 14:48
…ment

- Introduced a new setting to allow CodexBar to ignore ~/.codex as an implicit account, requiring users to manage accounts explicitly through the UI.
- Updated various components to reflect this change, including adjustments to account selection logic and UI elements.
- Enhanced the handling of account-related actions and settings to improve user experience and clarity.

Made-with: Cursor
Move Multi-Account toggles above the Accounts section so toggling
never shifts scroll position. Rename Use → Default/Make Default,
add drag-and-drop reordering, gate multi-account UI behind a toggle.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add per-account WKWebView login windows for chatgpt.com dashboard,
replacing the failed synthetic OAuth cookie approach. Each account
gets isolated cookie storage. Dashboard login auto-opens after
OAuth account creation when web extras is enabled.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Rag30 Rag30 changed the title Multiple OpenAI OAuth Multiple OpenAI/Codex Accounts Mar 22, 2026
Rag30 and others added 2 commits March 22, 2026 22:01
- Add per-account WKWebsiteDataStore keyed by CODEX_HOME path (not email)
  so accounts with the same email but different workspaces get separate
  dashboard sessions
- Add "OpenAI Web Dashboard" toggle in Multi-Account settings section
- Show "Dashboard" / "Login to Dashboard" button per account row based
  on individual login state, with logout option in edit mode
- Add "Usage Dashboard" / "Login to OpenAI Dashboard" in menu dropdown
  (below Buy Credits) reflecting active account's dashboard state
- Fix WKWebView and rename TextField keyboard input by switching to
  NSApp.activationPolicy(.regular) temporarily
- Fix dashboard window not closing Settings when dismissed
- View-only mode for already-logged-in accounts (no auto-close polling)
- Track dashboard login state via observable set on UsageStore for
  reactive SwiftUI updates
- Suppress cost data when "CodexBar accounts only" is on with no accounts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Each account uses its own WKWebView cookie store via the dashboard login
window, making browser cookie import redundant and error-prone.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Rag30
Copy link
Author

Rag30 commented Mar 23, 2026

@ratulsarna added features and streamlined codex experience more:

// Multi-account support: add, reorder, and switch between multiple Codex accounts with drag-and-drop
// Per-account OpenAI dashboard login with workspace-isolated WKWebView cookie stores (no browser cookie import)
// Reactive dashboard state tracking, menu bar dashboard button, and inline account rename/logout controls

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Rag30
Copy link
Author

Rag30 commented Mar 23, 2026

@codex review

Copy link

@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: d04b7cbe87

ℹ️ 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".

Rag30 and others added 2 commits March 23, 2026 09:35
…ation history

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

P1: Clear all cached credits/dashboard/cost data when codexExplicitAccountsOnly
has no accounts, not just snapshots/errors/sourceLabel.

P1: Reset selected token account to primary when multi-account toggle is turned
off, so Codex stops fetching against a hidden CODEX_HOME override.

P2: Use stable ~/.codex path as the default account dashboard key instead of the
editable display label, so renaming doesn't break dashboard session persistence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Rag30
Copy link
Author

Rag30 commented Mar 23, 2026

@codex review

Copy link

@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

let targetEmail = self.codexAccountEmailForOpenAIDashboard()
self.handleOpenAIWebTargetEmailChangeIfNeeded(targetEmail: targetEmail)

P1 Badge Reuse the account identifier when refreshing dashboard data

In multi-account mode, the dashboard login window stores cookies in a WKWebsiteDataStore keyed by the per-account identifier (CODEX_HOME path / token), but refreshOpenAIDashboardIfNeeded() still derives the fetch key from codexAccountEmailForOpenAIDashboard(). For any added Codex account, that means the post-login refresh reads a different cookie store than the one the user just signed into, so "Login to Dashboard" can immediately fall back to a login-required state; accounts that share the same email also collapse onto one dashboard session.

ℹ️ 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".

Comment on lines +605 to +608
if let dashboardLogin = self.descriptor.dashboardLogin {
let loggedIn = self.descriptor.isDashboardLoggedIn?(account.token) ?? false
Button(loggedIn ? "Dashboard" : "Login to Dashboard") {
dashboardLogin(account.token)

Choose a reason for hiding this comment

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

P2 Badge Stop passing raw API keys as dashboard identifiers

For Codex API-key accounts, account.token is the literal apikey:<secret> payload (see the add flow in PreferencesProviderSettingsRows.swift:705-710). Forwarding that value into the dashboard login/logout path here means OpenAIDashboardWebsiteDataStore.markDashboardLoggedIn will persist the raw API key in OpenAIDashboardLoggedInEmails under UserDefaults, and the same secret also rides around in menu payloads. Any user who clicks Dashboard/Login on an API-key row ends up copying the key outside the token-account store.

Useful? React with 👍 / 👎.

Comment on lines +294 to +297
func loginMenuAction(context _: ProviderMenuLoginContext)
-> (label: String, action: MenuDescriptor.MenuAction)?
{
("Add Account...", .addTokenAccount(.codex))

Choose a reason for hiding this comment

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

P2 Badge Hide Add Account until Multiple Accounts is enabled

When codexMultipleAccountsEnabled is off, both the menu switcher (StatusItemController+Menu.swift:719-726) and the Accounts section (PreferencesProvidersPane.swift:198-202) are hidden, but loginMenuAction() still exposes Add Account… here. Because SettingsStore.addTokenAccount() makes the newly added row active immediately, clicking that menu item can silently switch CodexBar onto a hidden account that the user cannot select, rename, or remove until they discover the toggle in Options.

Useful? React with 👍 / 👎.

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.

2 participants