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(accounts): give Codex accounts the same default node color

Uri Blochf4f6db35e95c
diff --git a/CLAUDE.md b/CLAUDE.md
index 922f8e98d..7395b48f1 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1264,18 +1264,23 @@ else, and its context links must keep classifying across restarts).
= **bit-for-bit legacy behavior** (no env touched). Inherited by **Branch** (the
terminal→chat fork it also fed is gone — the SDK chat node was removed 2026-07). A pending
(not-yet-logged-in) account resolves to `undefined` until it completes.
- - **`ClaudeAccount.color` (optional)** — a per-account default node color (Settings → Accounts)
- that beats the agent's own brand color in `createAgentNode`, so a second login is recognizable
- on the canvas. Read through `accountNodeColor` off the SAME `boundAccountId` that stamps
- `data.accountId`, so the color and the binding cannot drift. Applied **at creation** and baked
- into `data.color` like any other node color: a hand-picked node color is never overwritten and
- editing the account later repaints nothing. Unset / stale id / non-claude agent ⇒ the agent's
- color, unchanged — **Claude accounts only**: a `CodexAccount` carries no `color`, so a
- codex-bound node keeps the agent's color and the lookup is not even attempted for one (asking
- `claudeAccounts` about a Codex id is a cross-list question with no right answer). The value is **re-validated as a string** at the read: `claudeAccounts` comes
- out of a hand-editable settings.json that nothing checks field-by-field on load, and a
- `"color": 123` would throw on `.trim()` INSIDE `createAgentNode` — stopping every new node
- under that account from opening, with nothing pointing back at the edited file.
+ - **Account default node color (`ClaudeAccount.color` / `CodexAccount.color`, optional)** — a
+ per-account default node color (Settings → Accounts) that beats the agent's own brand color in
+ `createAgentNode`, so a second login is recognizable on the canvas. Read off the SAME
+ `boundAccountId` that stamps `data.accountId`, so the color and the binding cannot drift.
+ Applied **at creation** and baked into `data.color` like any other node color: a hand-picked
+ node color is never overwritten and editing the account later repaints nothing. Unset / stale
+ id / an agent that takes no managed account ⇒ the agent's color, unchanged.
+ **Which list answers is `agentAccountColor`'s alone** (`shared/agents/account-color.ts`, one
+ definition shared by `createAgentNode` and the phone-registered node path in `src/main`):
+ claude reads `claudeAccounts`, codex reads `codexAccounts`, everything else reads nothing. The
+ two lists are keyed **independently** — nothing stops the same id appearing in both — so a node
+ colored from the other list would be repainted from a stranger's row; the swatch UI is one
+ component (`AccountColorSwatches`) rendered by both row kinds for the same reason.
+ The value is **re-validated as a string** at the read: the account lists come out of a
+ hand-editable settings.json that nothing checks field-by-field on load, and a `"color": 123`
+ would throw on `.trim()` INSIDE `createAgentNode` — stopping every new node under that account
+ from opening, with nothing pointing back at the edited file.
- **Env injection** — `pty-manager` sets `CLAUDE_CONFIG_DIR` in the spawn env AND as a tmux `-e`
(local); for a remote node it emits an **absolute-path** remote tmux `-e` built from the
connection-cached `remoteHome` (skipped **fail-open** if home is unresolved). `AUTH_ENV_STRIP`
diff --git a/src/main/index.ts b/src/main/index.ts
index 3cb33e5ee..d03be29c2 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -182,7 +182,7 @@ import { geminiContextParse } from '../core/gemini-session'
import { codexContextParse } from '../core/codex-session'
import { codexHome } from '../core/usage/codex-usage'
import { grokRawFields, isAsyncSubagentLaunch, type NormalizedAgentEvent } from '../shared/agents/normalize'
-import { accountNodeColor } from '../shared/agents/account-color'
+import { agentAccountColor } from '../shared/agents/account-color'
import { grokSessionDir, grokSessionsDir } from '../core/agents/grok-paths'
import { forgetGrokSession, rememberGrokSessionDir } from '../core/grok-session'
import {
@@ -3270,8 +3270,13 @@ app.whenReady().then(async () => {
node,
new Date(),
// Host-derived, exactly as on the canvas: the account's default color beats the agent's,
- // so a phone-started session under a colored account is recognizable in the same way.
- accountNodeColor(node.accountId, settingsStore.get().claudeAccounts ?? [])
+ // so a phone-started session under a colored account is recognizable in the same way. The
+ // agent decides WHICH account list answers (agentAccountColor) — the phone supplies both
+ // ids, and the two lists are keyed independently.
+ agentAccountColor(node.agentId, node.accountId, {
+ claude: settingsStore.get().claudeAccounts ?? [],
+ codex: settingsStore.get().codexAccounts ?? []
+ })
),
// Jail roots beyond the active canvas: the phone browses EVERY project (projects.list), so
// its fs/git access spans every local project root — not just the tab the desktop happens
diff --git a/src/renderer/components/settings/sections/AccountsSection.color.test.tsx b/src/renderer/components/settings/sections/AccountsSection.color.test.tsx
index 8f78e9b02..28bb3db2a 100644
--- a/src/renderer/components/settings/sections/AccountsSection.color.test.tsx
+++ b/src/renderer/components/settings/sections/AccountsSection.color.test.tsx
@@ -4,12 +4,18 @@ import { createRoot, type Root } from 'react-dom/client'
import { act } from 'react'
import { AccountsSection } from './AccountsSection'
import { useSettings } from '../../../state/settings'
+import type { CodexAccount } from '@shared/codex-account'
import { DEFAULT_SETTINGS, type ClaudeAccount } from '@shared/types'
const account: ClaudeAccount = { id: 'a1', label: 'work', createdAt: 0 }
-function renderSection(accounts: ClaudeAccount[]): { host: HTMLElement; root: Root } {
- useSettings.setState({ settings: { ...DEFAULT_SETTINGS, claudeAccounts: accounts } })
+function renderSection(
+ accounts: ClaudeAccount[],
+ codexAccounts: CodexAccount[] = []
+): { host: HTMLElement; root: Root } {
+ useSettings.setState({
+ settings: { ...DEFAULT_SETTINGS, claudeAccounts: accounts, codexAccounts }
+ })
const host = document.createElement('div')
document.body.appendChild(host)
const root = createRoot(host)
@@ -32,6 +38,9 @@ function swatch(host: HTMLElement, label: string, name: string): HTMLButtonEleme
const colorOf = (id: string): string | undefined =>
useSettings.getState().settings.claudeAccounts.find((a) => a.id === id)?.color
+const codexColorOf = (id: string): string | undefined =>
+ useSettings.getState().settings.codexAccounts.find((a) => a.id === id)?.color
+
beforeEach(() => {
document.body.innerHTML = ''
// The section also mounts the Codex-accounts panel, which hydrates the SSH server list and the
@@ -91,4 +100,37 @@ describe('AccountsSection — default node color', () => {
expect(colorOf('a2')).toBe('#ff453a')
root.unmount()
})
+
+ // Codex accounts are managed the same way and bind to nodes through the same `data.accountId`,
+ // so they carry the same swatch group — a machine with two Codex logins is exactly the case the
+ // feature exists for. The rows render in their own machine panel, hence the separate lookup.
+ it('stores the picked color on a Codex account', () => {
+ const { host, root } = renderSection([], [{ id: 'c1', label: 'codex work' }])
+ act(() => {
+ swatch(host, 'codex work', '#32d74b').click()
+ })
+ expect(codexColorOf('c1')).toBe('#32d74b')
+ root.unmount()
+ })
+
+ it('clears a Codex account’s color back to the agent default', () => {
+ const { host, root } = renderSection([], [{ id: 'c1', label: 'codex work', color: '#32d74b' }])
+ act(() => {
+ swatch(host, 'codex work', 'Default').click()
+ })
+ expect(codexColorOf('c1')).toBeUndefined()
+ root.unmount()
+ })
+
+ // One list must never write through the other: the two are keyed independently and an id can
+ // legitimately appear in both.
+ it('colors a Codex account without touching a Claude account of the same id', () => {
+ const { host, root } = renderSection([{ ...account, id: 'x1' }], [{ id: 'x1', label: 'codex' }])
+ act(() => {
+ swatch(host, 'codex', '#32d74b').click()
+ })
+ expect(codexColorOf('x1')).toBe('#32d74b')
+ expect(colorOf('x1')).toBeUndefined()
+ root.unmount()
+ })
})
diff --git a/src/renderer/components/settings/sections/AccountsSection.tsx b/src/renderer/components/settings/sections/AccountsSection.tsx
index abb21b48e..ad7ea2057 100644
--- a/src/renderer/components/settings/sections/AccountsSection.tsx
+++ b/src/renderer/components/settings/sections/AccountsSection.tsx
@@ -102,6 +102,60 @@ function applyCodexAccounts(fn: (accs: CodexAccount[]) => CodexAccount[]): void
s.update({ codexAccounts: fn(s.settings.codexAccounts) })
}
+/**
+ * The per-account default node color picker. ONE definition for both managed-account kinds: a
+ * Claude and a Codex account carry the same optional `color` and feed the same `agentAccountColor`
+ * read at node creation, so two copies of these swatches could only drift. `label` names the group
+ * for assistive tech (and for the tests) — account labels are user-typed, so it is the only handle
+ * a row reliably has.
+ */
+function AccountColorSwatches({
+ label,
+ color,
+ onPick
+}: {
+ label: string
+ color?: string
+ onPick: (color?: string) => void
+}): React.JSX.Element {
+ return (
+ <div
+ role="group"
+ aria-label={`Default node color for ${label}`}
+ className="flex flex-wrap items-center gap-2 pt-1"
+ >
+ <span className="text-[12px] text-muted">Node color</span>
+ <button
+ type="button"
+ aria-label="Default"
+ aria-pressed={!color}
+ title="Use the agent's own color"
+ onClick={() => onPick(undefined)}
+ className={cn(
+ 'flex size-5 items-center justify-center rounded-full border-2 text-[11px] text-muted',
+ color ? 'border-transparent bg-fill-weak' : 'border-text bg-fill-weak'
+ )}
+ >
+ ✕
+ </button>
+ {NODE_COLORS.map((c) => (
+ <button
+ key={c}
+ type="button"
+ aria-label={c}
+ aria-pressed={color === c}
+ onClick={() => onPick(c)}
+ style={{ background: c }}
+ className={cn(
+ 'size-5 rounded-full border-2',
+ color === c ? 'border-text' : 'border-transparent'
+ )}
+ />
+ ))}
+ </div>
+ )
+}
+
/** Counts nodes bound to an account across every project's SERIALIZED nodes. The active
* project's live React Flow edits since the last commit aren't reflected here, so the count
* can be slightly stale for the active canvas — acceptable for a confirmation warning. */
@@ -224,6 +278,9 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.
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)))
+
// 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.
@@ -316,19 +373,26 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.
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
- className="w-48"
- placeholder="Codex account label"
- value={account.label}
- onChange={(e) => setCodexLabel(account.id, e.target.value)}
+ <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)}
/>
- <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>
<Button
variant="ghost"
@@ -531,40 +595,11 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.
{account.email && !account.pending ? (
<p className="text-[12px] text-muted">{account.email}</p>
) : null}
- <div
- role="group"
- aria-label={`Default node color for ${account.label}`}
- className="flex flex-wrap items-center gap-2 pt-1"
- >
- <span className="text-[12px] text-muted">Node color</span>
- <button
- type="button"
- aria-label="Default"
- aria-pressed={!account.color}
- title="Use the agent's own color"
- onClick={() => setColor(account.id, undefined)}
- className={cn(
- 'flex size-5 items-center justify-center rounded-full border-2 text-[11px] text-muted',
- account.color ? 'border-transparent bg-fill-weak' : 'border-text bg-fill-weak'
- )}
- >
- ✕
- </button>
- {NODE_COLORS.map((c) => (
- <button
- key={c}
- type="button"
- aria-label={c}
- aria-pressed={account.color === c}
- onClick={() => setColor(account.id, c)}
- style={{ background: c }}
- className={cn(
- 'size-5 rounded-full border-2',
- account.color === c ? 'border-text' : 'border-transparent'
- )}
- />
- ))}
- </div>
+ <AccountColorSwatches
+ label={account.label}
+ color={account.color}
+ onPick={(c) => setColor(account.id, c)}
+ />
</div>
<div className="flex shrink-0 items-center gap-2">
{account.pending
@@ -715,6 +750,8 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.
<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.
</p>
</div>
</SearchableRow>
diff --git a/src/renderer/state/workspace.account-color.test.ts b/src/renderer/state/workspace.account-color.test.ts
index 740714c9c..e31273ded 100644
--- a/src/renderer/state/workspace.account-color.test.ts
+++ b/src/renderer/state/workspace.account-color.test.ts
@@ -1,13 +1,23 @@
import { describe, it, expect, afterEach } from 'vitest'
-import { accountNodeColor, createAgentNode } from './workspace'
+import { accountNodeColor, agentAccountColor, createAgentNode } from './workspace'
import { useSettings } from './settings'
import { agentConfig } from '@shared/agents/config'
+import type { CodexAccount } from '@shared/codex-account'
import { DEFAULT_SETTINGS, type ClaudeAccount } from '@shared/types'
-const withAccounts = (claudeAccounts: ClaudeAccount[]): void => {
- useSettings.setState({ settings: { ...DEFAULT_SETTINGS, claudeAccounts } })
+const withAccounts = (
+ claudeAccounts: ClaudeAccount[],
+ codexAccounts: CodexAccount[] = []
+): void => {
+ useSettings.setState({ settings: { ...DEFAULT_SETTINGS, claudeAccounts, codexAccounts } })
}
+const codexAccount = (id: string, color?: string): CodexAccount => ({
+ id,
+ label: id,
+ ...(color ? { color } : {})
+})
+
const account = (id: string, color?: string): ClaudeAccount => ({
id,
label: id,
@@ -54,6 +64,31 @@ describe('accountNodeColor', () => {
})
})
+describe('agentAccountColor', () => {
+ const claude = [account('a1', '#0a84ff')]
+ const codex = [codexAccount('a1', '#32d74b'), codexAccount('c2')]
+
+ it('answers from the Claude list for a claude node', () => {
+ expect(agentAccountColor('claude', 'a1', { claude, codex })).toBe('#0a84ff')
+ })
+
+ it('answers from the Codex list for a codex node', () => {
+ expect(agentAccountColor('codex', 'a1', { claude, codex })).toBe('#32d74b')
+ })
+
+ // Every other agent takes no managed account at all, so there is no list that could answer for
+ // it — and guessing one would paint a node from a stranger's row.
+ it('is undefined for an agent that takes no managed account', () => {
+ expect(agentAccountColor('gemini', 'a1', { claude, codex })).toBeUndefined()
+ expect(agentAccountColor(undefined, 'a1', { claude, codex })).toBeUndefined()
+ })
+
+ it('is undefined when the owning list has no color for that id', () => {
+ expect(agentAccountColor('codex', 'c2', { claude, codex })).toBeUndefined()
+ expect(agentAccountColor('codex', 'gone', { claude, codex })).toBeUndefined()
+ })
+})
+
describe('createAgentNode — account default color', () => {
it('opens a Claude node in its account’s color instead of the agent’s', () => {
withAccounts([account('a1', '#0a84ff')])
@@ -73,14 +108,29 @@ describe('createAgentNode — account default color', () => {
expect(node.data.color).toBe(AGENT_COLOR('claude'))
})
- // Codex nodes bind managed accounts too (S6), but a CodexAccount carries no `color` — and the two
- // account lists are keyed independently, so a Codex id that happens to match a Claude one must
- // NOT borrow its color. The binding itself still has to land, unchanged by this feature.
- it('never colors a Codex node from the Claude account list, but still stamps its binding', () => {
- withAccounts([account('a1', '#0a84ff')])
- const node = createAgentNode('codex', 0, undefined, undefined, undefined, undefined, 'a1')
+ it('opens a Codex node in its account’s color instead of the agent’s', () => {
+ withAccounts([], [codexAccount('c1', '#32d74b')])
+ const node = createAgentNode('codex', 0, undefined, undefined, undefined, undefined, 'c1')
+ expect(node.data.color).toBe('#32d74b')
+ expect(node.data.accountId).toBe('c1')
+ })
+
+ // The two account lists are keyed INDEPENDENTLY — nothing stops a Codex account and a Claude
+ // account from sharing an id. Each node must read the list that owns its agent, or a colored
+ // Claude account silently repaints a Codex node it has nothing to do with.
+ it('reads the list that owns the agent when both hold the same account id', () => {
+ withAccounts([account('a1', '#0a84ff')], [codexAccount('a1', '#32d74b')])
+ const claude = createAgentNode('claude', 0, undefined, undefined, undefined, undefined, 'a1')
+ const codex = createAgentNode('codex', 0, undefined, undefined, undefined, undefined, 'a1')
+ expect(claude.data.color).toBe('#0a84ff')
+ expect(codex.data.color).toBe('#32d74b')
+ })
+
+ it('keeps the agent’s own color when the Codex account sets none', () => {
+ withAccounts([], [codexAccount('c1')])
+ const node = createAgentNode('codex', 0, undefined, undefined, undefined, undefined, 'c1')
expect(node.data.color).toBe(AGENT_COLOR('codex'))
- expect(node.data.accountId).toBe('a1')
+ expect(node.data.accountId).toBe('c1')
})
it('never colors a node of an agent that takes no account at all', () => {
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index dbc59e331..cdad416ed 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -11,7 +11,7 @@ import type {
import type { AgentId, AgentPermissionMode, BuiltinAgentId } from '@shared/agents/config'
import { agentConfig, supportsSessionIdFlag } from '@shared/agents/config'
import { assembleLaunchCommand } from '@shared/agents/launch'
-import { accountNodeColor } from '@shared/agents/account-color'
+import { agentAccountColor } from '@shared/agents/account-color'
import { agentEnvSnapshot } from '../lib/agentEnv'
import { uuid } from '@renderer/lib/uuid'
import { claudeCliCapsNow } from './permissionMode'
@@ -25,7 +25,7 @@ import { useSettings } from './settings'
// single implementation lives in src/shared and is shared with the relay host + the canvas-sync
// reflector.
export { applyCanvasMutation } from '@shared/canvas-mutations'
-export { accountNodeColor } from '@shared/agents/account-color'
+export { accountNodeColor, agentAccountColor } from '@shared/agents/account-color'
import { sanitizeInboundNode } from '@shared/node-exec'
/** Preset color palette — macOS system colors (dark mode). */
@@ -565,13 +565,15 @@ export function createAgentNode(
const boundAccountId =
accountId && (agentId === 'claude' || agentId === 'codex') ? accountId : undefined
// A managed account's default node color (Settings → Accounts) replaces the agent's brand color,
- // so a second login is recognizable on the canvas at a glance. Claude accounts only: a
- // `CodexAccount` carries no `color` field, so the lookup is not even attempted for one — asking
- // `claudeAccounts` about a Codex id would be a cross-list question with no right answer.
+ // so a second login of either builtin is recognizable on the canvas at a glance. `agentAccountColor`
+ // asks the list that OWNS this agent's accounts — the two are keyed independently, so a Claude
+ // account must never color a Codex node that happens to share its id.
+ const settings = useSettings.getState().settings
const color =
- (agentId === 'claude'
- ? accountNodeColor(boundAccountId, useSettings.getState().settings.claudeAccounts)
- : undefined) ?? agentColor
+ agentAccountColor(agentId, boundAccountId, {
+ claude: settings.claudeAccounts,
+ codex: settings.codexAccounts
+ }) ?? agentColor
// The launch-command override (this project's `.nodeterm/settings.json` first, then Settings →
// Agents → Launch commands — see `agentLaunchOverride`) replaces the bare CLI in the assembled
// command. Threaded into the shared assembler below as `launchCmdOverride` so fresh launch,
diff --git a/src/shared/agents/account-color.ts b/src/shared/agents/account-color.ts
index ce0c21150..961fca3fe 100644
--- a/src/shared/agents/account-color.ts
+++ b/src/shared/agents/account-color.ts
@@ -1,9 +1,20 @@
import type { ClaudeAccount } from '../types'
+import type { CodexAccount } from '../codex-account'
/**
- * The default node color a managed Claude account carries, or undefined for "use the agent's own".
+ * The minimum an account row must be to answer a color question. Structural on purpose: the two
+ * managed-account records (`ClaudeAccount`, `CodexAccount`) are separate types that share nothing
+ * but this, and a helper that named one of them could only be copied for the other.
+ */
+export interface AccountColorSource {
+ id: string
+ color?: string
+}
+
+/**
+ * The default node color a managed account carries, or undefined for "use the agent's own".
*
- * `typeof` first, not just optional chaining: `claudeAccounts` comes out of a hand-editable
+ * `typeof` first, not just optional chaining: the account lists come out of a hand-editable
* settings.json that nothing validates field-by-field on load (`mergeSettings` merges, it does not
* check), so a `"color": 123` arrives here verbatim — and `.trim()` on it throws inside
* `createAgentNode`, i.e. every new node under that account stops opening with nothing pointing
@@ -12,10 +23,37 @@ import type { ClaudeAccount } from '../types'
*/
export function accountNodeColor(
accountId: string | undefined,
- accounts: ClaudeAccount[]
+ accounts: readonly AccountColorSource[]
): string | undefined {
if (!accountId) return undefined
const color = accounts.find((a) => a.id === accountId)?.color
if (typeof color !== 'string') return undefined
return color.trim() || undefined
}
+
+/** The two managed-account lists, as they sit in settings. */
+export interface ManagedAccountLists {
+ claude: readonly ClaudeAccount[]
+ codex: readonly CodexAccount[]
+}
+
+/**
+ * The account color for a node bound to `agentId` — asking the list that OWNS that agent's
+ * accounts, and no other. The two lists are keyed independently (nothing stops a Codex account and
+ * a Claude account from sharing an id), so a node must never be colored from the other list: it
+ * would repaint from a stranger's row. Any other agent takes no managed account at all, so there
+ * is no list that could answer for it and none is guessed.
+ *
+ * This is the ONE definition of which list answers for which agent, shared by the canvas
+ * (`createAgentNode`) and the phone-registered node path in `src/main` — a second copy is exactly
+ * the drift CLAUDE.md warns about.
+ */
+export function agentAccountColor(
+ agentId: string | undefined,
+ accountId: string | undefined,
+ accounts: ManagedAccountLists
+): string | undefined {
+ if (agentId === 'claude') return accountNodeColor(accountId, accounts.claude)
+ if (agentId === 'codex') return accountNodeColor(accountId, accounts.codex)
+ return undefined
+}
diff --git a/src/shared/codex-account.ts b/src/shared/codex-account.ts
index c2cdf0529..17a924cb3 100644
--- a/src/shared/codex-account.ts
+++ b/src/shared/codex-account.ts
@@ -21,6 +21,10 @@ export interface CodexAccount {
pending?: boolean
/** Set only for remote (SSH) accounts: the ssh host this account's home lives on. */
host?: string
+ /** Optional default node color for nodes opened under this account (Settings → Accounts);
+ * unset = the agent's own brand color. Read through `accountNodeColor`, which re-validates it
+ * as a string — settings.json is hand-editable and nothing checks it field-by-field on load. */
+ color?: string
}
/**