Skip to content

Make switching between multiple Codex accounts easy on macOS#644

Closed
igneous-prose wants to merge 6 commits intosteipete:mainfrom
igneous-prose:codex/local-profile-manager-clean
Closed

Make switching between multiple Codex accounts easy on macOS#644
igneous-prose wants to merge 6 commits intosteipete:mainfrom
igneous-prose:codex/local-profile-manager-clean

Conversation

@igneous-prose
Copy link
Copy Markdown

@igneous-prose igneous-prose commented Apr 3, 2026

Summary

This PR makes it easy to switch between multiple Codex / ChatGPT accounts on macOS without manually copying auth files or re-running login flows.

CodexBar can now save named local profiles from the current ~/.codex/auth.json and restore them later. Because both Codex.app and the codex CLI use that auth file, switching a saved profile effectively switches the active account for both Codex Desktop and Codex CLI.

CodexBar is the UI for the workflow, but the main user benefit is simple multi-account switching for Codex on macOS.

Why This Matters

Today, switching between Codex accounts on macOS usually means manually replacing ~/.codex/auth.json or signing in again.

This PR turns that into a one-time setup:

  1. Sign into an account in Codex.app or codex.
  2. Save it as a local profile in CodexBar.
  3. Repeat for any additional accounts.
  4. Switch between saved accounts later from CodexBar.

After a switch, the restored auth is the one used by both Codex.app and the codex CLI.

What This Adds

  • A Local Profiles section in the Codex provider settings.
  • A Switch Local Profile submenu in the Codex menu bar menu.
  • Save Current Account…, which copies the current live Codex auth into ~/.codex/profiles/<name>.json.
  • Profile switching, which restores a saved profile back into ~/.codex/auth.json.
  • Reopening Codex.app after a successful switch so the desktop app picks up the restored account.

Multi-Account Workflow

This is intended to work for more than two Codex accounts.

The flow is:

  • Sign into a Codex account once in the Codex Desktop app or Codex CLI.
  • Choose Save Current Account… in CodexBar.
  • Repeat for each additional account you want to keep available.
  • After profiles are saved, switch entirely inside CodexBar from Settings or the menu bar.

There is no hard-coded account limit in this change. The practical limit is UI usability rather than the implementation.

Safety And Behavior

  • Refuses symlinked auth and profile paths.
  • Restricts switching to saved profiles under ~/.codex/profiles.
  • Confirms before closing Codex.app and any running codex CLI sessions.
  • Reopens Codex.app after a successful switch.
  • Creates private backups in ~/.codex/auth-backups before switching and prunes older backups.
  • Hides redundant save actions when the current live auth already matches a saved profile.
  • Keeps the existing Accounts UI close to the current CodexBar layout and isolates the new workflow in a separate Local Profiles section.

Screenshots

Menu Bar Switching

Menu bar switching

Settings Local Profiles Section

Settings local profiles section

Settings Help Tooltip

Settings help tooltip

Verification

  • swift build
  • ./Scripts/compile_and_run.sh
  • Manual checks for:
    • save current account
    • switch from Settings
    • switch from the menu bar
    • hide Save Current Account… when the current live auth already matches a saved profile
  • corepack pnpm check still reports an unrelated pre-existing formatting issue in Sources/CodexBar/Providers/Codex/UsageStore+CodexAccountState.swift
  • swift test --filter ... is still blocked by unrelated pre-existing test-compilation failures in existing test files such as SettingsStoreTests.swift and StatusItemAnimationTests.swift

Notes

  • The menu bar stays intentionally minimal; the extra guidance lives in Settings only.

@igneous-prose igneous-prose changed the title Add local Codex profile management Make Codex account switching easier with saved local profiles Apr 3, 2026
@igneous-prose igneous-prose marked this pull request as ready for review April 3, 2026 20:50
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: c41ad3ad0b

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

@igneous-prose igneous-prose changed the title Make Codex account switching easier with saved local profiles Make switching between multiple Codex accounts easy on macOS Apr 3, 2026
Copy link
Copy Markdown

jskoiz commented Apr 4, 2026

There is already a menu switcher in StatusItemController+Menu.swift (line 692), selection handling in StatusItemController+Menu.swift (line 710), and UI in StatusItemController+SwitcherViews.swift (line 899 that allows you to switch between multiple codex accounts.

@ratulsarna
Copy link
Copy Markdown
Collaborator

Thanks for the PR @igneous-prose ! This feature was already in the works but since we had the same idea at around the same time, I'll be crediting you for the idea as well :)

@ratulsarna ratulsarna closed this Apr 5, 2026
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.

3 participants