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): per-account default node color

Uri Blochc2749f3a9758
diff --git a/src/renderer/components/settings/sections/AccountsSection.color.test.tsx b/src/renderer/components/settings/sections/AccountsSection.color.test.tsx
new file mode 100644
index 000000000..919db0c2e
--- /dev/null
+++ b/src/renderer/components/settings/sections/AccountsSection.color.test.tsx
@@ -0,0 +1,89 @@
+// @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 = ''
+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {
+ usage: { fetch: 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 --git a/src/renderer/components/settings/sections/AccountsSection.tsx b/src/renderer/components/settings/sections/AccountsSection.tsx
index 0401c4fb9..65c58cd65 100644
--- a/src/renderer/components/settings/sections/AccountsSection.tsx
+++ b/src/renderer/components/settings/sections/AccountsSection.tsx
@@ -3,7 +3,7 @@ import type { ClaudeAccount } from '@shared/types'
import { sshHostKey } from '@shared/ssh'
import { useSettings } from '../../../state/settings'
import { useSystemAccount } from '../../../state/systemAccount'
-import { isAccountLoginNode } from '../../../state/workspace'
+import { isAccountLoginNode, NODE_COLORS } from '../../../state/workspace'
import { useProjects } from '../../../state/projects'
import { useSshConn } from '../../../state/sshConn'
import { ConfirmDialog } from '../../ConfirmDialog'
@@ -11,6 +11,7 @@ import { SettingsSection } from '../SettingsSection'
import { SearchableRow } from '../SearchableRow'
import { Button } from '@renderer/ui/Button'
import { Input } from '@renderer/ui/Input'
+import { cn } from '@renderer/ui/cn'
const ROWS = {
accounts: {
@@ -80,6 +81,9 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.
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)))
+
// 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.
const projectIdForHost = (host?: string): string | undefined => {
@@ -282,6 +286,40 @@ 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>
</div>
<div className="flex shrink-0 items-center gap-2">
{account.pending
@@ -377,8 +415,9 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.
<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. Remote accounts live on an SSH host and are
- only offered in that host&apos;s projects.
+ 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&apos;s projects.
</p>
</div>
</SearchableRow>
diff --git a/src/renderer/state/workspace.account-color.test.ts b/src/renderer/state/workspace.account-color.test.ts
new file mode 100644
index 000000000..27352e86a
--- /dev/null
+++ b/src/renderer/state/workspace.account-color.test.ts
@@ -0,0 +1,77 @@
+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()
+ })
+})
+
+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', () => {
+ withAccounts([account('a1', '#0a84ff')])
+ const node = createAgentNode('codex', 0, undefined, undefined, undefined, undefined, 'a1')
+ expect(node.data.color).toBe(AGENT_COLOR('codex'))
+ })
+
+ 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 --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index bc9764be1..2c62095f8 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -371,6 +371,15 @@ export function resolveNewNodeAccount(
return id && accounts.some((a) => a.id === id) ? id : undefined
}
+export function accountNodeColor(
+ accountId: string | undefined,
+ accounts: ClaudeAccount[]
+): string | undefined {
+ if (!accountId) return undefined
+ const color = accounts.find((a) => a.id === accountId)?.color?.trim()
+ return color || undefined
+}
+
/**
* Creates a terminal node that launches the given agent on open. Title, color, and the
* launch command come from the resolved agent config (builtin or custom); the node carries
@@ -387,7 +396,10 @@ export function createAgentNode(
accountId?: string,
permissionMode?: AgentPermissionMode
): CanvasNode {
- const { label, color } = resolveAgent(agentId)
+ const { label, color: agentColor } = resolveAgent(agentId)
+ const boundAccountId = accountId && agentId === 'claude' ? accountId : undefined
+ 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
@@ -463,7 +475,7 @@ export function createAgentNode(
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.
- ...(accountId && agentId === 'claude' ? { accountId } : {}),
+ ...(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 --git a/src/shared/types.ts b/src/shared/types.ts
index 6918c54b6..dec8222da 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -877,6 +877,7 @@ export interface ClaudeAccount {
host?: string
/** True until `claude /login` completes in the account dir and the email is captured. */
pending?: boolean
+ color?: string
createdAt: number
}