Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(codex-accounts): switch a running Codex node's account on an SSH host

review668fe75c91a5
diff --git a/CLAUDE.md b/CLAUDE.md
index 81b4bd1be..c8d4983a6 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -3095,8 +3095,19 @@ command-bearing opens; this does not add a human-confirm dialog or change mobile
on an SSH host got a Claude dir that does not exist and NO `CODEX_HOME` — its codex silently ran
as the host's system login (`remoteCodexTmuxEnvArgs` existed with no caller). The system Codex
account is left to the host's own env (a remote `CODEX_HOME` of the user's — a snap remap — must
- win). The running-node **Switch Codex account** is shown disabled on SSH nodes: its three-phase
- switch plans rollouts in LOCAL homes only.
+ win).
+ - **Switch Codex account on an SSH node** (2026-09) does NOT use the local three-phase reservation
+ (it plans rollouts in LOCAL homes). It is one host-side exposure —
+ `codexAccounts.switchThreadRemote` → `SshProjectManager.remoteCodexSwitchThread` →
+ `remoteCodexExposeThread` (relay `expose-thread`): resolve the thread across every account
+ catalog on the host, hardlink the one authoritative rollout into the target home, verify the
+ target's app-server discovers it, roll the link back if not; an ambiguous thread is refused.
+ Then the usual still-eligible check and a restart-shell recycle, with the rebind riding
+ `beforeRecycle` (never a separate setNodes). A hardlink, not a copy: both accounts see ONE file,
+ so there is no diverged-copy case. Needs the relay runtime on the host (node + codex + curl);
+ without it the switch fails with a notice and nothing changes. `planCodexAccountSwitch` now
+ refuses a target on another machine than the node (`hostKey`) — the switch never crosses
+ machines (moving a local conversation to a host is `transferThreadToSsh`, a separate flow).
- **Linked accounts** (`ClaudeAccount.configDir`) — a PRE-EXISTING local config
dir the user already drives themselves (`export CLAUDE_CONFIG_DIR=~/.claude-2; claude …` in a
plain terminal) adopted as a first-class account without a login node. Settings → Accounts →
diff --git a/docs/codex-accounts-acceptance.md b/docs/codex-accounts-acceptance.md
index 9bd1eb22a..af6b432a1 100644
--- a/docs/codex-accounts-acceptance.md
+++ b/docs/codex-accounts-acceptance.md
@@ -53,7 +53,11 @@ Codex install + a **logged-in 2nd managed account**. Headless CI cannot run them
conversation to an SSH account, then **recycle** the node onto the host. Owed on Mac + real host.
- [ ] **The imperative pane-recycle glue** (commit → rebind → restartShell → finish) + a **live SSH
remote-account switch.** The pure logic + the main-side switch are unit-tested; the imperative
- renderer sequencing is only exercised against the running app.
+ renderer sequencing is only exercised against the running app. The SSH switch is wired
+ (2026-09: node menu / kanban card → `switchThreadRemote` → relay `expose-thread` on the host →
+ recycle). VERIFY on a real host: switch an idle SSH Codex node A→B, the pane resumes the SAME
+ thread under B's `CODEX_HOME` (`echo $CODEX_HOME`, then the conversation history), and B's
+ usage moves; switch back B→A.
- [ ] **Remote-host account LIFECYCLE** (add / login / remove **on** an SSH host). Wired 2026-09: the
machine panel's Add creates the home ON the host (`remoteCodexAccountAdd`), opens
`codex login --device-auth` in the host's tmux under that account's `CODEX_HOME`, and polls the
diff --git a/src/main/codex-accounts.remote.test.ts b/src/main/codex-accounts.remote.test.ts
index 78a2df005..8d51426d9 100644
--- a/src/main/codex-accounts.remote.test.ts
+++ b/src/main/codex-accounts.remote.test.ts
@@ -33,7 +33,8 @@ const mgr = {
remoteCodexAccountIdentity: vi.fn(async (): Promise<{ email: string | null } | null> => ({
})),
- remoteCodexAccountRemove: vi.fn(async () => true)
+ remoteCodexAccountRemove: vi.fn(async () => true),
+ remoteCodexSwitchThread: vi.fn(async () => {})
}
const sender = { id: 1, isDestroyed: () => false, once: () => {}, removeListener: () => {} }
const call = (channel: string, ...args: any[]) => h.handlers[channel]({ sender }, ...args)
@@ -104,3 +105,26 @@ describe('Codex account verbs over SSH', () => {
await expect(call(IPC.codexAccountsRemove, 'acct1', CTX)).rejects.toThrow(/SSH host/)
})
})
+
+describe('Codex running-node switch over SSH', () => {
+ it('exposes the thread to the target on the host behind the project', async () => {
+ await call(IPC.codexAccountsSwitchThreadRemote, 'thread-1', 'acc2', ['acc1', 'acc2'], CTX)
+ expect(mgr.remoteCodexSwitchThread).toHaveBeenCalledWith('p1', 'thread-1', 'acc2', ['acc1', 'acc2'])
+ // To the host's system account (no id) too.
+ await call(IPC.codexAccountsSwitchThreadRemote, 'thread-1', undefined, ['acc1'], CTX)
+ expect(mgr.remoteCodexSwitchThread).toHaveBeenLastCalledWith('p1', 'thread-1', undefined, ['acc1'])
+ })
+
+ it('refuses a target that is not one of the host accounts, a bad id, and a missing ctx', async () => {
+ await expect(
+ call(IPC.codexAccountsSwitchThreadRemote, 'thread-1', 'elsewhere', ['acc1'], CTX)
+ ).rejects.toThrow(/not on this host/)
+ await expect(
+ call(IPC.codexAccountsSwitchThreadRemote, '../x', 'acc1', ['acc1'], CTX)
+ ).rejects.toThrow(/Invalid/)
+ await expect(
+ call(IPC.codexAccountsSwitchThreadRemote, 'thread-1', 'acc1', ['acc1'])
+ ).rejects.toThrow(/SSH project is required/)
+ expect(mgr.remoteCodexSwitchThread).not.toHaveBeenCalled()
+ })
+})
diff --git a/src/main/codex-accounts.ts b/src/main/codex-accounts.ts
index 773eee55e..e28724648 100644
--- a/src/main/codex-accounts.ts
+++ b/src/main/codex-accounts.ts
@@ -357,6 +357,45 @@ export function initCodexAccounts(getSshManager?: () => SshProjectManager | unde
}
})
+ // ---- The SSH switch: one host-side exposure --------------------------------------------------
+ // A node on an SSH host keeps its conversation in that host's account homes, so the three-phase
+ // LOCAL reservation below has nothing to plan. The host primitive is already atomic and
+ // self-verifying (hardlink + discover-or-roll-back), and the credentials never move: only the
+ // rollout's directory entry does. Refused while this build is removing either account.
+ ipcMain.handle(
+ IPC.codexAccountsSwitchThreadRemote,
+ async (
+ _event,
+ threadId: string,
+ targetAccountId: string | undefined,
+ hostAccountIds: unknown,
+ ctx?: { projectId?: string }
+ ) => {
+ if (typeof threadId !== 'string' || !SAFE_THREAD_ID.test(threadId)) {
+ throw new Error('Invalid Codex account switch request')
+ }
+ if (targetAccountId) assertCodexAccountId(targetAccountId)
+ if (!Array.isArray(hostAccountIds) || hostAccountIds.some((id) => typeof id !== 'string')) {
+ throw new Error('Invalid Codex account switch request')
+ }
+ for (const id of hostAccountIds as string[]) assertCodexAccountId(id)
+ if (targetAccountId && !(hostAccountIds as string[]).includes(targetAccountId)) {
+ throw new Error('The target Codex account is not on this host')
+ }
+ if (targetAccountId && removingCodexAccounts.has(targetAccountId)) {
+ throw new Error('Codex account removal is in progress')
+ }
+ const remote = remoteFor(ctx)
+ if (!remote) throw new Error('An SSH project is required for a remote Codex switch')
+ await remote.mgr.remoteCodexSwitchThread(
+ remote.projectId,
+ threadId,
+ targetAccountId,
+ hostAccountIds as string[]
+ )
+ }
+ )
+
// ---- The three-phase, owner-authorized, TTL-bounded switch (§4.1 / Properties 5, 10) ----------
ipcMain.handle(
diff --git a/src/main/remote-ssh/ssh-project.test.ts b/src/main/remote-ssh/ssh-project.test.ts
index 8e9d7b1bc..41cdc2070 100644
--- a/src/main/remote-ssh/ssh-project.test.ts
+++ b/src/main/remote-ssh/ssh-project.test.ts
@@ -7,6 +7,7 @@ import { SshProjectManager, lastSshErrorLine } from './ssh-project'
import { AskpassServer } from './ssh-askpass'
import { AppSshAgent } from './ssh-agent'
import { controlPathFor } from '../../core/remote-ssh/control-master'
+import { remoteCodexSocket } from '../../core/codex-accounts-core'
import type { SshConnection } from '@shared/ssh'
const conn: SshConnection = { host: 'h', user: 'u' }
@@ -2902,6 +2903,34 @@ describe('SshProjectManager — remote Codex account lifecycle (Task 6.1, Proper
})
})
+describe('SshProjectManager.remoteCodexSwitchThread — the SSH leg of a running-node switch', () => {
+ it('exposes the thread to the target ON the host, resolving it across every host account', async () => {
+ const cm = await makeCodexMgr()
+ await cm.mgr.remoteCodexSwitchThread('p1', 'thread1', 'acc2', ['acc1', 'acc2'])
+ const expose = cm.runCalls.find((c) => c.cmd.includes('expose-thread'))!.cmd
+ // Target socket first, then the thread, then every catalog: system + both managed accounts.
+ expect(expose).toContain(`expose-thread '${remoteCodexSocket(cm.home, 'acc2')}' 'thread1'`)
+ for (const id of [undefined, 'acc1', 'acc2']) {
+ expect(expose).toContain(`'${remoteCodexSocket(cm.home, id)}'`)
+ }
+ })
+
+ it('refuses a bad id, an unconnected project, and passes the host refusal through', async () => {
+ const cm = await makeCodexMgr({
+ handler: (cmd) => (cmd.includes('expose-thread') ? { code: 69 } : undefined)
+ })
+ await expect(cm.mgr.remoteCodexSwitchThread('p1', 'bad id!', 'acc1', ['acc1'])).rejects.toThrow(
+ /Invalid Codex thread id/
+ )
+ await expect(cm.mgr.remoteCodexSwitchThread('nope', 'thread1', 'acc1', ['acc1'])).rejects.toThrow(
+ /not connected/
+ )
+ await expect(cm.mgr.remoteCodexSwitchThread('p1', 'thread1', 'acc1', ['acc1'])).rejects.toThrow(
+ /unavailable or ambiguous/
+ )
+ })
+})
+
describe('SshProjectManager — atomic remote import (Task 6.2, Property 2 + 11)', () => {
const REL = 'sessions/2026/08/19/rollout-x.jsonl'
diff --git a/src/main/remote-ssh/ssh-project.ts b/src/main/remote-ssh/ssh-project.ts
index a585ed734..8d6f8e784 100644
--- a/src/main/remote-ssh/ssh-project.ts
+++ b/src/main/remote-ssh/ssh-project.ts
@@ -2095,6 +2095,27 @@ export class SshProjectManager {
}
}
+ /**
+ * The SSH leg of a running Codex node's account SWITCH: expose the node's conversation to
+ * `targetAccountId` ON THE HOST (`remoteCodexExposeThread` — hardlink the one authoritative
+ * rollout into the target home, verify the target's app-server discovers it, roll the link back
+ * if not). `hostAccountIds` are every managed account on this host: the thread is resolved
+ * across all of their catalogs, and more than one distinct rollout is refused as ambiguous.
+ * Throws when the host is not connected or cannot run the relay.
+ */
+ async remoteCodexSwitchThread(
+ projectId: string,
+ threadId: string,
+ targetAccountId: string | undefined,
+ hostAccountIds: string[]
+ ): Promise<void> {
+ if (targetAccountId) assertCodexAccountId(targetAccountId)
+ if (!ACCOUNT_ID_RE.test(threadId)) throw new Error('Invalid Codex thread id')
+ const c = this.conns.get(projectId)
+ if (!c) throw new Error('The SSH project is not connected')
+ await this.remoteCodexExposeThread(c.controlPath, targetAccountId, threadId, hostAccountIds)
+ }
+
/**
* Atomic remote import (Property 2 + 11): copy one authoritative LOCAL rollout into a remote
* account home so its conversation id survives the machine hop. The source stays untouched; the
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 35d7b2129..1008e8cdd 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -583,6 +583,8 @@ const api: NodeTerminalApi = {
commitSwitch: (token) => ipcRenderer.invoke(IPC.codexAccountsCommitSwitch, token),
finishSwitch: (token) => ipcRenderer.invoke(IPC.codexAccountsFinishSwitch, token),
rollbackSwitch: (token) => ipcRenderer.invoke(IPC.codexAccountsRollbackSwitch, token),
+ switchThreadRemote: (threadId, targetAccountId, hostAccountIds, ctx) =>
+ ipcRenderer.invoke(IPC.codexAccountsSwitchThreadRemote, threadId, targetAccountId, hostAccountIds, ctx),
transferThreadToSsh: (threadId, cwd, projectId, targetAccountId, sourceAccountId) =>
ipcRenderer.invoke(
IPC.codexAccountsTransferThreadToSsh,
diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.ts
index e5790c1c6..2b4858a5a 100644
--- a/src/renderer/bridge/stubs.ts
+++ b/src/renderer/bridge/stubs.ts
@@ -393,6 +393,7 @@ export function buildStubApi(): Omit<
commitSwitch: U('codexAccounts.commitSwitch'),
finishSwitch: U('codexAccounts.finishSwitch'),
rollbackSwitch: U('codexAccounts.rollbackSwitch'),
+ switchThreadRemote: U('codexAccounts.switchThreadRemote'),
transferThreadToSsh: U('codexAccounts.transferThreadToSsh')
},
transcripts: {
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index f17188c19..c48395204 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -6488,6 +6488,7 @@ export function Canvas() {
cwd?: string
accountId?: string
ssh?: boolean
+ hostKey?: string
sessionId?: string
state?: string
} => {
@@ -6498,6 +6499,7 @@ export function Canvas() {
cwd: n?.data.cwd as string | undefined,
accountId: (n?.data.accountId as string | undefined) || undefined,
ssh: !!n?.data.ssh,
+ hostKey: n?.data.ssh ? sshHostKey(n.data.ssh as SshServer) : undefined,
sessionId: restartSessionId(st?.sessionId, n?.data.agentSessionId),
state: st?.state
}
@@ -6522,6 +6524,78 @@ export function Canvas() {
return
}
const { plan } = decision
+ // SSH node: its conversation and account homes are on the HOST. One host-side exposure
+ // (hardlink the rollout into the target home, verified discoverable there) replaces the
+ // local three-phase reservation, then the same recycle resumes the SAME thread id under the
+ // target's CODEX_HOME (the remote spawn scopes it by provider).
+ const hostKey = snapshot().hostKey
+ if (hostKey) {
+ const active = useProjects.getState().getProject(useProjects.getState().activeProjectId)
+ const projectId =
+ (active?.ssh &&
+ sshHostKey(active.ssh.server) === hostKey &&
+ useSshConn.getState().byProject[active.id]
+ ? active.id
+ : undefined) ?? connectedProjectIdForHost(hostKey)
+ if (!projectId) {
+ setNotice({
+ kind: 'error',
+ text: `${hostKey} is not connected — reconnect the project, then switch. Nothing was changed.`
+ })
+ return
+ }
+ const hostAccountIds = useSettings
+ .getState()
+ .settings.codexAccounts.filter((a) => a.host === hostKey && !a.pending)
+ .map((a) => a.id)
+ try {
+ await codexApi.switchThreadRemote(plan.sessionId, plan.targetAccountId, hostAccountIds, {
+ projectId
+ })
+ } catch {
+ setNotice({
+ kind: 'error',
+ text:
+ `The Codex account switch failed on ${hostKey} — the conversation could not be made ` +
+ 'available to that account (is Codex set up on the host?). Nothing was changed.'
+ })
+ return
+ }
+ // The exposure took seconds. The linked rollout is harmless on its own (both accounts now
+ // see the same conversation), but the pane is only recycled if it is STILL the exact idle
+ // conversation the user chose.
+ if (!codexAccountSwitchStillEligible(plan.expected, snapshot())) {
+ setNotice({
+ kind: 'error',
+ text: 'This session changed while the switch was preparing — nothing was changed.'
+ })
+ return
+ }
+ const fn = agentRestartFn(nodeId)
+ // The rebind rides the closure's own node update (`beforeRecycle`), so the respawn is
+ // guaranteed to launch under the target account — a separate setNodes in the same tick can
+ // be dropped by React Flow's update queue.
+ const outcome = fn
+ ? await settleRestart(() =>
+ fn(undefined, undefined, true, undefined, async () => ({
+ accountId: plan.targetAccountId
+ }))
+ )
+ : 'not-eligible'
+ if (outcome === 'restarted') markDirty()
+ setNotice(
+ outcome === 'restarted'
+ ? { kind: 'info', text: 'Codex account switched — conversation resumed.' }
+ : {
+ kind: 'error',
+ text:
+ outcome === 'not-eligible'
+ ? 'Switch skipped: this session is busy or not attached — try again once its turn is done.'
+ : 'Switch skipped: Codex did not quit in time. Nothing was changed.'
+ }
+ )
+ return
+ }
let token: string | undefined
try {
const res = await codexApi.switchThread(
@@ -6817,24 +6891,12 @@ export function Canvas() {
(a) => !a.pending && (hostKey ? a.host === hostKey : !a.host)
)
if (onMachine.length === 0) return []
- // The three-phase switch (`switchThread`) plans and links rollouts in LOCAL
- // homes only; for a node on an SSH host it could only fail. Say so instead of
- // offering rows that roll back — the host-side switch is a follow-up.
- if (hostKey)
- return [
- {
- label: 'Switch Codex account',
- icon: <IconSwitch />,
- disabled: true,
- hint: 'Switching Codex accounts is not available for SSH sessions yet.',
- onClick: () => {}
- }
- ] as MenuItem[]
const currentAccountId = (n?.data.accountId as string | undefined) || undefined
- const systemCodexLabel = systemAccountDisplay(
- undefined,
- useSystemCodexAccount.getState().email
- )
+ // The system row names ITS machine: an SSH node's is the host's own `~/.codex`, whose
+ // login this machine's system email says nothing about.
+ const systemCodexLabel = hostKey
+ ? (useSystemCodexAccount.getState().remoteEmails[hostKey] ?? `System account (${hostKey})`)
+ : systemAccountDisplay(undefined, useSystemCodexAccount.getState().email)
const row = (
id: string | undefined,
label: string
diff --git a/src/renderer/canvas/codex-account-ops.test.ts b/src/renderer/canvas/codex-account-ops.test.ts
index 2348b1224..d369c54df 100644
--- a/src/renderer/canvas/codex-account-ops.test.ts
+++ b/src/renderer/canvas/codex-account-ops.test.ts
@@ -63,7 +63,8 @@ describe('planCodexAccountSwitch (fail-closed switch origination — §3.5)', ()
}
it('plans a switch to a present account, preserving the conversation id', () => {
- const d = planCodexAccountSwitch(codexNode, 'account-r', accounts, connected)
+ // `account-r` lives on u@box, so the node must run there too — a switch never crosses machines.
+ const d = planCodexAccountSwitch({ ...codexNode, ssh: true, hostKey: 'u@box' }, 'account-r', accounts, connected)
expect(d.ok).toBe(true)
if (!d.ok) return
expect(d.plan.sourceAccountId).toBe('account-a')
@@ -116,9 +117,39 @@ describe('planCodexAccountSwitch (fail-closed switch origination — §3.5)', ()
})
it('REFUSES a remote target whose host is not connected', () => {
- expect(planCodexAccountSwitch(codexNode, 'account-r', accounts, noConnection)).toEqual({
+ expect(
+ planCodexAccountSwitch({ ...codexNode, ssh: true, hostKey: 'u@box' }, 'account-r', accounts, noConnection)
+ ).toEqual({
ok: false,
reason: 'no-connection'
})
})
})
+
+describe('planCodexAccountSwitch — the account must live on the node\'s machine', () => {
+ const accts = [
+ { id: 'loc', label: 'Local' },
+ { id: 'rem', label: 'Remote', host: 'u@h' },
+ { id: 'rem2', label: 'Remote 2', host: 'u@h' },
+ { id: 'far', label: 'Elsewhere', host: 'x@y' }
+ ]
+ const connected = (): string => 'p1'
+ const base = { agentId: 'codex', cwd: '/srv/app', sessionId: 't1' }
+
+ it('switches an SSH node between accounts on its host, and to the host system login', () => {
+ const ssh = { ...base, ssh: true, hostKey: 'u@h', accountId: 'rem' }
+ expect(planCodexAccountSwitch(ssh, 'rem2', accts, connected)).toMatchObject({ ok: true })
+ expect(planCodexAccountSwitch(ssh, undefined, accts, connected)).toMatchObject({ ok: true })
+ })
+
+ it('refuses an account on another machine, in both directions', () => {
+ const ssh = { ...base, ssh: true, hostKey: 'u@h', accountId: 'rem' }
+ expect(planCodexAccountSwitch(ssh, 'loc', accts, connected)).toEqual({ ok: false, reason: 'unavailable' })
+ expect(planCodexAccountSwitch(ssh, 'far', accts, connected)).toEqual({ ok: false, reason: 'unavailable' })
+ const local = { ...base, accountId: 'loc' }
+ expect(planCodexAccountSwitch(local, 'rem', accts, connected)).toEqual({
+ ok: false,
+ reason: 'unavailable'
+ })
+ })
+})
diff --git a/src/renderer/canvas/codex-account-ops.ts b/src/renderer/canvas/codex-account-ops.ts
index 870f0e3f7..ee1e2c08e 100644
--- a/src/renderer/canvas/codex-account-ops.ts
+++ b/src/renderer/canvas/codex-account-ops.ts
@@ -66,12 +66,22 @@ export type CodexSwitchDecision =
* - the node must be a Codex node (`agentId === 'codex'`);
* - it must have a resumable conversation id (`sessionId`) and an absolute-ish cwd;
* - the target must differ from the source (a no-op switch is refused, not run);
- * - the target must pass `codexAccountSelectable` (missing/hostile/unconnected ⇒ refused).
+ * - the target must pass `codexAccountSelectable` (missing/hostile/unconnected ⇒ refused);
+ * - the target must live on the node's OWN machine (`hostKey`: this one when undefined) — an
+ * account on another machine has no home where the pane runs. Refused as `unavailable`.
* The returned `plan.expected.sessionId` and `plan.sessionId` are BOTH the node's current id, so the
* orchestration can never fork the conversation onto the switched account.
*/
export function planCodexAccountSwitch(
- node: { agentId?: string; cwd?: string; accountId?: string; ssh?: boolean; sessionId?: string },
+ node: {
+ agentId?: string
+ cwd?: string
+ accountId?: string
+ ssh?: boolean
+ sessionId?: string
+ /** `sshHostKey` of the host an SSH node's pane runs on; undefined = this machine. */
+ hostKey?: string
+ },
targetAccountId: string | undefined,
accounts: readonly CodexAccount[],
connectedProjectIdForHost: (host: string) => string | undefined
@@ -84,6 +94,11 @@ export function planCodexAccountSwitch(
if (source === target) return { ok: false, reason: 'same-account' }
const selectable = codexAccountSelectable(target, accounts, connectedProjectIdForHost)
if (!selectable.ok) return { ok: false, reason: selectable.reason }
+ if (
+ target !== undefined &&
+ (accounts.find((a) => a.id === target)?.host || undefined) !== (node.hostKey || undefined)
+ )
+ return { ok: false, reason: 'unavailable' }
return {
ok: true,
plan: {
diff --git a/src/shared/ipc.ts b/src/shared/ipc.ts
index e5653114f..f422db2b3 100644
--- a/src/shared/ipc.ts
+++ b/src/shared/ipc.ts
@@ -78,6 +78,7 @@ export const IPC = {
codexAccountsCommitSwitch: 'codex-accounts:commit-switch',
codexAccountsFinishSwitch: 'codex-accounts:finish-switch',
codexAccountsRollbackSwitch: 'codex-accounts:rollback-switch',
+ codexAccountsSwitchThreadRemote: 'codex-accounts:switch-thread-remote',
codexAccountsTransferThreadToSsh: 'codex-accounts:transfer-thread-to-ssh',
claudeCliCaps: 'claude-cli:caps',
grokCliCaps: 'grok-cli:caps',
diff --git a/src/shared/types.ts b/src/shared/types.ts
index e23431008..3ae135e9b 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -2907,6 +2907,18 @@ export interface CodexAccountsApi {
finishSwitch(rollbackToken: string): Promise<void>
/** Phase 3b: roll back a reservation (releases it; a committed link is left for cleanup). */
rollbackSwitch(rollbackToken: string): Promise<void>
+ /**
+ * The SSH leg of a running node's account switch: expose the conversation to `targetAccountId`
+ * ON the connected host behind `ctx.projectId` (hardlink the rollout into the target home, verify
+ * the target discovers it). `hostAccountIds` = every managed account on that host (the catalogs
+ * the thread is resolved across). Resolves once the target can resume it; throws otherwise.
+ */
+ switchThreadRemote(
+ threadId: string,
+ targetAccountId: string | undefined,
+ hostAccountIds: string[],
+ ctx: AccountSshCtx
+ ): Promise<void>
/** Source-side leg of moving an idle LOCAL conversation to an SSH account: validate strict source
* containment then hand the upload to the remote import path (PR 6). Local rollout untouched. */
transferThreadToSsh(