Skip to content

[Feature] Managed Codex account switching for SSH remote worktrees #4387

Closed

Description

@vthuan1889

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_HOME for the selected managed account (buildPtyHostEnv is skipped when connectionId is set — see src/main/ipc/pty.ts).
  • Codex identity comes from ~/.codex on 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:

  1. Select and manage multiple Codex accounts per SSH target (or per remote runtime) in Settings → AI Provider Accounts and/or the status-bar switcher.
  2. Remote Codex terminals use the selected managed account (via a prepared remote CODEX_HOME), not only whatever is in ~/.codex.
  3. Usage / rate limits reflect the active remote account, or the UI clearly states when that isn't available.
  4. 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

Precedent in this repo

WSL parity is a good model for SSH:

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.md lists a non-goal: "Do not redesign SSH remote Codex home handling… SSH still uses the remote user's Codex home."
  • Fix Codex hook ownership in Orca runtime #3032 (open) improves remote Codex runtime/hooks by copying one ~/.codex/auth.json into a remote Orca runtime home — useful for hooks, but not Orca-managed multi-account switching.
  • CodexAccountSelectionTarget is only 'host' | 'wsl' (src/main/codex-accounts/runtime-selection.ts).
  • codexHookService.installRemote notes 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)

  1. Extend CodexAccountSelectionTarget for SSH (e.g. { runtime: 'ssh', connectionId, targetId }).
  2. Keep credentials in Orca userData; materialize the selected launch home on the remote during launch/PTY spawn (similar to WSL, over SSH).
  3. Set remote PTY CODEX_HOME / ORCA_CODEX_HOME to that home without leaking host paths or local hook tokens (preserve the SSH env guard in pty.ts and Managed hook runtime and PTY spawn env handling drift across layers #1308 notes).
  4. Fetch rate limits from the remote launch home when possible; otherwise show a clear degraded state.
  5. Default new SSH targets to System default (~/.codex on 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 login on the server.
  • Switching accounts in Orca and starting a new remote Codex session uses the new account.
  • Host and WSL behavior is unchanged.
  • Host userData paths 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

Activity

  1. added
    size/l
    on Jun 9, 2026
  2. added
    enhancement
    on Jun 25, 2026
  3. added theissue type on Jul 12, 2026
  4. OrcaWin commented on Oct 11, 2026

    @OrcaWin
    Collaborator

    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.

  5. AmoabaKelvin commented on Nov 17, 2026

    @AmoabaKelvin
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementsize/l

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions