feat: implement desktop account switcher for codex-auth#140
Conversation
Add a new desktop widget that allows users to switch active Codex accounts from the system tray or menu bar across Windows, macOS, and Linux. The feature enhances user convenience by providing a lightweight background process and a menu for account selection, while reusing existing registry and switch workflows. Initial implementation includes basic command parsing and menu layout, with plans for further enhancements in future phases.
Greptile SummaryThis PR swaps out the
Confidence Score: 5/5Documentation-only change; no production code is touched and the deleted brainstorm document covers an already-implemented feature. Both changed files are design brainstorm documents. The deleted file describes a feature (previous_active_account_key) that is already fully implemented across the registry, switch workflow, and tests. The new file is a well-structured design spec that correctly references existing APIs (activateAccountByKey, replaceFilePreservingPermissions, previous_active_account_key) and explicitly calls out risks. The one design gap — single-instance guard timing — is a future-phase concern with no impact on the current codebase. No files require special attention; both are documentation artifacts with no runtime impact. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant TrayIcon as Platform Adapter<br/>(windows/macos/linux)
participant MenuModel as menu_model.zig
participant SwitchAction as switch_action.zig
participant Registry as registry (account_ops)
participant AuthFile as auth.json
User->>TrayIcon: Click tray icon
TrayIcon->>MenuModel: Build account menu
MenuModel->>Registry: Load registry.json
Registry-->>MenuModel: Account list + active/previous keys
MenuModel-->>TrayIcon: Menu entries (stable account_keys)
TrayIcon-->>User: Show account menu
User->>TrayIcon: Select account
TrayIcon->>SwitchAction: switch(account_key)
SwitchAction->>Registry: "Load & sync registry"
SwitchAction->>Registry: activateAccountByKey(account_key)
Registry->>AuthFile: replaceFilePreservingPermissions
Registry-->>SwitchAction: display label
SwitchAction-->>TrayIcon: label / error
TrayIcon-->>User: Native notification "Switched to label"
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
docs/brainstorm/2026-06-04-desktop-account-switcher.md:299-313
**Single-instance guard deferred too late**
The Risks section notes "Multiple desktop processes could confuse users. Add a single-instance guard before startup install support," but the guard itself is placed in Phase 5 (Polish) while the Windows MVP lands in Phase 2. This means every Phase 2 user who accidentally runs `codex-auth desktop` twice ends up with two tray icons and two concurrent processes independently writing `auth.json`, with no protection until Phase 5 ships. Consider adding a lightweight single-instance check (e.g. a named mutex on Windows, a lock file under `CODEX_HOME`) to Phase 2 rather than only requiring it before startup install.
Reviews (1): Last reviewed commit: "feat: implement desktop account switcher..." | Re-trigger Greptile |
| - Optionally show last-known usage percentages as menu suffixes. | ||
| - Optionally add a menu item to launch `codex-auth app`. | ||
|
|
||
| ## Build And Packaging Considerations | ||
|
|
||
| The npm package currently dispatches to platform-specific native binaries through optional dependencies: | ||
|
|
||
| - `@loongphy/codex-auth-win32-x64` | ||
| - `@loongphy/codex-auth-win32-arm64` | ||
| - `@loongphy/codex-auth-darwin-x64` | ||
| - `@loongphy/codex-auth-darwin-arm64` | ||
| - `@loongphy/codex-auth-linux-x64` | ||
| - `@loongphy/codex-auth-linux-arm64` | ||
|
|
||
| The desktop feature can ship inside those platform packages. |
There was a problem hiding this comment.
Single-instance guard deferred too late
The Risks section notes "Multiple desktop processes could confuse users. Add a single-instance guard before startup install support," but the guard itself is placed in Phase 5 (Polish) while the Windows MVP lands in Phase 2. This means every Phase 2 user who accidentally runs codex-auth desktop twice ends up with two tray icons and two concurrent processes independently writing auth.json, with no protection until Phase 5 ships. Consider adding a lightweight single-instance check (e.g. a named mutex on Windows, a lock file under CODEX_HOME) to Phase 2 rather than only requiring it before startup install.
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/brainstorm/2026-06-04-desktop-account-switcher.md
Line: 299-313
Comment:
**Single-instance guard deferred too late**
The Risks section notes "Multiple desktop processes could confuse users. Add a single-instance guard before startup install support," but the guard itself is placed in Phase 5 (Polish) while the Windows MVP lands in Phase 2. This means every Phase 2 user who accidentally runs `codex-auth desktop` twice ends up with two tray icons and two concurrent processes independently writing `auth.json`, with no protection until Phase 5 ships. Consider adding a lightweight single-instance check (e.g. a named mutex on Windows, a lock file under `CODEX_HOME`) to Phase 2 rather than only requiring it before startup install.
How can I resolve this? If you propose a fix, please make it concise.
Add a new desktop widget that allows users to switch active Codex accounts from the system tray or menu bar across Windows, macOS, and Linux. The feature enhances user convenience by providing a lightweight background process and a menu for account selection, while reusing existing registry and switch workflows. Initial implementation includes basic command parsing and menu layout, with plans for further enhancements in future phases.