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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(settings): one machine-grouped Accounts surface for Claude and Codex
review304e25b09f55
diff --git a/CLAUDE.md b/CLAUDE.mdindex b980defba..cbdbde700 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -2964,6 +2964,24 @@ command-bearing opens; this does not add a human-confirm dialog or change mobilecorrect (their credentials aren't on the host) but read as "multi-account is broken on SSH".- **Remote accounts** — selection + login + env injection, plus **usage** (below); noper-account transcript readers beyond env.+ - **Settings → Accounts is ONE machine-grouped surface for BOTH providers** (2026-09): a panel+ per machine (this one, then each saved SSH server ∪ the active project's server — a saved server+ with no accounts and no connection is folded into a footnote count), each holding a Claude and a+ Codex block with the SAME row, system row and Add button (`groupAccountsByMachine`). A remote+ machine's Add / Retry / Remove act ON that host over a **connected** project only — a+ disconnected host's Add is disabled and its Remove only forgets the record (the dialog says so);+ a remote id never reaches a LOCAL remove. Codex gained the remote lifecycle this needed:+ `codexAccounts.add/waitLogin/identity/remove` take an SSH `ctx` (desktop `src/main/codex-accounts.ts`+ → the `SshProjectManager.remoteCodex*` legs; the credential is written on the host by+ `codex login --device-auth` — the default browser flow calls back to the HOST's localhost), and+ `systemIdentity({projectId})` now asks the host instead of answering `null`.+ - **The remote spawn scopes the account BY PROVIDER** (`core/remote-account-env.ts`). It used to+ hand every `accountId` to Claude's `CLAUDE_CONFIG_DIR`, so a node bound to a managed Codex account+ 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.- **Linked accounts** (`ClaudeAccount.configDir`) — a PRE-EXISTING local configdir the user already drives themselves (`export CLAUDE_CONFIG_DIR=~/.claude-2; claude …` in aplain 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.mdindex cd8b99894..9bd1eb22a 100644--- a/docs/codex-accounts-acceptance.md+++ b/docs/codex-accounts-acceptance.md@@ -54,9 +54,13 @@ Codex install + a **logged-in 2nd managed account**. Headless CI cannot run them- [ ] **The imperative pane-recycle glue** (commit → rebind → restartShell → finish) + a **live SSHremote-account switch.** The pure logic + the main-side switch are unit-tested; the imperativerenderer sequencing is only exercised against the running app.-- [ ] **Remote-host account LIFECYCLE UI** (add / login / remove **on** an SSH host). The local picker +- switch are wired (PR 8.5); the remote-host lifecycle surface is **display + group only**,- fail-closed, owed to the host-relay follow-up. VERIFY it stays display-only and refuses to mint.+- [ ] **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+ host for a real `auth.json`; Remove deletes it there. Unit-tested only. VERIFY on a real host:+ the device flow completes, the row picks up the email (needs the relay runtime — without it the+ login completes with no email), a new Codex node on that host runs under the managed home+ (`echo $CODEX_HOME` in the pane), and Remove leaves no `~/.nodeterm/cx/<digest>` behind.## Happy-path acceptance walk (the one a human runs end to end)diff --git a/docs/node-identity.md b/docs/node-identity.mdindex 012af8bc3..2cc6e7c4f 100644--- a/docs/node-identity.md+++ b/docs/node-identity.md@@ -524,9 +524,8 @@ parts that touch this secret and the invariants here:(invariant 1 — no credential *or* scope-shaping input on a command line).Two S6 surfaces remain **owed device verifications** rather than shipped-and-verified: the imperative-pane-recycle glue behind a live switch, and the remote-host account **lifecycle** UI (add/login/remove-*on* an SSH host — the local picker + switch are wired, the remote lifecycle surface is display-only,-fail-closed). Both, plus the live-daemon and real-WAN legs, are in+pane-recycle glue behind a live switch, and the remote-host account **lifecycle** (add/login/remove+*on* an SSH host — wired 2026-09 from the machine panels in Settings → Accounts, unit-tested only). Both, plus the live-daemon and real-WAN legs, are in[the acceptance gate](codex-accounts-acceptance.md).## Invariants a future change must not breakdiff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 42ce9019c..6a8b60e5b 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -4699,21 +4699,38 @@ export function Canvas() {// The Codex sibling of the block above: Settings → Accounts "Add Codex account" dispatches// 'nodeterm:add-codex-account-login' and then polls `codexAccounts.waitLogin` for the account// home's auth.json. Nothing was listening, so no `codex login` ever ran and the poll waited out- // its timeout on a credential nothing was writing (issue #346). Local only: `codexAccounts.add()`- // mints on THIS machine, so there is no remote/host leg to resolve — the remote account- // lifecycle lands with the host relay.+ // its timeout on a credential nothing was writing (issue #346). A REMOTE account (its home was+ // created on an SSH host) logs in ON that host, resolved BY HOST among connected projects exactly+ // like the Claude branch — and with no match nothing is spawned: a local `codex login` would write+ // this machine's credential while waitLogin polls the host.useEffect(() => {const onAddCodexAccountLogin = (ev: Event): void => {- const accountId = (ev as CustomEvent<{ accountId?: string }>).detail?.accountId+ const detail = (ev as CustomEvent<{ accountId?: string; remote?: boolean; host?: string }>)+ .detail+ const accountId = detail?.accountIdif (!accountId) return- // Same cwd reasoning as the Claude branch above (issue #553). Local only, so `project.cwd`- // is the only field that can be read here — an SSH project's `remoteCwd` names a directory- // on the host and would send this local shell somewhere that does not exist.+ let ssh: ReturnType<typeof useProjects.getState>['projects'][number]['ssh']+ if (detail?.remote) {+ const host = detail.host+ const conn = useSshConn.getState().byProject+ const project = host+ ? useProjects+ .getState()+ .projects.find((p) => p.ssh && sshHostKey(p.ssh.server) === host && conn[p.id])+ : undefined+ if (!project) return // defensive: mismatched/disconnected remote login — never spawn locally+ ssh = project.ssh+ }+ // Same cwd reasoning as the Claude branch above (issue #553). A remote login ignores it —+ // `createTerminalNode` prefers `ssh.remoteCwd` — because a local path names nothing there.const { getProject, activeProjectId: pid } = useProjects.getState()const cwd = getProject(pid)?.cwdsetNodes((ns) => [...ns.map((n) => ({ ...n, selected: false })),- { ...createCodexAccountLoginNode(accountId, ns.length, viewCenter(), cwd), selected: true }+ {+ ...createCodexAccountLoginNode(accountId, ns.length, viewCenter(), cwd, ssh),+ selected: true+ }])markDirty()// Same reason as the Claude branch: the event fires from the full-screen Settings overlay,@@ -8545,6 +8562,19 @@ 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) || undefinedconst systemCodexLabel = systemAccountDisplay(undefined,diff --git a/src/renderer/components/settings/sections/AccountsSection.machines.test.tsx b/src/renderer/components/settings/sections/AccountsSection.machines.test.tsxnew file mode 100644index 000000000..14f662ca0--- /dev/null+++ b/src/renderer/components/settings/sections/AccountsSection.machines.test.tsx@@ -0,0 +1,200 @@+// @vitest-environment jsdom+//+// The machine-grouped Accounts settings: Claude and Codex accounts sit on the SAME machine panel,+// each provider with its own Add button, and a remote machine's buttons act ON that host — over a+// live connection only. The rules pinned here are the ones a regression would make silently wrong:+// a remote add/remove never runs locally, a disconnected host never reaches the remote leg, and a+// saved server with nothing on it and no connection stays out of the way.+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { act } from 'react'+import { createRoot, type Root } from 'react-dom/client'+import { AccountsSection } from './AccountsSection'+import { useSettings } from '../../../state/settings'+import { useProjects } from '../../../state/projects'+import { useSshConn } from '../../../state/sshConn'+import { useSshServers } from '../../../state/sshServers'+import { DEFAULT_SETTINGS, type ClaudeAccount } from '@shared/types'+import type { CodexAccount } from '@shared/codex-account'+import type { SshServer } from '@shared/ssh'++const prod: SshServer = { id: 's1', host: 'prod-box', user: 'deploy', label: 'Prod' } as SshServer+const idle: SshServer = { id: 's2', host: 'idle-box', user: 'me', label: 'Idle' } as SshServer+const PROD = 'deploy@prod-box'++let codexApi: Record<string, ReturnType<typeof vi.fn>>+let claudeApi: Record<string, ReturnType<typeof vi.fn>>+let events: { type: string; detail: unknown }[]+let root: Root+let host: HTMLElement+const onEvent = (e: Event): void => {+ events.push({ type: e.type, detail: (e as CustomEvent).detail })+}++function render(opts: {+ claude?: ClaudeAccount[]+ codex?: CodexAccount[]+ connected?: boolean+}): void {+ useSettings.setState({+ settings: {+ ...DEFAULT_SETTINGS,+ claudeAccounts: opts.claude ?? [],+ codexAccounts: opts.codex ?? []+ },+ hydrated: true+ })+ useSshServers.setState({ servers: [prod, idle] })+ useProjects.setState({+ projects: [{ id: 'p1', name: 'prod', nodes: [], ssh: { server: prod, remoteCwd: '/srv' } } as never],+ activeProjectId: 'p1'+ })+ useSshConn.setState({ byProject: opts.connected === false ? {} : ({ p1: {} } as never) })+ host = document.createElement('div')+ document.body.appendChild(host)+ root = createRoot(host)+ act(() => root.render(<AccountsSection isActive />))+}++const panel = (label: string): HTMLElement =>+ host.querySelector(`section[aria-label="Accounts on ${label}"]`) as HTMLElement+const buttonIn = (el: ParentNode, text: string): HTMLButtonElement | undefined =>+ [...el.querySelectorAll('button')].find((b) => b.textContent === text) as HTMLButtonElement | undefined+const byLabel = (label: string): HTMLButtonElement | undefined =>+ [...host.querySelectorAll('button')].find((b) => b.getAttribute('aria-label') === label) as+ | HTMLButtonElement+ | undefined++beforeEach(() => {+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)+ events = []+ window.addEventListener('nodeterm:add-codex-account-login', onEvent)+ window.addEventListener('nodeterm:add-account-login', onEvent)+ codexApi = {+ add: vi.fn(async () => ({ id: 'cx-new', home: '/home/deploy/.nodeterm/cx/x' })),+ waitLogin: vi.fn(async () => ({ email: '[email protected]' })),+ cancelWaitLogin: vi.fn(async () => {}),+ identity: vi.fn(async () => null),+ systemIdentity: vi.fn(async () => null),+ remove: vi.fn(async () => {})+ }+ claudeApi = {+ add: vi.fn(async () => ({ id: 'cl-new', configDir: '~/x', versionSupported: true })),+ waitLogin: vi.fn(async () => ({ email: '[email protected]' })),+ cancelWaitLogin: vi.fn(async () => {}),+ remove: vi.fn(async () => {})+ }+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {+ usage: { fetch: async () => null },+ ssh: { list: async () => [prod, idle] },+ settings: { save: async () => {} },+ codexAccounts: codexApi,+ claudeAccounts: claudeApi+ }+})++afterEach(async () => {+ act(() => root.unmount())+ host.remove()+ window.removeEventListener('nodeterm:add-codex-account-login', onEvent)+ window.removeEventListener('nodeterm:add-account-login', onEvent)+ await useSettings.getState().flush()+ useSettings.setState({ settings: DEFAULT_SETTINGS })+ useSshConn.setState({ byProject: {} })+ useSshServers.setState({ servers: [] })+ vi.unstubAllGlobals()+})++describe('AccountsSection — one panel per machine, both providers', () => {+ it('puts a host’s Claude and Codex accounts on that host’s panel, and hides an idle saved server', () => {+ render({+ claude: [{ id: 'a1', label: 'Server login', host: PROD, createdAt: 0 }],+ codex: [{ id: 'c1', label: 'Prod codex', host: PROD }]+ })+ const p = panel(PROD)+ expect(p).toBeTruthy()+ expect((p.querySelector('input[value="Server login"]') as HTMLInputElement | null)).toBeTruthy()+ expect((p.querySelector('input[value="Prod codex"]') as HTMLInputElement | null)).toBeTruthy()+ expect(buttonIn(p, 'Add Claude account')?.disabled).toBe(false)+ expect(buttonIn(p, 'Add Codex account')?.disabled).toBe(false)+ // idle-box: saved, nothing on it, not connected → no panel, but the footnote counts it.+ expect(panel('me@idle-box')).toBeNull()+ expect(host.textContent).toContain('1 saved SSH server has no accounts yet')+ })++ it('disables a disconnected host’s Add buttons instead of running them locally', () => {+ render({ claude: [{ id: 'a1', label: 'Server login', host: PROD, createdAt: 0 }], connected: false })+ const p = panel(PROD)+ expect(buttonIn(p, 'Add Claude account')?.disabled).toBe(true)+ expect(buttonIn(p, 'Add Codex account')?.disabled).toBe(true)+ expect(p.textContent).toContain('not connected')+ })+})++describe('AccountsSection — Codex on an SSH host', () => {+ it('creates the home ON the host, opens the login there, and waits over the host', async () => {+ render({})+ await act(async () => buttonIn(panel(PROD), 'Add Codex account')!.click())+ expect(codexApi.add).toHaveBeenCalledWith({ projectId: 'p1' })+ expect(events).toContainEqual({+ type: 'nodeterm:add-codex-account-login',+ detail: { accountId: 'cx-new', remote: true, host: PROD }+ })+ expect(codexApi.waitLogin).toHaveBeenCalledWith('cx-new', { projectId: 'p1' })+ expect(useSettings.getState().settings.codexAccounts[0]).toMatchObject({+ id: 'cx-new',+ host: PROD,+ email: '[email protected]',+ pending: false+ })+ })++ it('removes a remote account ON its host when connected', async () => {+ render({ codex: [{ id: 'c1', label: 'Prod codex', host: PROD }] })+ act(() => byLabel('Remove Codex account')!.click())+ expect(document.body.textContent).toContain('Codex home on deploy@prod-box will be deleted')+ await act(async () => buttonIn(document.body, 'Remove')!.click())+ expect(codexApi.remove).toHaveBeenCalledWith('c1', { projectId: 'p1' })+ expect(useSettings.getState().settings.codexAccounts).toEqual([])+ })++ it('only forgets a remote account whose host is not connected — never a local remove', async () => {+ render({ codex: [{ id: 'c1', label: 'Prod codex', host: PROD }], connected: false })+ act(() => byLabel('Remove Codex account')!.click())+ expect(document.body.textContent).toContain('not connected, so nodeterm only forgets it')+ await act(async () => buttonIn(document.body, 'Remove')!.click())+ expect(codexApi.remove).not.toHaveBeenCalled()+ expect(useSettings.getState().settings.codexAccounts).toEqual([])+ })++ it('keeps the row and says why when the removal is refused', async () => {+ codexApi.remove.mockRejectedValueOnce(new Error('Codex account is reserved by an account switch'))+ render({ codex: [{ id: 'c1', label: 'Mine' }] })+ act(() => byLabel('Remove Codex account')!.click())+ await act(async () => buttonIn(document.body, 'Remove')!.click())+ expect(useSettings.getState().settings.codexAccounts).toHaveLength(1)+ expect(host.textContent).toContain('reserved by an account switch')+ })++ it('offers Retry login on a pending Codex row, like Claude', async () => {+ render({ codex: [{ id: 'c2', label: 'New Codex account', pending: true }] })+ await act(async () => buttonIn(host, 'Retry login')!.click())+ expect(codexApi.waitLogin).toHaveBeenCalledWith('c2')+ })+})++describe('AccountsSection — Claude on an SSH host', () => {+ it('only forgets a remote Claude account whose host is not connected', async () => {+ render({ claude: [{ id: 'a1', label: 'Server login', host: PROD, createdAt: 0 }], connected: false })+ act(() => byLabel('Remove account')!.click())+ await act(async () => buttonIn(document.body, 'Remove')!.click())+ expect(claudeApi.remove).not.toHaveBeenCalled()+ expect(useSettings.getState().settings.claudeAccounts).toEqual([])+ })++ it('removes it ON the host when connected', async () => {+ render({ claude: [{ id: 'a1', label: 'Server login', host: PROD, createdAt: 0 }] })+ act(() => byLabel('Remove account')!.click())+ await act(async () => buttonIn(document.body, 'Remove')!.click())+ expect(claudeApi.remove).toHaveBeenCalledWith('a1', { projectId: 'p1' })+ })+})diff --git a/src/renderer/components/settings/sections/AccountsSection.tsx b/src/renderer/components/settings/sections/AccountsSection.tsxindex 6957e1524..5f7e8d782 100644--- a/src/renderer/components/settings/sections/AccountsSection.tsx+++ b/src/renderer/components/settings/sections/AccountsSection.tsx@@ -1,5 +1,6 @@import { Fragment, useEffect, useState } from 'react'import { IconClose } from '../../icons'+import { AgentIcon } from '../../../lib/agentIcons'import type { ClaudeAccount, ClaudeSkillShareResult } from '@shared/types'import type { CodexAccount } from '@shared/codex-account'import { E_UNSUPPORTED } from '@shared/rpc'@@ -19,14 +20,13 @@ import {} from '../../../state/codexAccountReconcile'import {codexRemoteTargets,- groupCodexAccountsByMachine,- strayCodexAccounts+ groupAccountsByMachine,+ strayAccounts} from '../../../lib/codexMachineGroups'import { configDirLabel, unlinkedConfigDirs } from '../../../lib/accountChip'import { presentAccount } from '../../../lib/accountPresentation'import { skillShareNote } from '../../../lib/skillSharing'import { codexAccountSelectable } from '../../../canvas/codex-account-switch'-import { AccountIdentityPills } from '../../AccountIdentityPills'import { ConfirmDialog } from '../../ConfirmDialog'import { SettingsSection } from '../SettingsSection'import { SearchableRow } from '../SearchableRow'@@ -38,10 +38,12 @@ import { thisMachine, thisMachineCap } from '../../../lib/machineName'const ROWS = {accounts: {- title: 'Claude accounts',+ title: 'Claude & Codex accounts',keywords: ['account','claude',+ 'codex',+ 'openai','login','isolated','multi',@@ -49,12 +51,12 @@ const ROWS = {'link','config dir','existing',- 'detected'+ 'detected',+ 'machine',+ 'ssh',+ 'host',+ 'remote']- },- codex: {- title: 'Codex accounts',- keywords: ['account', 'codex', 'openai', 'login', 'isolated', 'multi', 'email', 'machine', 'ssh']}}const ENTRIES = Object.values(ROWS)@@ -74,7 +76,7 @@ const errorText = (e: unknown, fallback: string): string => {}/** One machine's card in the accounts UI: a connectivity dot, the machine label, a Local/SSH pill,- * and (for a remote machine) its `user@host` subtitle. Children are the provider account rows. */+ * and (for a remote machine) its `user@host` subtitle. Children are the provider blocks. */function MachinePanel({label,remote,@@ -89,8 +91,11 @@ function MachinePanel({children: React.ReactNode}): React.JSX.Element {return (- <div className="space-y-3 rounded-md border border-border p-3">- <div className="flex items-center gap-2">+ <section+ aria-label={remote ? `Accounts on ${hostKey ?? label}` : `Accounts on ${label}`}+ className="space-y-3 rounded-md border border-border p-3"+ >+ <div className="flex flex-wrap items-center gap-2"><spanclassName={`inline-block h-2 w-2 rounded-full ${!remote || connected ? 'bg-[color:var(--ok,#30d158)]' : 'bg-[color:var(--muted-2)]'@@ -102,26 +107,148 @@ function MachinePanel({<span className="rounded-full bg-fill-weak px-2 py-0.5 text-[11px] font-medium text-muted">{remote ? 'SSH' : 'Local'}</span>- {remote && hostKey ? <span className="text-[12px] text-muted">{hostKey}</span> : null}+ {remote && hostKey && hostKey !== label ? (+ <span className="text-[12px] text-muted">{hostKey}</span>+ ) : null}+ {remote && !connected ? (+ <span className="text-[12px] text-muted">+ · not connected — open a project on this host to add or log in accounts+ </span>+ ) : null}</div>{children}+ </section>+ )+}++/**+ * One provider's accounts on one machine. The SAME frame for Claude and Codex — a heading with the+ * agent's icon and its Add button, then the system row, then the managed rows — so the two+ * providers read, and are added, the same way on every machine.+ */+function ProviderBlock({+ agentId,+ title,+ action,+ error,+ progress,+ children+}: {+ agentId: 'claude' | 'codex'+ title: string+ action: React.ReactNode+ error?: string | null+ progress?: string | null+ children: React.ReactNode+}): React.JSX.Element {+ return (+ <div className="space-y-2">+ <div className="flex items-center justify-between gap-2">+ <div className="flex items-center gap-2 text-[12px] font-medium text-text">+ <AgentIcon agentId={agentId} size={14} />+ {title}+ </div>+ {action}+ </div>+ {progress ? <p className="text-[12px] leading-relaxed text-muted">{progress}</p> : null}+ {error ? <p className="text-[12px] text-[color:var(--danger)]">{error}</p> : null}+ <div className="space-y-2">{children}</div></div>)}-/** `addingOn` sentinel for the local button — a host key can never be this. */-const LOCAL_TARGET = ''+/** The machine's implicit SYSTEM login (`~/.claude` / `~/.codex`) — not an account record, so it+ * has no remove and no color; `name` may be an editable label (the local Claude one is). */+function SystemAccountRow({+ name,+ detail+}: {+ name: React.ReactNode+ detail?: string | null+}): React.JSX.Element {+ return (+ <div className="flex items-center justify-between gap-3 rounded-md border border-border/60 p-2">+ <div className="min-w-0 flex-1 space-y-1">+ <div className="flex items-center gap-2">+ {name}+ <span+ className="rounded-full bg-fill-weak px-2 py-0.5 text-[11px] font-medium text-muted"+ title="The machine's default login. Used when a node has no account."+ >+ system+ </span>+ </div>+ {detail ? <p className="text-[12px] text-muted">{detail}</p> : null}+ </div>+ </div>+ )+}-/** Spinner + label for an Add button that is mid-setup. */-function AddingLabel({ where }: { where: string }): React.JSX.Element {+/** A managed account row — identical for both providers; `extra` carries provider-only controls. */+function ManagedAccountRow({+ label,+ placeholder,+ onLabel,+ pending,+ pills,+ email,+ color,+ onColor,+ extra,+ actions,+ blockedReason+}: {+ label: string+ placeholder: string+ onLabel: (label: string) => void+ pending?: boolean+ pills?: React.ReactNode+ email?: string | null+ color?: string+ onColor: (color?: string) => void+ extra?: React.ReactNode+ actions: React.ReactNode+ blockedReason?: string+}): React.JSX.Element {return (- <span className="inline-flex items-center gap-2">- <span className="ui-spinner" aria-hidden />- Setting up on {where}…- </span>+ <div+ className={cn(+ 'flex items-center justify-between gap-3 rounded-md border p-2',+ blockedReason ? 'border-[color:var(--warn)]/40' : 'border-border/60'+ )}+ title={blockedReason}+ >+ <div className="min-w-0 flex-1 space-y-1">+ <div className="flex min-w-0 flex-wrap items-center gap-2">+ <Input+ className="w-56"+ placeholder={placeholder}+ value={label}+ onChange={(e) => onLabel(e.target.value)}+ />+ {pending ? (+ <span className="rounded-full bg-[color:var(--warn)]/15 px-2 py-0.5 text-[11px] font-medium text-[color:var(--warn)]">+ pending+ </span>+ ) : null}+ {pills}+ </div>+ {email && !pending ? <p className="text-[12px] text-muted">{email}</p> : null}+ {blockedReason ? (+ <p className="text-[11px] text-[color:var(--warn)]">{blockedReason}</p>+ ) : null}+ <AccountColorSwatches label={label} color={color} onPick={onColor} />+ {extra}+ </div>+ <div className="flex shrink-0 items-center gap-2">{actions}</div>+ </div>)}+/** Which Add button is mid-setup: `<provider>:<host>` (`''` host = this machine). */+type Provider = 'claude' | 'codex'+const addKey = (provider: Provider, host: string): string => `${provider}:${host}`+/** Reads fresh settings then applies a transform to the accounts list (avoids stale closures* after an awaited login resolves late). */function applyAccounts(fn: (accs: ClaudeAccount[]) => ClaudeAccount[]): void {@@ -246,13 +373,24 @@ function SkillSharingRow({.finally(() => setBusy(false))}}/>- <span className="text-[12px] text-muted">Share ~/.claude/skills</span>+ <span+ className="text-[12px] text-muted"+ // The full consequence rides the tooltip; the line below keeps the one fact a user must+ // not miss (an edit changes the machine's own file) visible without a paragraph per row.+ title={+ remote+ ? undefined+ : 'Links this machine’s skills into the account. They are shared, not copied, so an edit from either side changes the same file. Turning this off removes only the links.'+ }+ >+ Share ~/.claude/skills+ </span>+ <span className="text-[11px] text-muted">+ {remote+ ? 'Not available for accounts on an SSH host — their skills live on that machine.'+ : '— linked, not copied: edits change the same files'}+ </span></div>- <p className="pt-1 text-[11px] text-muted">- {remote- ? 'Not available for accounts on an SSH host — their skills live on that machine.'- : 'Links this machine’s skills into the account. They are shared, not copied, so an edit from either side changes the same file. Turning this off removes only the links.'}- </p>{note ? <p className="pt-1 text-[11px] text-[color:var(--warn)]">{note}</p> : null}</div>)@@ -272,28 +410,34 @@ function countNodesUsing(accountId: string): number {export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.Element {const accounts = useSettings((s) => s.settings.claudeAccounts)+ const codexAccounts = useSettings((s) => s.settings.codexAccounts)const systemLabelSetting = useSettings((s) => s.settings.systemAccountLabel)const systemEmail = useSystemAccount((s) => s.email)useEffect(() => useSystemAccount.getState().ensure(), [])+ const systemCodexEmail = useSystemCodexAccount((s) => s.email)+ const remoteSystemCodexEmails = useSystemCodexAccount((s) => s.remoteEmails)+ useEffect(() => useSystemCodexAccount.getState().ensure(), [])+ const sshServers = useSshServers((s) => s.servers)+ useEffect(() => {+ void useSshServers.getState().hydrate?.()+ }, [])const activeProjectId = useProjects((s) => s.activeProjectId)const activeProject = useProjects((s) => s.projects.find((p) => p.id === activeProjectId))- // The active project's SSH host key (`user@host`), when it's a connected SSH project. Present →- // the "Add account" control also offers adding an account ON that host.- const activeHostKey = activeProject?.ssh ? sshHostKey(activeProject.ssh.server) : undefined- // Subscribe to live SSH connections so a remote account's Retry button enables/disables as its- // host connects/disconnects while this panel is open.+ // Subscribe to live SSH connections so a remote machine's Add / Retry buttons enable and disable+ // as its host connects and disconnects while this panel is open.const sshByProject = useSshConn((s) => s.byProject)const [versionWarning, setVersionWarning] = useState(false)const [pendingRemove, setPendingRemove] = useState<ClaudeAccount | null>(null)+ const [pendingRemoveCodex, setPendingRemoveCodex] = useState<CodexAccount | null>(null)/**- * Which "Add account" button is mid-setup: the host key, or LOCAL_TARGET for this machine.- * Minting a REMOTE account is 10–15 s of real work on the host — mkdir, merging the status hook- * into the account dir's settings.json, installing the canvas-control + context-link skills, and- * a `claude --version` through a login shell — and until this state existed the button simply- * sat there, so the click read as "nothing happened" until the login node appeared.+ * Which Add button is mid-setup (`addKey(provider, host)`). Minting a REMOTE account is several+ * seconds of real work on the host — mkdir, hook/skill installs or the Codex runtime links, a CLI+ * probe — and until this state existed the button simply sat there, so the click read as+ * "nothing happened" until the login node appeared. One setup at a time, across providers.*/- const [addingOn, setAddingOn] = useState<string | null>(null)- const [addError, setAddError] = useState<string | null>(null)+ const [adding, setAdding] = useState<string | null>(null)+ const [addErrors, setAddErrors] = useState<Record<string, string>>({})+ const [removeError, setRemoveError] = useState<string | null>(null)// "Link existing config dir…": the typed path, the in-flight guard, and the inline error.const [linkPath, setLinkPath] = useState('')const [linking, setLinking] = useState(false)@@ -304,8 +448,8 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.const [browseUnsupported, setBrowseUnsupported] = useState(false)/*** Config dirs SEEN running on this core that we have no account for — the one-click Link- * candidates. A primitive selector (newline-joined) so the settings page does not re-render on- * every hook event of every node just to discover the same list again.+ * candidates. A primitive selector so the settings page does not re-render on every hook event+ * of every node just to discover the same list again.*/const detectedDirs = useAgentStatus((s) =>// NUL-joined, not newline-joined: a path may legally contain a newline, and splitting one back@@ -314,68 +458,53 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.)const detected = detectedDirs ? detectedDirs.split('\u0000') : []- const setLabel = (id: string, label: string): void =>- applyAccounts((accs) => accs.map((a) => (a.id === id ? { ...a, label } : a)))-- const setColor = (id: string, color?: string): void =>- applyAccounts((accs) => accs.map((a) => (a.id === id ? { ...a, color } : a)))-- /**- * Flip `~/.claude/skills` sharing for one account (issue #643). The FILESYSTEM is reconciled- * first and the flag is persisted only if that call came back — because the flag is what the- * launch sweep replays, and a stored `true` whose links were never made would make the switch- * lie until the next boot. A REFUSAL is likewise not a state to store: nothing happened, so the- * switch stays where it was and the note says why.- */- const setSkillSharing = async (id: string, enabled: boolean): Promise<string | null> => {- let res: ClaudeSkillShareResult- try {- res = await window.nodeTerminal.claudeAccounts.setSkillSharing(id, enabled)- } catch (e) {- if (isUnsupported(e)) return 'Sharing skills is not available on this connection.'- throw e- }- if (!res.refused) {- applyAccounts((accs) =>- accs.map((a) => (a.id === id ? { ...a, shareSystemSkills: enabled } : a))- )- }- return skillShareNote(res, enabled)- }+ const setAddError = (key: string, message: string | null): void =>+ setAddErrors((errs) => {+ const next = { ...errs }+ if (message) next[key] = message+ else delete next[key]+ return next+ })- // The open project whose SSH host matches a remote account (needed for the ssh context of- // waitLogin / remove). Undefined for local accounts, or when no such project is open.+ // The open project whose SSH host matches a remote account. Undefined for local accounts, or when+ // no such project is open.const projectIdForHost = (host?: string): string | undefined => {if (!host) return undefinedreturn useProjects.getState().projects.find((p) => p.ssh && sshHostKey(p.ssh.server) === host)?.id}- // A remote account can only log in on a CONNECTED matching-host project (live ControlMaster in- // useSshConn). Undefined when the account is remote but no such project is currently connected —- // Retry is then disabled so `claude /login` never runs against the local system account.+ // A remote account can only be created, logged into or deleted over a CONNECTED matching-host+ // project (live ControlMaster in useSshConn). Undefined ⇒ that host is not reachable right now,+ // and every remote action is disabled — never quietly run against this machine instead.const connectedProjectIdForHost = (host?: string): string | undefined => {- const id = projectIdForHost(host)- return id && sshByProject[id] ? id : undefined+ if (!host) return undefined+ return useProjects+ .getState()+ .projects.find((p) => p.ssh && sshHostKey(p.ssh.server) === host && sshByProject[p.id])?.id}- // ── Codex accounts (machine-grouped) ─────────────────────────────────────────────────────────- const codexAccounts = useSettings((s) => s.settings.codexAccounts)- const sshServers = useSshServers((s) => s.servers)- const systemCodexEmail = useSystemCodexAccount((s) => s.email)- const remoteSystemCodexEmails = useSystemCodexAccount((s) => s.remoteEmails)- useEffect(() => useSystemCodexAccount.getState().ensure(), [])- useEffect(() => {- void useSshServers.getState().hydrate?.()- }, [])- const [pendingRemoveCodex, setPendingRemoveCodex] = useState<CodexAccount | null>(null)- const [addingCodex, setAddingCodex] = useState(false)- const [codexAddError, setCodexAddError] = useState<string | null>(null)-- // The reachable machines: this machine first, then every saved SSH server unioned with the active- // project's own server (deduped by host key). Accounts partition onto them by `host`.+ // ── The machines ─────────────────────────────────────────────────────────────────────────────+ // This machine first, then every saved SSH server unioned with the active project's own server+ // (deduped by host key). BOTH providers' accounts partition onto the same list, so a host's+ // Claude and Codex logins always sit in the same panel.const remoteTargets = codexRemoteTargets(sshServers, activeProject?.ssh?.server)- const codexGroups = groupCodexAccountsByMachine(codexAccounts, remoteTargets)- const codexStrays = strayCodexAccounts(codexAccounts, remoteTargets)+ const claudeGroups = groupAccountsByMachine(accounts, remoteTargets)+ const codexGroups = groupAccountsByMachine(codexAccounts, remoteTargets)+ const claudeStrays = strayAccounts(accounts, remoteTargets)+ const codexStrays = strayAccounts(codexAccounts, remoteTargets)+ // A saved server with nothing on it and no connection is a panel of two empty lists and two+ // disabled buttons — noise, once a user has saved a handful of servers. It appears as soon as it+ // is connected (the moment its buttons would work) or holds an account.+ const machines = claudeGroups+ .map((group, i) => ({ ...group, claude: group.accounts, codex: codexGroups[i].accounts }))+ .filter(+ (m) =>+ !m.remote ||+ m.claude.length > 0 ||+ m.codex.length > 0 ||+ !!connectedProjectIdForHost(m.host)+ )+ const hiddenMachines = claudeGroups.length - machines.length// Discover the system Codex identity of every CONNECTED remote target, once per host. A host with// no live connection is skipped (and never fabricated — its panel simply shows no system email).@@ -388,10 +517,9 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.// eslint-disable-next-line react-hooks/exhaustive-deps}, [isActive, remoteTargets.map(([h]) => h).join('|'), sshByProject])- // Reconcile LOCAL pending Codex accounts against their now-authenticated homes. Remote accounts- // are intentionally NOT probed here: `codexAccounts.identity` reads the LOCAL managed home, so- // resolving a remote account against it would read the wrong machine. Their reconcile arrives- // with the host relay (a follow-up); until then a remote row stays pending, not misattributed.+ // Reconcile LOCAL pending Codex accounts against their now-authenticated homes. A remote pending+ // account is resolved by its own login wait (and its Retry), which asks the HOST — the local+ // `identity` read would look in this machine's managed home and misattribute it.useEffect(() => {if (!isActive) returnlet cancelled = false@@ -420,163 +548,34 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.}}, [isActive, codexAccounts])- const setCodexLabel = (id: string, label: string): void =>- applyCodexAccounts((accs) => accs.map((a) => (a.id === id ? { ...a, label } : a)))+ // ── Claude ───────────────────────────────────────────────────────────────────────────────────+ const setLabel = (id: string, label: string): void =>+ applyAccounts((accs) => accs.map((a) => (a.id === id ? { ...a, label } : a)))- const setCodexColor = (id: string, color?: string): void =>- applyCodexAccounts((accs) => accs.map((a) => (a.id === id ? { ...a, color } : a)))+ const setColor = (id: string, color?: string): void =>+ applyAccounts((accs) => accs.map((a) => (a.id === id ? { ...a, color } : a)))- // Add a LOCAL managed Codex account and open its device-login node. Remote Codex account creation- // is fail-closed here: the base `codexAccounts.add()` mints on THIS Mac, so offering it under a- // remote machine would silently create a local account — the remote leg lands with the host relay.- const onAddCodexAccount = async (): Promise<void> => {- if (addingCodex) return- setAddingCodex(true)- setCodexAddError(null)+ /**+ * Flip `~/.claude/skills` sharing for one account (issue #643). The FILESYSTEM is reconciled+ * first and the flag is persisted only if that call came back — because the flag is what the+ * launch sweep replays, and a stored `true` whose links were never made would make the switch+ * lie until the next boot. A REFUSAL is likewise not a state to store: nothing happened, so the+ * switch stays where it was and the note says why.+ */+ const setSkillSharing = async (id: string, enabled: boolean): Promise<string | null> => {+ let res: ClaudeSkillShareResulttry {- const added = await window.nodeTerminal.codexAccounts.add()- const account: CodexAccount = { id: added.id, label: 'New Codex account', pending: true }- applyCodexAccounts((accs) => [...accs, account])- // PTY scoping identifies this agent-less login by the core's account list. The ordinary- // settings save is coalesced for 300 ms; launching before it lands uses the system home.- await useSettings.getState().flush()- window.dispatchEvent(- new CustomEvent('nodeterm:add-codex-account-login', { detail: { accountId: added.id } })- )- const captured = await window.nodeTerminal.codexAccounts.waitLogin(added.id)- if (captured) {- applyCodexAccounts((accs) =>- applyResolvedCodexAccounts(accs, [{ id: added.id, email: captured.email }])- )- }+ res = await window.nodeTerminal.claudeAccounts.setSkillSharing(id, enabled)} catch (e) {- // Without this the browser's E_UNSUPPORTED rejection was an UNHANDLED promise rejection: the- // spinner stopped and nothing else happened, which reads as a dead button. Managed Claude- // accounts now work in the browser, so a user who just added one has every reason to expect- // the button beneath it to work too — say why it does not.- setCodexAddError(- isUnsupported(e)- ? 'Managed Codex accounts are not available in the browser yet — manage them from the desktop app.'- : 'Could not set up the Codex account.'+ if (isUnsupported(e)) return 'Sharing skills is not available on this connection.'+ throw e+ }+ if (!res.refused) {+ applyAccounts((accs) =>+ accs.map((a) => (a.id === id ? { ...a, shareSystemSkills: enabled } : a)))- } finally {- setAddingCodex(false)}- }-- const confirmRemoveCodex = async (account: CodexAccount): Promise<void> => {- setPendingRemoveCodex(null)- if (account.pending) await window.nodeTerminal.codexAccounts.cancelWaitLogin(account.id)- // A remote account's home lives on its host; the base remove() acts locally only, so a remote- // account is dropped from settings without a local fs op it does not own (fail-closed — it never- // deletes the wrong machine's home).- if (!account.host) await window.nodeTerminal.codexAccounts.remove(account.id)- applyCodexAccounts((accs) => accs.filter((a) => a.id !== account.id))- useProjects.setState((s) => ({- projects: s.projects.map((p) => ({- ...p,- nodes: p.nodes.map((n) => (n.accountId === account.id ? { ...n, accountId: undefined } : n))- }))- }))- }-- /** The presented Claude account for a row. Mirrors `presentCodex` — one contract, so a linked- * account reads the same here as it would anywhere else it is shown. */- const presentClaude = (account: ClaudeAccount): ReturnType<typeof presentAccount> =>- presentAccount({- label: account.label,- email: account.email,- host: account.host,- machineLabel: sshServers.find((entry) => sshHostKey(entry) === account.host)?.label,- linked: !!account.configDir,- configDir: account.configDir- })-- // The presented account for a row, resolving the friendly machine label from saved servers.- const presentCodex = (account: CodexAccount) => {- const server = account.host- ? sshServers.find((entry) => sshHostKey(entry) === account.host)- : undefined- return presentAccount({- label: account.label,- email: account.email,- host: account.host,- machineLabel: server?.label- })- }-- /** A machine's managed-account rows + the system row header. `remoteHost` set ⇒ that host. */- const codexRowsFor = (- accounts: readonly CodexAccount[],- remoteHost?: string- ): React.JSX.Element => {- const systemEmail = remoteHost ? (remoteSystemCodexEmails[remoteHost] ?? null) : systemCodexEmail- return (- <div className="space-y-2">- <div className="flex items-center justify-between gap-3 rounded-md border border-border/60 p-2">- <AccountIdentityPills- account={presentAccount({- label: null,- email: systemEmail,- host: remoteHost,- machineLabel: remoteHost- ? sshServers.find((s) => sshHostKey(s) === remoteHost)?.label- : undefined- })}- />- </div>- {accounts.map((account) => {- // The SAME fail-closed gate the create/switch UI uses (§5 Property 4): an account that is- // unsafe, missing, or a remote account with no live connection is not operable. Driving- // the row's warning state through it (rather than an ad-hoc host check) makes- // `codexAccountSelectable` a real reader and keeps one definition of "operable".- const selectable = codexAccountSelectable(account.id, codexAccounts, (host) =>- connectedProjectIdForHost(host)- )- const blockedReason = selectable.ok- ? undefined- : selectable.reason === 'no-connection'- ? `Connect to ${account.host} to use this account`- : 'This account is unavailable'- return (- <div- key={account.id}- className="flex items-center justify-between gap-3 rounded-md border border-border/60 p-2"- title={blockedReason}- >- <div className="min-w-0 flex-1 space-y-1">- <div className="flex min-w-0 items-center gap-2">- <Input- className="w-48"- placeholder="Codex account label"- value={account.label}- onChange={(e) => setCodexLabel(account.id, e.target.value)}- />- <AccountIdentityPills account={presentCodex(account)} warning={!selectable.ok} />- {account.pending ? (- <span className="rounded-full bg-[color:var(--warn)]/15 px-2 py-0.5 text-[11px] font-medium text-[color:var(--warn)]">- pending- </span>- ) : null}- </div>- <AccountColorSwatches- label={account.label}- color={account.color}- onPick={(c) => setCodexColor(account.id, c)}- />- </div>- <Button- variant="ghost"- aria-label="Remove Codex account"- onClick={() => setPendingRemoveCodex(account)}- >- <IconClose />- </Button>- </div>- )- })}- </div>- )+ return skillShareNote(res, enabled)}// Open a login terminal for an account and wait (up to ~5 min) for the CLI to write its@@ -585,7 +584,7 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.// the remote `.claude.json` over ssh (via the ctx `projectId`).const runLogin = async (account: Pick<ClaudeAccount, 'id' | 'host'>): Promise<void> => {const remote = !!account.host- const projectId = remote ? projectIdForHost(account.host) : undefined+ const projectId = remote ? connectedProjectIdForHost(account.host) : undefined// Carry `host` so Canvas resolves the ssh binding BY HOST (among connected projects), not from// whatever project happens to be active when Retry fires.window.dispatchEvent(@@ -613,23 +612,23 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.}// `host` set → create the account dir + hook ON that SSH host (via the ctx projectId); the row- // then carries the host chip and only appears in that host's projects.- const onAddAccount = async (host?: string): Promise<void> => {- if (addingOn) return // one setup at a time — the buttons are disabled, this is the guard- const projectId = host ? projectIdForHost(host) : undefined- setAddingOn(host ?? LOCAL_TARGET)- setAddError(null)+ // then lives in that host's panel and is only offered in that host's projects.+ const onAddClaude = async (host?: string): Promise<void> => {+ if (adding) return // one setup at a time — the buttons are disabled, this is the guard+ const key = addKey('claude', host ?? '')+ const projectId = host ? connectedProjectIdForHost(host) : undefined+ if (host && !projectId) return+ setAdding(key)+ setAddError(key, null)let added: { id: string; versionSupported: boolean }try {added = await window.nodeTerminal.claudeAccounts.add(projectId ? { projectId } : undefined)} catch (e) {// The remote path does not reject on a failed setup (it answers with an empty configDir and// lets the login node report the connection error), so reaching here means the call itself- // never landed. Say so: after a spinner, silence is the one outcome that teaches nothing.- // E_UNSUPPORTED is a separate sentence because it is a fact about the surface, not this- // account: the Server Edition serves these channels now, but a relay tab still refuses them- // and so does a server binary older than that change.+ // never landed. E_UNSUPPORTED is its own sentence: a fact about the surface, not the account.setAddError(+ key,isUnsupported(e)? 'Managed Claude accounts are not available on this surface — manage them from the desktop app or the Server Edition directly.': host@@ -641,7 +640,7 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.// Cleared before the login wait below: `runLogin` resolves only when the user finishes// logging in (up to 5 minutes), and a spinner running that long would claim the setup is// still going when the thing to do next is on the canvas.- setAddingOn(null)+ setAdding(null)}// Non-blocking: the account still isolates config, but an old CLI's unscoped macOS keychain// service would collide across accounts — surface a dismissable warning.@@ -711,13 +710,23 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.const confirmRemove = async (account: ClaudeAccount): Promise<void> => {setPendingRemove(null)- // Removing a pending account: stop the 5-minute waitLogin poll loop first.- if (account.pending) await window.nodeTerminal.claudeAccounts.cancelWaitLogin(account.id)- const projectId = projectIdForHost(account.host)- await window.nodeTerminal.claudeAccounts.remove(- account.id,- projectId ? { projectId } : undefined- )+ setRemoveError(null)+ try {+ // Removing a pending account: stop the 5-minute waitLogin poll loop first.+ if (account.pending) await window.nodeTerminal.claudeAccounts.cancelWaitLogin(account.id)+ if (account.host) {+ // A remote account's dir is deleted ON its host, over a live connection. Without one there+ // is nothing to reach — the record is forgotten and the dir stays (the dialog said so). A+ // remote id must never reach the LOCAL remove, which would `rm -rf` this machine's copy.+ const projectId = connectedProjectIdForHost(account.host)+ if (projectId) await window.nodeTerminal.claudeAccounts.remove(account.id, { projectId })+ } else {+ await window.nodeTerminal.claudeAccounts.remove(account.id)+ }+ } catch (e) {+ setRemoveError(errorText(e, `Could not remove "${account.label}".`))+ return+ }applyAccounts((accs) => accs.filter((a) => a.id !== account.id))// Clear the account off serialized nodes (all projects) + any project default...useProjects.setState((s) => ({@@ -747,14 +756,368 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.if (a.configDir) {return `Unlink account "${a.label}"? nodeterm forgets it — the folder ${a.configDir} keeps its login and transcripts exactly as they are. ${fallout}`}- return `Remove account "${a.label}"? Its logged-in credentials and all its Claude transcripts will be deleted. ${fallout}`+ if (a.host && !connectedProjectIdForHost(a.host)) {+ return `Remove account "${a.label}"? ${a.host} is not connected, so nodeterm only forgets it — its login and transcripts stay on that host. ${fallout}`+ }+ return `Remove account "${a.label}"? Its logged-in credentials and all its Claude transcripts${+ a.host ? ` on ${a.host}` : ''+ } will be deleted. ${fallout}`+ }++ // ── Codex ────────────────────────────────────────────────────────────────────────────────────+ const setCodexLabel = (id: string, label: string): void =>+ applyCodexAccounts((accs) => accs.map((a) => (a.id === id ? { ...a, label } : a)))++ const setCodexColor = (id: string, color?: string): void =>+ applyCodexAccounts((accs) => accs.map((a) => (a.id === id ? { ...a, color } : a)))++ /** Open the account's `codex login` node (on its host for a remote one) and wait for the device+ * login to land; on success the row leaves `pending` with the captured email. */+ const runCodexLogin = async (account: Pick<CodexAccount, 'id' | 'host'>): Promise<void> => {+ const remote = !!account.host+ const projectId = remote ? connectedProjectIdForHost(account.host) : undefined+ if (remote && !projectId) return+ window.dispatchEvent(+ new CustomEvent('nodeterm:add-codex-account-login', {+ detail: remote ? { accountId: account.id, remote, host: account.host } : { accountId: account.id }+ })+ )+ const captured = projectId+ ? await window.nodeTerminal.codexAccounts.waitLogin(account.id, { projectId })+ : await window.nodeTerminal.codexAccounts.waitLogin(account.id)+ if (captured) {+ applyCodexAccounts((accs) =>+ applyResolvedCodexAccounts(accs, [{ id: account.id, email: captured.email }])+ )+ }+ }++ // Add a managed Codex account on this machine or, with `host`, ON that connected SSH host: its+ // private CODEX_HOME is created there and the device login runs there, so the credential is+ // written on the machine that uses it and never travels.+ const onAddCodex = async (host?: string): Promise<void> => {+ if (adding) return+ const key = addKey('codex', host ?? '')+ const projectId = host ? connectedProjectIdForHost(host) : undefined+ if (host && !projectId) return+ setAdding(key)+ setAddError(key, null)+ let accountId: string+ try {+ const added = projectId+ ? await window.nodeTerminal.codexAccounts.add({ projectId })+ : await window.nodeTerminal.codexAccounts.add()+ accountId = added.id+ const account: CodexAccount = {+ id: added.id,+ label: 'New Codex account',+ pending: true,+ ...(host ? { host } : {})+ }+ applyCodexAccounts((accs) => [...accs, account])+ // PTY scoping identifies this agent-less login by the core's account list. The ordinary+ // settings save is coalesced for 300 ms; launching before it lands uses the system home.+ await useSettings.getState().flush()+ } catch (e) {+ // Without this the browser's E_UNSUPPORTED rejection was an UNHANDLED promise rejection: the+ // spinner stopped and nothing else happened, which reads as a dead button.+ setAddError(+ key,+ isUnsupported(e)+ ? 'Managed Codex accounts are not available in the browser yet — manage them from the desktop app.'+ : host+ ? errorText(e, `Could not set up a Codex account on ${host}.`)+ : 'Could not set up the Codex account.'+ )+ return+ } finally {+ setAdding(null)+ }+ await runCodexLogin({ id: accountId, host })}+ const confirmRemoveCodex = async (account: CodexAccount): Promise<void> => {+ setPendingRemoveCodex(null)+ setRemoveError(null)+ try {+ if (account.pending) await window.nodeTerminal.codexAccounts.cancelWaitLogin(account.id)+ if (account.host) {+ // Deleted ON its host over a live connection; without one the record is only forgotten+ // (the dialog said so). Never the local remove — it acts on this machine's homes.+ const projectId = connectedProjectIdForHost(account.host)+ if (projectId) await window.nodeTerminal.codexAccounts.remove(account.id, { projectId })+ } else {+ await window.nodeTerminal.codexAccounts.remove(account.id)+ }+ } catch (e) {+ // Local removal refuses while an account switch holds the account — say so, keep the row.+ setRemoveError(errorText(e, `Could not remove "${account.label}".`))+ return+ }+ applyCodexAccounts((accs) => accs.filter((a) => a.id !== account.id))+ useProjects.setState((s) => ({+ projects: s.projects.map((p) => ({+ ...p,+ nodes: p.nodes.map((n) => (n.accountId === account.id ? { ...n, accountId: undefined } : n))+ }))+ }))+ }++ const removeCodexMessage = (a: CodexAccount): string => {+ if (a.host && !connectedProjectIdForHost(a.host)) {+ return `Remove Codex account "${a.label}"? ${a.host} is not connected, so nodeterm only forgets it — its login and Codex home stay on that host.`+ }+ return `Remove Codex account "${a.label}"? Its logged-in credentials and its Codex home${+ a.host ? ` on ${a.host}` : ''+ } will be deleted.`+ }++ // ── Rows ─────────────────────────────────────────────────────────────────────────────────────+ const machineLabelFor = (host?: string): string | undefined =>+ host ? sshServers.find((entry) => sshHostKey(entry) === host)?.label : undefined++ /** The Retry-login button both providers show on a pending row; a remote one needs its host. */+ const retryButton = (host: string | undefined, onRetry: () => void): React.JSX.Element => {+ const blocked = !!host && !connectedProjectIdForHost(host)+ return (+ <Button+ disabled={blocked}+ title={blocked ? `Connect to ${host} to finish logging in` : undefined}+ onClick={onRetry}+ >+ Retry login+ </Button>+ )+ }++ const claudeRow = (account: ClaudeAccount, showHost: boolean): React.JSX.Element => {+ const presented = presentAccount({+ label: account.label,+ email: account.email,+ host: account.host,+ machineLabel: machineLabelFor(account.host),+ linked: !!account.configDir,+ configDir: account.configDir+ })+ return (+ <ManagedAccountRow+ key={account.id}+ label={account.label}+ placeholder="Account label"+ onLabel={(v) => setLabel(account.id, v)}+ pending={account.pending}+ email={account.email}+ color={account.color}+ onColor={(c) => setColor(account.id, c)}+ pills={+ <>+ {/* A LINKED account: the user's own dir, adopted rather than minted. The path is the+ identifying fact, so it rides the tooltip — through `presentAccount`, so this row+ says the same thing every other account surface would. */}+ {account.configDir ? (+ <span+ className="rounded-full bg-fill-weak px-2 py-0.5 text-[11px] font-medium text-muted"+ title={presented.tooltip}+ >+ {presented.provenance}+ </span>+ ) : null}+ {showHost && account.host ? (+ <span+ className="rounded-full bg-[color:var(--accent)]/15 px-2 py-0.5 text-[11px] font-medium text-[color:var(--accent)]"+ title={`Remote account on ${account.host}`}+ >+ {account.host}+ </span>+ ) : null}+ </>+ }+ extra={+ <SkillSharingRow account={account} onChange={(v) => setSkillSharing(account.id, v)} />+ }+ actions={+ <>+ {account.pending ? retryButton(account.host, () => void runLogin(account)) : null}+ <Button+ variant="ghost"+ // "Unlink" for a linked dir: the action really is different (the folder stays), and+ // the label is what a screen reader and the tests both go by.+ aria-label={account.configDir ? 'Unlink account' : 'Remove account'}+ onClick={() => setPendingRemove(account)}+ >+ <IconClose />+ </Button>+ </>+ }+ />+ )+ }++ const codexRow = (account: CodexAccount, showHost: boolean): React.JSX.Element => {+ // The SAME fail-closed gate the create/switch UI uses (§5 Property 4): an account that is+ // unsafe, missing, or a remote account with no live connection is not operable.+ const selectable = codexAccountSelectable(account.id, codexAccounts, (host) =>+ connectedProjectIdForHost(host)+ )+ const blockedReason = selectable.ok+ ? undefined+ : selectable.reason === 'no-connection'+ ? `Connect to ${account.host} to use this account`+ : 'This account is unavailable'+ return (+ <ManagedAccountRow+ key={account.id}+ label={account.label}+ placeholder="Codex account label"+ onLabel={(v) => setCodexLabel(account.id, v)}+ pending={account.pending}+ email={account.email}+ color={account.color}+ onColor={(c) => setCodexColor(account.id, c)}+ blockedReason={account.pending ? undefined : blockedReason}+ pills={+ showHost && account.host ? (+ <span+ className="rounded-full bg-[color:var(--accent)]/15 px-2 py-0.5 text-[11px] font-medium text-[color:var(--accent)]"+ title={`Remote account on ${account.host}`}+ >+ {account.host}+ </span>+ ) : null+ }+ actions={+ <>+ {account.pending ? retryButton(account.host, () => void runCodexLogin(account)) : null}+ <Button+ variant="ghost"+ aria-label="Remove Codex account"+ onClick={() => setPendingRemoveCodex(account)}+ >+ <IconClose />+ </Button>+ </>+ }+ />+ )+ }++ /** A provider's Add button on one machine: local always, remote only over a live connection. */+ const addButton = (provider: Provider, host: string): React.JSX.Element => {+ const key = addKey(provider, host)+ const where = host || thisMachine()+ const reachable = !host || !!connectedProjectIdForHost(host)+ const text = provider === 'claude' ? 'Add Claude account' : 'Add Codex account'+ return (+ <Button+ variant="primary"+ disabled={adding !== null || !reachable}+ title={reachable ? undefined : `Connect to ${host} to add an account there`}+ onClick={() =>+ void (provider === 'claude' ? onAddClaude(host || undefined) : onAddCodex(host || undefined))+ }+ >+ {adding === key ? (+ <span className="inline-flex items-center gap-2">+ <span className="ui-spinner" aria-hidden />+ Setting up on {where}…+ </span>+ ) : (+ text+ )}+ </Button>+ )+ }++ /** What the spinner is waiting for — a remote setup takes long enough that silence reads as a+ * broken button. */+ const progressFor = (provider: Provider, host: string): string | null => {+ if (adding !== addKey(provider, host)) return null+ if (!host) return 'Creating the account directory and installing the status hook…'+ return provider === 'claude'+ ? `Creating the config dir on ${host} and installing the status hook and agent skills over SSH — this takes a few seconds. The login terminal opens when it's ready.`+ : `Creating the Codex home on ${host} over SSH — the login terminal opens when it's ready.`+ }++ const linkExisting = (+ // LINK an existing config dir. The other half of "several Claude logins": a user who already+ // keeps `~/.claude-2` and drives it from their own shell function does not want a new managed+ // dir — they want THIS one to have an id. Local only: a linked dir is a path on the machine that+ // owns the files. Folded away by default: it is the rarer way in, and the Add button is the+ // common one.+ <details className="rounded-md border border-border/60 p-2" open={!!linkPath || !!linkError}>+ <summary className="cursor-pointer text-[12px] font-medium text-text">+ Link an existing config dir…+ </summary>+ <div className="space-y-2 pt-2">+ <p className="text-[12px] leading-relaxed text-muted">+ Already have a second login in its own folder (say <code>~/.claude-2</code>)? Link it and+ nodeterm will label its terminals, read its transcripts, and offer it in the add menus.+ Nothing is copied or moved, and unlinking later leaves the folder alone.+ </p>+ <div className="flex flex-wrap items-center gap-2">+ <Input+ className="w-72"+ placeholder="~/.claude-2"+ value={linkPath}+ onChange={(e) => setLinkPath(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === 'Enter') void onLink(linkPath)+ }}+ />+ {browseUnsupported ? null : (+ <Button disabled={linking} onClick={() => void onBrowse()}>+ Browse…+ </Button>+ )}+ <Button+ variant="primary"+ // Named: the detected list repeats the word "Link" once per row, and a bare label+ // leaves both the user's screen reader and the tests guessing which.+ aria-label="Link config dir"+ disabled={linking || !linkPath.trim()}+ onClick={() => void onLink(linkPath)}+ >+ {linking ? (+ <span className="inline-flex items-center gap-2">+ <span className="ui-spinner" aria-hidden />+ Linking…+ </span>+ ) : (+ 'Link'+ )}+ </Button>+ </div>+ {linkError ? <p className="text-[12px] text-[color:var(--danger)]">{linkError}</p> : null}+ </div>+ </details>+ )++ // DETECTED dirs: config dirs whose sessions actually posted hooks here and that we have no+ // account for. Derived from observations only — nothing on disk is read for an unlinked dir (a+ // forged POST must not make us stat anything), so the path is all that is shown. Shown OUTSIDE+ // the fold: it is a suggestion about a login the user is demonstrably using.+ const detectedBlock =+ detected.length > 0 ? (+ <div className="space-y-2 rounded-md border border-dashed border-border/60 p-2">+ <div className="text-[12px] font-medium text-text">Detected config dirs</div>+ {detected.map((dir) => (+ <div key={dir} className="flex items-center justify-between gap-3">+ <span className="min-w-0 flex-1 truncate text-[12px] text-muted" title={dir}>+ {dir}+ </span>+ <Button aria-label={`Link ${dir}`} disabled={linking} onClick={() => void onLink(dir)}>+ Link+ </Button>+ </div>+ ))}+ </div>+ ) : null+return (<SettingsSectionid="accounts"title="Accounts"- description="Isolated Claude logins. Each account has its own config dir, credentials, and transcripts; a node keeps the account it was created with for life."+ description="Separate Claude and Codex logins, grouped by the machine they live on. Each account has its own login, settings and history; pick one when you open an agent, or move a running node to another from its right-click menu."isActive={isActive}searchEntries={ENTRIES}>@@ -775,310 +1138,91 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.</button></div>) : null}+ {removeError ? (+ <p className="text-[12px] text-[color:var(--danger)]">{removeError}</p>+ ) : null}- {/* The SYSTEM account (the machine's default ~/.claude login) is implicit — not a- ClaudeAccount record — but gets a fixed row so it can be told apart from managed- accounts: detected email as subtitle, renamable display label (empty = default). */}- <div className="flex items-center justify-between gap-3 rounded-md border border-border p-3">- <div className="min-w-0 flex-1 space-y-1">- <div className="flex items-center gap-2">- <Input- className="w-56"- placeholder="System account"- value={systemLabelSetting}- onChange={(e) => useSettings.getState().update({ systemAccountLabel: e.target.value })}- />- <span- className="rounded-full bg-fill-weak px-2 py-0.5 text-[11px] font-medium text-muted"- title="The machine's default Claude login (~/.claude). Used when a node has no account."- >- system- </span>- </div>- {systemEmail ? <p className="text-[12px] text-muted">{systemEmail}</p> : null}- </div>- </div>-- {accounts.length === 0 ? null : (- accounts.map((account) => (- <div- key={account.id}- className="flex items-center justify-between gap-3 rounded-md border border-border p-3"+ {machines.map((m) => {+ const host = m.host // '' = this machine+ const connected = !m.remote || !!connectedProjectIdForHost(host)+ const codexSystemEmail = m.remote ? (remoteSystemCodexEmails[host] ?? null) : systemCodexEmail+ return (+ <MachinePanel+ key={host || 'local'}+ label={m.remote ? (m.server?.label ?? host) : thisMachineCap()}+ remote={m.remote}+ hostKey={host || undefined}+ connected={connected}>- <div className="min-w-0 flex-1 space-y-1">- <div className="flex items-center gap-2">- <Input- className="w-56"- placeholder="Account label"- value={account.label}- onChange={(e) => setLabel(account.id, e.target.value)}- />- {account.pending ? (- <span className="rounded-full bg-[color:var(--warn)]/15 px-2 py-0.5 text-[11px] font-medium text-[color:var(--warn)]">- pending- </span>- ) : null}- {account.host ? (- <span- className="rounded-full bg-[color:var(--accent)]/15 px-2 py-0.5 text-[11px] font-medium text-[color:var(--accent)]"- title={`Remote account on ${account.host}`}- >- {account.host}- </span>- ) : null}- {/* A LINKED account: the user's own dir, adopted rather than minted. The path- is the identifying fact (no label reliably tells `.claude-2` from- `.claude-work`), so it rides the tooltip — through `presentAccount`, so- this row says the same thing every other account surface would. */}- {account.configDir ? (- <span- className="rounded-full bg-fill-weak px-2 py-0.5 text-[11px] font-medium text-muted"- title={presentClaude(account).tooltip}- >- {presentClaude(account).provenance}- </span>- ) : null}- </div>- {account.email && !account.pending ? (- <p className="text-[12px] text-muted">{account.email}</p>- ) : null}- <AccountColorSwatches- label={account.label}- color={account.color}- onPick={(c) => setColor(account.id, c)}- />- <SkillSharingRow- account={account}- onChange={(v) => setSkillSharing(account.id, v)}- />- </div>- <div className="flex shrink-0 items-center gap-2">- {account.pending- ? (() => {- // A remote account can only retry login on a connected matching-host- // project; without one, disable Retry (a local spawn would log into the- // system account instead of the remote host).- const blocked = !!account.host && !connectedProjectIdForHost(account.host)- return (- <Button- disabled={blocked}- title={- blocked- ? `Connect to ${account.host} to finish logging in`- : undefined- }- onClick={() => void runLogin(account)}- >- Retry login- </Button>- )- })()- : null}- <Button- variant="ghost"- // "Unlink" for a linked dir: the action really is different (the folder stays),- // and the label is what a screen reader and the tests both go by.- aria-label={account.configDir ? 'Unlink account' : 'Remove account'}- onClick={() => setPendingRemove(account)}- >- <IconClose />- </Button>- </div>- </div>- ))- )}-- {activeHostKey ? (- // Inside an SSH project: choose where the new account lives. "On this machine" is a- // normal local account; "On <host>" creates it on the remote host (usable only there).- <div className="space-y-2">- <div className="flex flex-wrap items-center gap-2">- <Button- variant="primary"- disabled={addingOn !== null}- onClick={() => void onAddAccount()}- >- {addingOn === LOCAL_TARGET ? (- <AddingLabel where={thisMachine()} />- ) : (- `Add account — On ${thisMachine()}`- )}- </Button>- <Button- variant="primary"- disabled={addingOn !== null}- onClick={() => void onAddAccount(activeHostKey)}+ <ProviderBlock+ agentId="claude"+ title="Claude"+ action={addButton('claude', host)}+ progress={progressFor('claude', host)}+ error={addErrors[addKey('claude', host)]}>- {addingOn === activeHostKey ? (- <AddingLabel where={activeHostKey} />- ) : (- `Add account — On ${activeHostKey}`- )}- </Button>- </div>- {/* A spinner says "wait"; this says what for. Setting up a remote account is a- handful of ssh round-trips plus a login-shell `claude --version`, so it takes- long enough that silence reads as a broken button. */}- {addingOn !== null ? (- <p className="text-[12px] leading-relaxed text-muted">- {addingOn === LOCAL_TARGET- ? 'Creating the config dir and installing the status hook…'- : `Creating the config dir on ${addingOn} and installing the status hook and agent skills over SSH — this takes a few seconds. The login terminal opens when it's ready.`}- </p>- ) : null}- {addError ? <p className="text-[12px] text-[color:var(--danger)]">{addError}</p> : null}- </div>- ) : (- <div className="space-y-2">- <Button- variant="primary"- disabled={addingOn !== null}- onClick={() => void onAddAccount()}- >- {addingOn === LOCAL_TARGET ? <AddingLabel where={thisMachine()} /> : 'Add account'}- </Button>- {addingOn !== null ? (- <p className="text-[12px] leading-relaxed text-muted">- Creating the config dir and installing the status hook…- </p>- ) : null}- {addError ? <p className="text-[12px] text-[color:var(--danger)]">{addError}</p> : null}- </div>- )}-- {/* LINK an existing config dir. The other half of "several Claude logins": a user- who already keeps `~/.claude-2` and drives it from their own shell function does not- want a new managed dir — they want THIS one to have an id, so the chip, the transcript- readers and the pickers stop treating their second login as a stranger. Local only:- a linked dir is a path on the machine that owns the files. */}- <div className="space-y-2 rounded-md border border-border p-3">- <div className="text-[13px] font-medium text-text">Link existing config dir…</div>- <p className="text-[12px] leading-relaxed text-muted">- Already have a second login in its own folder (say <code>~/.claude-2</code>)? Link it- and nodeterm will label its terminals, read its transcripts, and offer it in the add- menus. Nothing is copied or moved, and unlinking later leaves the folder alone.- </p>- <div className="flex flex-wrap items-center gap-2">- <Input- className="w-72"- placeholder="~/.claude-2"- value={linkPath}- onChange={(e) => setLinkPath(e.target.value)}- onKeyDown={(e) => {- if (e.key === 'Enter') void onLink(linkPath)- }}- />- {browseUnsupported ? null : (- <Button disabled={linking} onClick={() => void onBrowse()}>- Browse…- </Button>- )}- <Button- variant="primary"- // Named: the detected list below repeats the word "Link" once per row, and a- // bare label leaves both the user's screen reader and the tests guessing which.- aria-label="Link config dir"- disabled={linking || !linkPath.trim()}- onClick={() => void onLink(linkPath)}- >- {linking ? (- <span className="inline-flex items-center gap-2">- <span className="ui-spinner" aria-hidden />- Linking…- </span>- ) : (- 'Link'- )}- </Button>- </div>- {linkError ? <p className="text-[12px] text-[color:var(--danger)]">{linkError}</p> : null}-- {/* DETECTED dirs: config dirs whose sessions actually posted hooks here and that we- have no account for. Derived from observations only — nothing on disk is read for- an unlinked dir (a forged POST must not make us stat anything), so the path is all- that is shown. Empty ⇒ this whole block is absent. */}- {detected.length > 0 ? (- <div className="space-y-2 pt-1">- <div className="text-[12px] font-medium text-text">Detected config dirs</div>- {detected.map((dir) => (- <div- key={dir}- className="flex items-center justify-between gap-3 rounded-md border border-border/60 p-2"- >- <span className="min-w-0 flex-1 truncate text-[12px] text-muted" title={dir}>- {dir}- </span>- <Button aria-label={`Link ${dir}`} disabled={linking} onClick={() => void onLink(dir)}>- Link- </Button>- </div>- ))}- </div>- ) : null}- </div>-- <p className="text-[12px] leading-relaxed text-muted">- Accounts are isolated Claude logins. New Claude nodes pick an account from the add- menus; each node keeps its account for life. A node color applies to nodes opened under- that account from then on — existing ones keep the color they have. Remote accounts live- on an SSH host and are only offered in that host's projects.- </p>- </div>- </SearchableRow>-- {/* Codex accounts, grouped by machine. Each managed Codex login has its own CODEX_HOME and- credentials; a node keeps its account for life. Machine provenance (Local / SSH · host)- is shown as a pill; the credential-storage kind is deliberately not surfaced. */}- <SearchableRow {...ROWS.codex}>- <div className="space-y-4">- {codexGroups.map((group) => (- <MachinePanel- key={group.host || 'local'}- label={group.remote ? (group.server?.label ?? group.host) : thisMachineCap()}- remote={group.remote}- hostKey={group.host || undefined}- connected={group.remote ? !!connectedProjectIdForHost(group.host) : true}- >- {codexRowsFor(group.accounts, group.remote ? group.host : undefined)}- {!group.remote ? (- <div className="space-y-2">- <Button variant="primary" disabled={addingCodex} onClick={() => void onAddCodexAccount()}>- {addingCodex ? (- <span className="inline-flex items-center gap-2">- <span className="ui-spinner" aria-hidden />- Setting up on {thisMachine()}…- </span>- ) : (- 'Add Codex account'- )}- </Button>- {codexAddError ? (- <p className="text-[12px] text-[color:var(--danger)]">{codexAddError}</p>+ <SystemAccountRow+ name={+ m.remote ? (+ <span className="text-[13px] text-text">System account</span>+ ) : (+ // The local SYSTEM account is implicit (no ClaudeAccount record) but gets+ // a renamable display label (empty = default) so pickers tell it apart.+ <Input+ className="w-56"+ placeholder="System account"+ value={systemLabelSetting}+ onChange={(e) =>+ useSettings.getState().update({ systemAccountLabel: e.target.value })+ }+ />+ )+ }+ detail={m.remote ? `~/.claude on ${host}` : systemEmail}+ />+ {m.claude.map((a) => claudeRow(a, false))}+ {!m.remote ? (+ <>+ {detectedBlock}+ {linkExisting}+ </>) : null}- </div>- ) : (- <p className="text-[12px] leading-relaxed text-muted">- Codex accounts on this machine are managed from its own NodeTerm. Accounts already- created here are shown above.- </p>- )}- </MachinePanel>- ))}+ </ProviderBlock>+ <div className="border-t border-border/60" aria-hidden />+ <ProviderBlock+ agentId="codex"+ title="Codex"+ action={addButton('codex', host)}+ progress={progressFor('codex', host)}+ error={addErrors[addKey('codex', host)]}+ >+ <SystemAccountRow+ name={<span className="text-[13px] text-text">System account</span>}+ detail={codexSystemEmail ?? (m.remote ? `~/.codex on ${host}` : '~/.codex')}+ />+ {m.codex.map((a) => codexRow(a, false))}+ </ProviderBlock>+ </MachinePanel>+ )+ })}- {codexStrays.length > 0 ? (+ {claudeStrays.length + codexStrays.length > 0 ? (<div className="space-y-2 rounded-md border border-[color:var(--warn)]/40 p-3"><p className="text-[12px] font-medium text-[color:var(--warn)]">Accounts on machines you no longer have saved</p>- {codexRowsFor(codexStrays)}+ {claudeStrays.map((a) => claudeRow(a, true))}+ {codexStrays.map((a) => codexRow(a, true))}</div>) : null}<p className="text-[12px] leading-relaxed text-muted">- Codex accounts are isolated logins, grouped by the machine their credentials live on.- New Codex nodes pick an account from the add menus; each node keeps its account for life.- A node color applies to nodes opened under that account from then on — existing ones- keep the color they have.+ An account on an SSH host is created, logged into and removed ON that host — its+ credentials never leave it — and is only offered in that host's projects.+ {hiddenMachines > 0+ ? ` ${hiddenMachines} saved SSH ${hiddenMachines === 1 ? 'server has' : 'servers have'} no accounts yet and ${hiddenMachines === 1 ? 'appears' : 'appear'} here once connected.`+ : ''}{' '}+ A node color applies to nodes opened under that account from then on.</p></div></SearchableRow>@@ -1093,11 +1237,7 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.) : null}{pendingRemoveCodex ? (<ConfirmDialog- message={`Remove Codex account "${pendingRemoveCodex.label}"?${- pendingRemoveCodex.host- ? ' It is dropped from this NodeTerm; its credentials on the host are untouched.'- : ' Its logged-in credentials and its Codex home will be deleted.'- }`}+ message={removeCodexMessage(pendingRemoveCodex)}confirmLabel="Remove"onConfirm={() => void confirmRemoveCodex(pendingRemoveCodex)}onCancel={() => setPendingRemoveCodex(null)}diff --git a/src/renderer/lib/codexMachineGroups.ts b/src/renderer/lib/codexMachineGroups.tsindex d0e9a1158..875d0b4d2 100644--- a/src/renderer/lib/codexMachineGroups.ts+++ b/src/renderer/lib/codexMachineGroups.ts@@ -2,8 +2,10 @@// #112 inline `AccountsSection` logic so the "one panel per host, accounts under the right machine"// invariant is unit-tested apart from the JSX.//-// Renderer-pure: no `src/core`, no IPC. It only rearranges the flat `settings.codexAccounts` array-// (partitioned by `host`) alongside the deduped set of reachable SSH machines.+// Renderer-pure: no `src/core`, no IPC. It only rearranges a flat account array (partitioned by+// `host`) alongside the deduped set of reachable SSH machines. The grouping itself is generic+// (`groupAccountsByMachine` / `strayAccounts`): the Accounts settings puts Claude AND Codex accounts+// on the same machine panels, so the two providers can never disagree about where an account lives.import type { SshConnection } from '@shared/ssh'import { sshHostKey } from '@shared/ssh'@@ -57,7 +59,20 @@ export function groupCodexAccountsByMachine(accounts: readonly CodexAccount[],remoteTargets: readonly CodexRemoteTarget[]): CodexMachineGroup[] {- const local: CodexMachineGroup = {+ return groupAccountsByMachine(accounts, remoteTargets)+}++/** A machine panel for any provider's account type (see `CodexMachineGroup`). */+export interface AccountMachineGroup<T> extends Omit<CodexMachineGroup, 'accounts'> {+ accounts: T[]+}++/** `groupCodexAccountsByMachine`, for any account type that carries an optional `host`. */+export function groupAccountsByMachine<T extends { host?: string | null }>(+ accounts: readonly T[],+ remoteTargets: readonly CodexRemoteTarget[]+): AccountMachineGroup<T>[] {+ const local: AccountMachineGroup<T> = {host: '',remote: false,accounts: accounts.filter((account) => !account.host)@@ -77,6 +92,14 @@ export function strayCodexAccounts(accounts: readonly CodexAccount[],remoteTargets: readonly CodexRemoteTarget[]): CodexAccount[] {+ return strayAccounts(accounts, remoteTargets)+}++/** `strayCodexAccounts`, for any account type that carries an optional `host`. */+export function strayAccounts<T extends { host?: string | null }>(+ accounts: readonly T[],+ remoteTargets: readonly CodexRemoteTarget[]+): T[] {const known = new Set(remoteTargets.map(([host]) => host))return accounts.filter((account) => account.host && !known.has(account.host))}