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(projects): registerNode derives agent color/label like createAgentNode

enescd45e7823d26
diff --git a/src/core/project-node-append.test.ts b/src/core/project-node-append.test.ts
index 9742a49f8..840df0c02 100644
--- a/src/core/project-node-append.test.ts
+++ b/src/core/project-node-append.test.ts
@@ -68,6 +68,28 @@ describe('appendProjectNode', () => {
expect(plain.nodes[0].agentId).toBeUndefined()
})
+ it('an agent node adopts the agent color + label default, like createAgentNode', () => {
+ const claude = JSON.parse(appendProjectNode(baseFile([]), { id: 'term-c-1', agentId: 'claude' }, NOW)!)
+ expect(claude.nodes[0].color).toBe('#d97757')
+ expect(claude.nodes[0].title).toBe('Claude Code') // no title sent → agent label, not "Mobile session"
+ const codex = JSON.parse(appendProjectNode(baseFile([]), { id: 'term-c-2', agentId: 'codex' }, NOW)!)
+ expect(codex.nodes[0].color).toBe('#10a37f')
+ // A sent title always wins (the phone's own naming) — only the color is agent-derived.
+ const titled = JSON.parse(
+ appendProjectNode(baseFile([]), { id: 'term-c-3', agentId: 'claude', title: 'Claude Code' }, NOW)!
+ )
+ expect(titled.nodes[0].title).toBe('Claude Code')
+ expect(titled.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')
+ expect(custom.nodes[0].title).toBe('Mobile session')
+ const plain = JSON.parse(appendProjectNode(baseFile([]), { id: 'term-c-2' }, NOW)!)
+ expect(plain.nodes[0].color).toBe('#7aa2f7')
+ })
+
it('round-trips fields it does not understand (future schema, bridges, dino score…)', () => {
const raw = baseFile([sibling], { bridges: [{ id: 'b1' }], dinoHighScore: 42, futureField: { deep: true } })
const f = JSON.parse(appendProjectNode(raw, { id: 'term-bbb-2' }, NOW)!)
diff --git a/src/core/project-node-append.ts b/src/core/project-node-append.ts
index f856fec84..18d2f8e0a 100644
--- a/src/core/project-node-append.ts
+++ b/src/core/project-node-append.ts
@@ -8,6 +8,8 @@
// parse must never be invented or overwritten), a duplicate id (a retry must not churn rev), or
// an unsafe id (it becomes a tmux session name).
+import { agentConfig } from '../shared/agents/config'
+
/** What the phone is allowed to choose; everything else is host-derived. */
export interface RemoteNodeInput {
id: string
@@ -56,14 +58,21 @@ export function appendProjectNode(raw: string, input: RemoteNodeInput, now: Date
y = lowest.y + (typeof lh === 'number' ? lh : 560) + 40
}
+ // 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.
+ const agent = typeof input.agentId === 'string' ? agentConfig(input.agentId) : undefined
const node: Record<string, unknown> = {
id: input.id,
kind: 'terminal',
position: { x, y },
size: { width: 900, height: 560 },
- title: typeof input.title === 'string' ? input.title.slice(0, TITLE_MAX) : 'Mobile session',
+ title:
+ typeof input.title === 'string'
+ ? input.title.slice(0, TITLE_MAX)
+ : (agent?.label ?? 'Mobile session'),
titleAuto: true,
- color: '#7aa2f7',
+ color: agent?.color ?? '#7aa2f7',
group: null,
tags: [],
collapsed: false,