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): route the settings account rows through codexAccountSelectable (review I2)

Claude Code61570c196234
diff --git a/src/renderer/canvas/codex-account-switch.ts b/src/renderer/canvas/codex-account-switch.ts
index 65233ce7f..854cf75dd 100644
--- a/src/renderer/canvas/codex-account-switch.ts
+++ b/src/renderer/canvas/codex-account-switch.ts
@@ -7,6 +7,21 @@
// 2. `codexAccountSelectable` — an explicitly selected account that is MISSING, unsafe, or a
// remote account with no live connection is REFUSED; the UI never silently falls back to
// another login (§5 Property 4 / Decision 2).
+//
+// READERS / follow-up wiring:
+// - `codexAccountSelectable` is consumed today by the Accounts settings UI
+// (`AccountsSection.tsx`), which drives each Codex row's operable/warning state through it — one
+// definition of "operable" for the surface PR 8 builds. It is ALSO the gate the "New Codex
+// node" account picker must route every pick through once that picker exists. That picker is a
+// FOLLOW-UP (surface §3.4): the base node factory deliberately refuses a non-Claude accountId
+// (`createAgentNode` in `state/workspace.ts` stamps `accountId` only when `agentId==='claude'`)
+// and `addAgentNode` validates against `claudeAccounts`, so wiring a Codex picker first needs
+// the factory/creation path to carry codex account ids. The pty spawn side already honours one
+// (`pty-manager.ts` applies `codexSessionEnv` and fails closed on a missing home).
+// - `codexAccountSwitchStillEligible` is the recycle gate the account-SWITCH menu (surface §3.5)
+// must consult before reusing the source pane. That menu is a FOLLOW-UP: the renderer switch
+// bridge (`codexAccounts.switchThread` et al.) is still a stub, so no switch is originated in
+// the renderer yet. When the switch menu lands it MUST gate recycle on this function.
import type { CodexAccount } from '@shared/codex-account'
import { isSafeAccountId } from '@shared/codex-account'
diff --git a/src/renderer/components/settings/sections/AccountsSection.tsx b/src/renderer/components/settings/sections/AccountsSection.tsx
index aa2d2983a..df8b58615 100644
--- a/src/renderer/components/settings/sections/AccountsSection.tsx
+++ b/src/renderer/components/settings/sections/AccountsSection.tsx
@@ -19,6 +19,7 @@ import {
strayCodexAccounts
} from '../../../lib/codexMachineGroups'
import { presentAccount } from '../../../lib/accountPresentation'
+import { codexAccountSelectable } from '../../../canvas/codex-account-switch'
import { AccountIdentityPills } from '../../AccountIdentityPills'
import { ConfirmDialog } from '../../ConfirmDialog'
import { SettingsSection } from '../SettingsSection'
@@ -293,11 +294,23 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.
/>
</div>
{accounts.map((account) => {
- const blockedRemote = !!account.host && !connectedProjectIdForHost(account.host)
+ // 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="flex min-w-0 flex-1 items-center gap-2">
<Input
@@ -306,7 +319,7 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.
value={account.label}
onChange={(e) => setCodexLabel(account.id, e.target.value)}
/>
- <AccountIdentityPills account={presentCodex(account)} warning={blockedRemote} />
+ <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