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.

fix(accounts): apply the account color on the phone-registered node path too

Uri Bloch9cee281e9f2d
diff --git a/src/core/project-node-append.test.ts b/src/core/project-node-append.test.ts
index 4db3e744f..2c9080882 100644
--- a/src/core/project-node-append.test.ts
+++ b/src/core/project-node-append.test.ts
@@ -82,6 +82,26 @@ describe('appendProjectNode', () => {
expect(titled.nodes[0].color).toBe('#d97757')
})
+ it('an account-bound node takes the account color the host resolved, over the agent color', () => {
+ const out = JSON.parse(
+ appendProjectNode(
+ baseFile([]),
+ { id: 'term-c-1', agentId: 'claude', accountId: 'acct1' },
+ NOW,
+ '#0a84ff'
+ )!
+ )
+ expect(out.nodes[0].color).toBe('#0a84ff')
+ expect(out.nodes[0].accountId).toBe('acct1')
+ })
+
+ it('keeps the agent color when the host resolved no account color', () => {
+ const out = JSON.parse(
+ appendProjectNode(baseFile([]), { id: 'term-c-1', agentId: 'claude', accountId: 'acct1' }, NOW)!
+ )
+ expect(out.nodes[0].color).toBe('#d97757')
+ })
+
it('a custom/unknown agent and a plain terminal keep the mobile defaults', () => {
const custom = JSON.parse(appendProjectNode(baseFile([]), { id: 'term-c-1', agentId: 'aider' }, NOW)!)
expect(custom.nodes[0].color).toBe('#7aa2f7')
diff --git a/src/core/project-node-append.ts b/src/core/project-node-append.ts
index 9299ee673..3710780c2 100644
--- a/src/core/project-node-append.ts
+++ b/src/core/project-node-append.ts
@@ -50,7 +50,12 @@ function isSshSpec(value: unknown): boolean {
return typeof c.host === 'string' && c.host !== '' && typeof c.user === 'string' && c.user !== ''
}
-export function appendProjectNode(raw: string, input: RemoteNodeInput, now: Date): string | null {
+export function appendProjectNode(
+ raw: string,
+ input: RemoteNodeInput,
+ now: Date,
+ accountColor?: string
+): string | null {
if (!SAFE_NODE_ID.test(input.id)) return null
// Refused, not silently dropped: an account id becomes a config-DIR path segment
// (`claude-accounts/<id>`, `~/.nodeterm/claude-accounts/<id>` on a host), so a bad one must never
@@ -97,8 +102,12 @@ export function appendProjectNode(raw: string, input: RemoteNodeInput, now: Date
}
// An agent node looks exactly like one minted by the canvas (createAgentNode): the agent's
- // label as the starting title and the agent's color — titleAuto then lets the agent's own
- // session name take over, same as desktop. A plain terminal keeps the mobile defaults.
+ // label as the starting title, and the bound account's default color where the host resolved
+ // one, else the agent's — titleAuto then lets the agent's own session name take over, same as
+ // desktop. `accountColor` is host-derived (the phone cannot choose it) and already resolved
+ // through the shared `accountNodeColor`, so a phone-started session under a colored account
+ // lands on the canvas in that color instead of the agent's. A plain terminal keeps the mobile
+ // defaults.
const agent = typeof input.agentId === 'string' ? agentConfig(input.agentId) : undefined
const node: Record<string, unknown> = {
id: input.id,
@@ -110,7 +119,7 @@ export function appendProjectNode(raw: string, input: RemoteNodeInput, now: Date
? input.title.slice(0, TITLE_MAX)
: (agent?.label ?? 'Mobile session'),
titleAuto: true,
- color: agent?.color ?? '#7aa2f7',
+ color: accountColor ?? agent?.color ?? '#7aa2f7',
group: null,
tags: [],
collapsed: false,
diff --git a/src/core/workspace-store.ts b/src/core/workspace-store.ts
index 8f7971156..7e19d60d9 100644
--- a/src/core/workspace-store.ts
+++ b/src/core/workspace-store.ts
@@ -872,13 +872,25 @@ export class WorkspaceStore {
* that read the file first lands last, and the node the phone was told about ("true", card shown)
* never existed. Queued, the append reads what the save just wrote and the save cannot un-write it.
*/
- appendRemoteNode(projectId: string, input: RemoteNodeInput, now = new Date()): Promise<boolean> {
- const run = this.saveChain.then(() => this.appendRemoteNodeNow(projectId, input, now))
+ appendRemoteNode(
+ projectId: string,
+ input: RemoteNodeInput,
+ now = new Date(),
+ accountColor?: string
+ ): Promise<boolean> {
+ const run = this.saveChain.then(() =>
+ this.appendRemoteNodeNow(projectId, input, now, accountColor)
+ )
this.saveChain = run.catch(() => {})
return run
}
- private async appendRemoteNodeNow(projectId: string, input: RemoteNodeInput, now: Date): Promise<boolean> {
+ private async appendRemoteNodeNow(
+ projectId: string,
+ input: RemoteNodeInput,
+ now: Date,
+ accountColor?: string
+ ): Promise<boolean> {
const e = this.index?.entries.find((x) => x.id === projectId && x.cwd)
if (!e?.cwd) return false
const file = projectFilePath(e.cwd)
@@ -888,7 +900,7 @@ export class WorkspaceStore {
} catch {
return false
}
- const updated = appendProjectNode(raw, input, now)
+ const updated = appendProjectNode(raw, input, now, accountColor)
if (updated === null) return false
try {
await writeAtomic(file, updated)
diff --git a/src/main/index.ts b/src/main/index.ts
index 0cee368be..38f33799f 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -122,6 +122,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 { grokSessionDir, grokSessionsDir } from '../core/agents/grok-paths'
import { forgetGrokSession, rememberGrokSessionDir } from '../core/grok-session'
import {
@@ -2411,7 +2412,15 @@ app.whenReady().then(async () => {
registerNode: (
projectId: string,
node: { id: string; title?: string; agentId?: string; accountId?: string }
- ) => workspaceStore.appendRemoteNode(projectId, node),
+ ) =>
+ workspaceStore.appendRemoteNode(
+ projectId,
+ 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 ?? [])
+ ),
// 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
// to have focused (that gap read as "cwd is outside the shared project roots" on the phone).
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index 2c62095f8..bd828795a 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -3,6 +3,7 @@ import type { CanvasMutation, CanvasNodeState, ClaudeAccount, NodeKind, PendingL
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 { agentEnvSnapshot } from '../lib/agentEnv'
import { uuid } from '@renderer/lib/uuid'
import { claudeCliCapsNow } from './permissionMode'
@@ -14,6 +15,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'
import { sanitizeInboundNode } from '@shared/node-exec'
/** Preset color palette — macOS system colors (dark mode). */
@@ -371,15 +373,6 @@ 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
diff --git a/src/shared/agents/account-color.ts b/src/shared/agents/account-color.ts
new file mode 100644
index 000000000..07eddcc58
--- /dev/null
+++ b/src/shared/agents/account-color.ts
@@ -0,0 +1,10 @@
+import type { ClaudeAccount } from '../types'
+
+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
+}