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.

Merge branch 'main' into feat/account-default-color

Uri Bloch357500111664
diff --cc CLAUDE.md
index 01b6026a5,624951a68..922f8e98d
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@@ -1235,16 -1264,6 +1264,18 @@@ else, and its context links must keep c
= **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. The value is **re-validated as a string** at the read: `claudeAccounts` comes
++ 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.
- **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 --cc src/renderer/components/settings/sections/AccountsSection.color.test.tsx
index 919db0c2e,000000000..8f78e9b02
mode 100644,000000..100644
--- a/src/renderer/components/settings/sections/AccountsSection.color.test.tsx
+++ b/src/renderer/components/settings/sections/AccountsSection.color.test.tsx
@@@ -1,89 -1,0 +1,94 @@@
+// @vitest-environment jsdom
+import { describe, it, expect, beforeEach, afterEach } from 'vitest'
+import { createRoot, type Root } from 'react-dom/client'
+import { act } from 'react'
+import { AccountsSection } from './AccountsSection'
+import { useSettings } from '../../../state/settings'
+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 } })
+ const host = document.createElement('div')
+ document.body.appendChild(host)
+ const root = createRoot(host)
+ act(() => {
+ root.render(<AccountsSection isActive />)
+ })
+ return { host, root }
+}
+
+function swatch(host: HTMLElement, label: string, name: string): HTMLButtonElement {
+ const group = host.querySelector(`[aria-label="Default node color for ${label}"]`)
+ expect(group).toBeTruthy()
+ const btn = Array.from(group!.querySelectorAll('button')).find(
+ (b) => b.getAttribute('aria-label') === name
+ )
+ expect(btn, `no swatch "${name}"`).toBeTruthy()
+ return btn as HTMLButtonElement
+}
+
+const colorOf = (id: string): string | undefined =>
+ useSettings.getState().settings.claudeAccounts.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
++ // system Codex identity on mount — stubbed so those effects resolve instead of throwing on an
++ // absent bridge member (the throw takes the whole section down with it, colors included).
+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {
- usage: { fetch: async () => null }
++ usage: { fetch: async () => null },
++ ssh: { list: async () => [] },
++ codexAccounts: { systemIdentity: async () => null, identity: async () => null }
+ }
+})
+
+afterEach(() => {
+ useSettings.setState({ settings: DEFAULT_SETTINGS })
+})
+
+describe('AccountsSection — default node color', () => {
+ it('stores the picked color on the account', () => {
+ const { host, root } = renderSection([account])
+ act(() => {
+ swatch(host, 'work', '#0a84ff').click()
+ })
+ expect(colorOf('a1')).toBe('#0a84ff')
+ root.unmount()
+ })
+
+ it('clears the color back to the agent default', () => {
+ const { host, root } = renderSection([{ ...account, color: '#0a84ff' }])
+ act(() => {
+ swatch(host, 'work', 'Default').click()
+ })
+ expect(colorOf('a1')).toBeUndefined()
+ root.unmount()
+ })
+
+ it('marks the picked swatch as selected', () => {
+ const { host, root } = renderSection([{ ...account, color: '#0a84ff' }])
+ expect(swatch(host, 'work', '#0a84ff').getAttribute('aria-pressed')).toBe('true')
+ expect(swatch(host, 'work', '#32d74b').getAttribute('aria-pressed')).toBe('false')
+ expect(swatch(host, 'work', 'Default').getAttribute('aria-pressed')).toBe('false')
+ root.unmount()
+ })
+
+ it('marks Default as selected while no color is set', () => {
+ const { host, root } = renderSection([account])
+ expect(swatch(host, 'work', 'Default').getAttribute('aria-pressed')).toBe('true')
+ root.unmount()
+ })
+
+ it('colors one account without touching the other', () => {
+ const other: ClaudeAccount = { id: 'a2', label: 'personal', createdAt: 0, color: '#ff453a' }
+ const { host, root } = renderSection([account, other])
+ act(() => {
+ swatch(host, 'work', '#0a84ff').click()
+ })
+ expect(colorOf('a1')).toBe('#0a84ff')
+ expect(colorOf('a2')).toBe('#ff453a')
+ root.unmount()
+ })
+})
diff --cc src/renderer/components/settings/sections/AccountsSection.tsx
index 65c58cd65,df8b58615..abb21b48e
--- a/src/renderer/components/settings/sections/AccountsSection.tsx
+++ b/src/renderer/components/settings/sections/AccountsSection.tsx
@@@ -3,9 -4,23 +4,23 @@@ import type { CodexAccount } from '@sha
import { sshHostKey } from '@shared/ssh'
import { useSettings } from '../../../state/settings'
import { useSystemAccount } from '../../../state/systemAccount'
+ import { useSystemCodexAccount } from '../../../state/systemCodexAccount'
-import { isAccountLoginNode } from '../../../state/workspace'
+import { isAccountLoginNode, NODE_COLORS } from '../../../state/workspace'
import { useProjects } from '../../../state/projects'
import { useSshConn } from '../../../state/sshConn'
+ import { useSshServers } from '../../../state/sshServers'
+ import {
+ applyResolvedCodexAccounts,
+ discoverResolvedCodexAccounts
+ } from '../../../state/codexAccountReconcile'
+ import {
+ codexRemoteTargets,
+ groupCodexAccountsByMachine,
+ 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'
import { SearchableRow } from '../SearchableRow'
diff --cc src/renderer/state/workspace.account-color.test.ts
index c63ebec03,000000000..740714c9c
mode 100644,000000..100644
--- a/src/renderer/state/workspace.account-color.test.ts
+++ b/src/renderer/state/workspace.account-color.test.ts
@@@ -1,86 -1,0 +1,97 @@@
+import { describe, it, expect, afterEach } from 'vitest'
+import { accountNodeColor, createAgentNode } from './workspace'
+import { useSettings } from './settings'
+import { agentConfig } from '@shared/agents/config'
+import { DEFAULT_SETTINGS, type ClaudeAccount } from '@shared/types'
+
+const withAccounts = (claudeAccounts: ClaudeAccount[]): void => {
+ useSettings.setState({ settings: { ...DEFAULT_SETTINGS, claudeAccounts } })
+}
+
+const account = (id: string, color?: string): ClaudeAccount => ({
+ id,
+ label: id,
+ createdAt: 0,
+ ...(color ? { color } : {})
+})
+
+const AGENT_COLOR = (id: string): string => agentConfig(id)!.color
+
+afterEach(() => {
+ useSettings.setState({ settings: DEFAULT_SETTINGS })
+})
+
+describe('accountNodeColor', () => {
+ const accounts = [account('a1', '#0a84ff'), account('a2')]
+
+ it('returns the account’s color', () => {
+ expect(accountNodeColor('a1', accounts)).toBe('#0a84ff')
+ })
+
+ it('is undefined when the account has no color set', () => {
+ expect(accountNodeColor('a2', accounts)).toBeUndefined()
+ })
+
+ it('is undefined for an id that no longer resolves — a removed account never colors a node', () => {
+ expect(accountNodeColor('gone', accounts)).toBeUndefined()
+ })
+
+ it('is undefined when no account is bound', () => {
+ expect(accountNodeColor(undefined, accounts)).toBeUndefined()
+ })
+
+ it('is undefined for a blank color — an empty string must not paint a node transparent', () => {
+ expect(accountNodeColor('a3', [account('a3', ' ')])).toBeUndefined()
+ })
+
+ // settings.json is hand-editable and nothing validates `claudeAccounts` field-by-field on load,
+ // so a non-string `color` reaches this helper as-is. `.trim()` on it throws — and this runs
+ // inside createAgentNode, so the throw would stop EVERY new node under that account from
+ // opening, with nothing pointing back at the edited file.
+ it('is undefined for a non-string color — a hand-edited settings.json must not break node creation', () => {
+ const bad = { id: 'a4', label: 'a4', createdAt: 0, color: 123 } as unknown as ClaudeAccount
+ expect(accountNodeColor('a4', [bad])).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')])
+ const node = createAgentNode('claude', 0, undefined, undefined, undefined, undefined, 'a1')
+ expect(node.data.color).toBe('#0a84ff')
+ })
+
+ it('keeps the agent’s own color when the account sets none', () => {
+ withAccounts([account('a1')])
+ const node = createAgentNode('claude', 0, undefined, undefined, undefined, undefined, 'a1')
+ expect(node.data.color).toBe(AGENT_COLOR('claude'))
+ })
+
+ it('keeps the agent’s own color for an account id that no longer resolves', () => {
+ withAccounts([account('a1', '#0a84ff')])
+ const node = createAgentNode('claude', 0, undefined, undefined, undefined, undefined, 'gone')
+ expect(node.data.color).toBe(AGENT_COLOR('claude'))
+ })
+
- it('never colors a non-Claude node — accounts are Claude-only, and so is their color', () => {
++ // 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')
+ expect(node.data.color).toBe(AGENT_COLOR('codex'))
++ expect(node.data.accountId).toBe('a1')
++ })
++
++ it('never colors a node of an agent that takes no account at all', () => {
++ withAccounts([account('a1', '#0a84ff')])
++ const node = createAgentNode('gemini', 0, undefined, undefined, undefined, undefined, 'a1')
++ expect(node.data.color).toBe(AGENT_COLOR('gemini'))
++ expect(node.data.accountId).toBeUndefined()
+ })
+
+ it('leaves an account-less node exactly where it was before the feature', () => {
+ withAccounts([account('a1', '#0a84ff')])
+ expect(createAgentNode('claude', 0).data.color).toBe(AGENT_COLOR('claude'))
+ })
+})
diff --cc src/renderer/state/workspace.ts
index bd828795a,228f2a6da..dbc59e331
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@@ -387,17 -544,22 +546,38 @@@ export function createAgentNode
initialPrompt?: string,
ssh?: Project['ssh'],
accountId?: string,
- permissionMode?: AgentPermissionMode
+ permissionMode?: AgentPermissionMode,
+ projectId?: string,
+ /** Per-node model override for a MODEL_SWITCH_CAPABLE agent (claude/codex/copilot, base-resolved).
+ * Applied through the effective base harness via `withAgentModel` (a no-op for a non-capable
+ * agent, so passing a model for one is harmless — it's simply not appended). Persisted as
+ * `data.agentModel` so cold-restore and later restarts keep the model. Trails `projectId`: every
+ * existing caller passes that ninth argument, so the model is the one that had to move. */
+ model?: string
): CanvasNode {
- const { label, color } = resolveAgent(agentId)
+ const { label, color: agentColor } = resolveAgent(agentId)
- const boundAccountId = accountId && agentId === 'claude' ? accountId : undefined
++ // Managed accounts bind to the builtin Claude and Codex agents (S6) — never to another builtin,
++ // and never to a custom agent even when it inherits one of those bases. A custom agent inheriting
++ // claude/codex is still its own agent; account binding stays with the builtin the account picker
++ // offered it for. The Codex spawn side honours `data.accountId` (resolveCodexSessionScope), the
++ // same field Claude uses. Extracted to one local so the stamped binding below and the account
++ // color resolved from it cannot drift apart.
++ 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.
+ const color =
- accountNodeColor(boundAccountId, useSettings.getState().settings.claudeAccounts) ?? agentColor
- // A per-builtin launch-command override (Settings -> Agents -> Launch commands) replaces the bare
- // CLI in the assembled command. Threaded into the shared assembler below as `launchCmdOverride`
- // so fresh launch, cold-restore resume and in-place restart all pick it up identically. Custom
- // agents already own their `launchCmd`, so the helper returns undefined for them.
- const launchCmdOverride = agentLaunchOverride(agentId)
++ (agentId === 'claude'
++ ? accountNodeColor(boundAccountId, useSettings.getState().settings.claudeAccounts)
++ : undefined) ?? 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,
+ // cold-restore resume and in-place restart all pick it up identically. Custom agents already own
+ // their `launchCmd`, so the global layer returns undefined for them.
+ const launchCmdOverride = agentLaunchOverride(agentId, projectId)
// The session id is DECIDED here rather than learned from a hook later, so this node always has
// something to resume with — see SESSION_ID_CAPABLE for the failure this closes. `uuid()` (not
// crypto.randomUUID) because the Server Edition serves plain HTTP on a LAN, where randomUUID is
@@@ -466,9 -632,12 +650,8 @@@
group: null,
tags: [],
agentId,
- // Accounts are inherently Claude-only — never stamp one onto another agent's node. A custom
- // agent inheriting claude is still its own agent; account binding stays claude-the-builtin.
- // Managed accounts bind to the builtin Claude and Codex agents (S6) — never to another
- // builtin, and never to a custom agent even when it inherits one of those bases. A custom
- // agent inheriting claude/codex is still its own agent; account binding stays with the
- // builtin the account picker offered it for. The Codex spawn side honours `data.accountId`
- // (resolveCodexSessionScope), the same field Claude uses.
- ...(accountId && (agentId === 'claude' || agentId === 'codex') ? { accountId } : {}),
++ // See `boundAccountId` above for why this is claude/codex-only.
+ ...(boundAccountId ? { accountId: boundAccountId } : {}),
// Persisted alongside the node (unlike initialCommand, which is consumed on first open), so
// a cold restore months later still knows which conversation this node owns.
...(mintedSessionId ? { agentSessionId: mintedSessionId } : {}),
diff --cc src/shared/types.ts
index dec8222da,64292c9c8..2282d0135
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@@ -877,7 -1061,6 +1061,10 @@@ export interface ClaudeAccount
host?: string
/** True until `claude /login` completes in the account dir and the email is captured. */
pending?: boolean
++ /** 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 — this file is hand-editable and nothing checks it field-by-field on load. */
+ color?: string
createdAt: number
}