[Feature] Managed Codex account switching for SSH remote worktrees
Summary
Orca's managed Codex account switcher works on host and WSL, but not on SSH remote worktrees. On SSH, Codex uses the remote user's ~/.codex/auth.json; changing the account in Orca Settings or the status bar does not affect terminals on the remote host.
I'd like SSH worktrees to support the same managed multi-account Codex workflow as local and WSL.
Problem
When using an SSH worktree:
- Remote PTYs are spawned without Orca-injected
CODEX_HOMEfor the selected managed account (buildPtyHostEnvis skipped whenconnectionIdis set — seesrc/main/ipc/pty.ts). - Codex identity comes from
~/.codexon the remote machine, not from Orca's managed account list. - To use a different account, I must run
codex login, a third-party switcher, or use separate Linux users on the server.
I use multiple Codex accounts for quota/plan rotation. Local and WSL switching in Orca is enough there; SSH is the gap.
Expected behavior
For worktrees attached to an SSH target:
- Select and manage multiple Codex accounts per SSH target (or per remote runtime) in Settings → AI Provider Accounts and/or the status-bar switcher.
- Remote Codex terminals use the selected managed account (via a prepared remote
CODEX_HOME), not only whatever is in~/.codex. - Usage / rate limits reflect the active remote account, or the UI clearly states when that isn't available.
- Switching accounts applies to new remote Codex sessions, with an optional restart prompt for existing sessions (similar to local pane-scoped restart UX).
Why this matters
- SSH worktrees are documented as a first-class feature: https://www.onorca.dev/docs/ssh
- The README highlights Account Switcher & Usage Tracking as a core workflow.
- The current behavior is easy to misread: the UI implies global Codex account control, but SSH terminals ignore it.
Precedent in this repo
WSL parity is a good model for SSH:
- #2649 — runtime-aware managed accounts (
hostvswsl) - #4318 — WSL launch homes with isolated
auth.json - #4323 — shared Codex SQLite/state across launch homes
SSH could add a third runtime (e.g. runtime: 'ssh' + connectionId / targetId) with managed homes on the remote host (via relay/SFTP), not on the laptop's userData.
Current behavior (as I understand it)
docs/codex-account-auth-isolated-launch-homes.mdlists a non-goal: "Do not redesign SSH remote Codex home handling… SSH still uses the remote user's Codex home."- #3032 (open) improves remote Codex runtime/hooks by copying one
~/.codex/auth.jsoninto a remote Orca runtime home — useful for hooks, but not Orca-managed multi-account switching. CodexAccountSelectionTargetis only'host' | 'wsl'(src/main/codex-accounts/runtime-selection.ts).codexHookService.installRemotenotes that Codex host-managed hook registration for SSH is not available yet.
This issue asks to revisit the SSH non-goal now that host/WSL launch homes are in place.
Proposed direction (suggestion)
- Extend
CodexAccountSelectionTargetfor SSH (e.g.{ runtime: 'ssh', connectionId, targetId }). - Keep credentials in Orca
userData; materialize the selected launch home on the remote during launch/PTY spawn (similar to WSL, over SSH). - Set remote PTY
CODEX_HOME/ORCA_CODEX_HOMEto that home without leaking host paths or local hook tokens (preserve the SSH env guard inpty.tsand #1308 notes). - Fetch rate limits from the remote launch home when possible; otherwise show a clear degraded state.
- Default new SSH targets to System default (
~/.codexon the remote) until the user configures managed accounts.
Acceptance criteria
- [ ] I can store two or more managed Codex accounts and pick the active one per SSH target.
- [ ] A new Codex terminal in an SSH worktree uses the selected account without manual
codex loginon the server. - [ ] Switching accounts in Orca and starting a new remote Codex session uses the new account.
- [ ] Host and WSL behavior is unchanged.
- [ ] Host
userDatapaths and local hook tokens are not injected into remote PTY env. - [ ] Docs updated (
/docs/ssh, usage tracking) to describe remote managed accounts vs system default.
Alternatives considered
| Approach | Pros | Cons |
|---|---|---|
Document-only: use codex-switch on the server |
No Orca work | Worse UX vs host/WSL |
| One SSH target = one Linux user | Strong isolation | High operational cost |
Overwrite remote ~/.codex on switch |
Simple mental model | Mutates shared global Codex state on the server |
Environment
- Orca version: (not specified — reporter on latest public release)
- Client OS: Linux (TrueNAS host environment)
- SSH target: (user to fill in if needed)
- Remote Codex CLI: (user to fill in if needed)
Related
- #3032 — remote Codex runtime home (single-auth copy)
- #2323 — SSH workspace sync /
codex resume - #4318, #2649 — WSL parity
docs/codex-account-auth-isolated-launch-homes.md
Update after the SSH relay was retired (#27214, #27215): SSH terminals now start inside the host's managed Orca server, so the relay-era buildPtyHostEnv/connectionId detail no longer applies. The request still stands, though: the status-bar switcher only targets this computer or a paired server, so for an SSH workspace Codex still uses the host's own ~/.codex (or that server's account selection) instead of the account picked on the desktop.
This is fixed on main and shipped in v1.4.261: SSH projects now run on the host's own managed Orca server, so the status-bar Codex switcher, Add Account and usage all act on that host (#27214, #27687, #31461, #29430).
Please update to the latest Orca and try again. If you still see it, comment here and we'll reopen.