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(chat): chat node factory + canvas/dock/palette integration

enes1cc7a3e3c169
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 7bf9c09dd..81188f6bf 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -21,6 +21,7 @@ import { GroupNode, setWorktreeActionHandler } from '../nodes/GroupNode'
import { LazyEditorNode, LazyDiffNode } from '../nodes/lazyMonacoNodes'
import { DinoNode } from '../nodes/DinoNode'
import BrowserNode from '../nodes/BrowserNode'
+import ChatNode from '../nodes/ChatNode'
import { normalizeAddress } from '../nodes/browserUrl'
import VideoNode from '../nodes/VideoNode'
import WebNode from '../nodes/WebNode'
@@ -37,6 +38,7 @@ import {
IconFit,
IconGrid,
IconGroup,
+ IconChat,
IconDino,
IconJump,
IconMarkdown,
@@ -77,6 +79,7 @@ import { prepareQuickOpenFiles, type QuickOpenIndexedFile } from '../lib/quickOp
import { opensInEditor } from '../lib/openTarget'
import { useProjects } from '../state/projects'
import { useAgentStatus } from '../state/agentStatus'
+import { useChatSessions } from '../state/chatSessions'
import { useAgentNodes } from '../state/agentNodes'
import { SubagentNode } from '../nodes/SubagentNode'
import { LoopNode } from '../nodes/LoopNode'
@@ -115,6 +118,7 @@ import {
COLLAPSED_HEIGHT,
createAgentNode,
createBrowserNode,
+ createChatNode,
createDinoNode,
createDiffNode,
createEditorNode,
@@ -347,7 +351,8 @@ export function Canvas() {
dino: withNodeBoundary(DinoNode),
video: withNodeBoundary(VideoNode),
web: withNodeBoundary(WebNode),
- browser: withNodeBoundary(BrowserNode)
+ browser: withNodeBoundary(BrowserNode),
+ chat: withNodeBoundary(ChatNode)
}),
[]
)
@@ -1280,6 +1285,15 @@ export function Canvas() {
[setNodes, markDirty, viewCenter]
)
+ const addChatNode = useCallback(
+ (center?: { x: number; y: number }) => {
+ const cwd = useProjects.getState().getProject(activeProjectId)?.cwd
+ setNodes((ns) => [...ns, createChatNode(ns.length, cwd, center ?? viewCenter())])
+ markDirty()
+ },
+ [setNodes, markDirty, activeProjectId, viewCenter]
+ )
+
const addAgentNode = useCallback(
(agentId: AgentId, center?: { x: number; y: number }, groupId?: string) => {
const project = useProjects.getState().getProject(activeProjectId)
@@ -1360,6 +1374,13 @@ export function Canvas() {
if (!set.has(n.id)) return
// Remote terminals have no local persistent session — only destroy local ones.
if (n.type === 'terminal' && !n.data.remote) transport.destroy(n.id)
+ // Chat nodes: permanently kill the SDK driver + drop the live chat state. The driver
+ // lives across project switches (only permanent delete kills it), so this belongs here,
+ // not in node unmount.
+ if (n.type === 'chat') {
+ window.nodeTerminal.chat.dispose(n.id)
+ useChatSessions.getState().drop(n.id)
+ }
// Permanent deletion → drop the node's persisted agent status (sessionId/session/
// unread). Node unmount no longer does this, so deletion must.
useAgentStatus.getState().remove(n.id)
@@ -1993,6 +2014,7 @@ export function Canvas() {
onClick: () => addAgentNode(c.id, at)
})
),
+ { label: 'New chat', icon: <IconChat />, onClick: () => addChatNode(at) },
{ label: 'New browser', icon: <IconRemote />, onClick: () => addBrowser(at) },
{ label: 'New sticky note', icon: <IconNote />, onClick: () => addSticky(at) },
{ label: 'New dino game', icon: <IconDino />, onClick: () => addDino(at) },
@@ -2012,6 +2034,7 @@ export function Canvas() {
screenToFlowPosition,
addTerminal,
addAgentNode,
+ addChatNode,
addSticky,
addDino,
addBrowser,
@@ -2451,6 +2474,10 @@ export function Canvas() {
deleteNodes([id])
} else {
transport.destroy(id)
+ // Chat nodes in an inactive project keep their driver running across the switch;
+ // dispose is a no-op for non-chat ids, so call it unconditionally like destroy.
+ window.nodeTerminal.chat.dispose(id)
+ useChatSessions.getState().drop(id)
useAgentStatus.getState().remove(id)
useProjects.getState().removeNode(projectId, id)
void writeDisk()
@@ -2925,6 +2952,7 @@ export function Canvas() {
run: () => addAgentNode(c.id)
})
),
+ { id: 'new-chat', label: 'New chat', icon: <IconChat />, run: () => addChatNode() },
{ id: 'new-sticky', label: 'New sticky note', icon: <IconNote />, run: () => addSticky() },
{ id: 'new-dino', label: 'New dino game', icon: <IconDino />, run: () => addDino() },
{ id: 'open-file', label: 'Open file…', icon: <IconEditor />, run: () => void openFileDialog() },
@@ -3000,6 +3028,7 @@ export function Canvas() {
}, [
addTerminal,
addAgentNode,
+ addChatNode,
addSticky,
addDino,
addWebView,
@@ -3406,6 +3435,7 @@ export function Canvas() {
onAddSticky={addSticky}
onAddDino={addDino}
onAddAgent={(aid) => addAgentNode(aid)}
+ onAddChat={() => addChatNode()}
onOpenFile={() => void openFileDialog()}
onAddRemote={() => openRemotePicker({ x: window.innerWidth / 2, y: window.innerHeight / 2 })}
onConnectRemote={() => void connectRemote()}
diff --git a/src/renderer/components/Dock.tsx b/src/renderer/components/Dock.tsx
index 1a5b8c24c..6ddaf15dc 100644
--- a/src/renderer/components/Dock.tsx
+++ b/src/renderer/components/Dock.tsx
@@ -12,6 +12,7 @@ interface DockProps {
onAddSticky: () => void
onAddDino: () => void
onAddAgent: (agentId: AgentId) => void
+ onAddChat: () => void
onOpenFile: () => void
onAddRemote: () => void
onConnectRemote: () => void
@@ -36,6 +37,7 @@ export function Dock({
onAddSticky,
onAddDino,
onAddAgent,
+ onAddChat,
onOpenFile,
onAddRemote,
onConnectRemote,
@@ -84,6 +86,10 @@ export function Dock({
<span>{c.label}</span>
</button>
))}
+ <button onClick={pick(onAddChat)}>
+ <ChatIcon />
+ <span>Chat</span>
+ </button>
<button onClick={pick(onAddSticky)}>
<NoteIcon />
<span>Sticky Note</span>
@@ -226,6 +232,14 @@ function DinoIcon() {
</svg>
)
}
+function ChatIcon() {
+ return (
+ <svg {...S}>
+ <path d="M4 5h16v11H9l-4 3v-3H4z" />
+ <path d="M8 10h8M8 13h5" />
+ </svg>
+ )
+}
function EditorIcon() {
return (
<svg {...S}>
diff --git a/src/renderer/components/icons.tsx b/src/renderer/components/icons.tsx
index 29da6625e..6e7ac775a 100644
--- a/src/renderer/components/icons.tsx
+++ b/src/renderer/components/icons.tsx
@@ -37,6 +37,13 @@ export const IconDino = () => (
</svg>
)
+export const IconChat = () => (
+ <svg {...S}>
+ <path d="M4 5h16v11H9l-4 3v-3H4z" />
+ <path d="M8 10h8M8 13h5" />
+ </svg>
+)
+
export const IconPlus = () => (
<svg {...S}>
<path d="M12 5v14M5 12h14" />
diff --git a/src/renderer/state/workspace.chat.test.ts b/src/renderer/state/workspace.chat.test.ts
new file mode 100644
index 000000000..5e3d6eaa9
--- /dev/null
+++ b/src/renderer/state/workspace.chat.test.ts
@@ -0,0 +1,29 @@
+import { describe, it, expect } from 'vitest'
+import { createChatNode, nodeStatesToFlow, flowToNodeStates } from './workspace'
+
+describe('chat node', () => {
+ it('createChatNode carries kind chat + cwd + optional session id', () => {
+ const n = createChatNode(0, '/work', undefined, { chatSessionId: 'sess-1' })
+ expect(n.type).toBe('chat')
+ expect(n.data.cwd).toBe('/work')
+ expect(n.data.chatSessionId).toBe('sess-1')
+ })
+
+ it('round-trips chat kind + chatSessionId through both serializers (resume survives restart)', () => {
+ const round = nodeStatesToFlow(
+ flowToNodeStates([createChatNode(0, '/work', undefined, { chatSessionId: 'sess-1' })])
+ )
+ const c = round.find((n) => n.type === 'chat')!
+ expect(c.type).toBe('chat')
+ expect(c.data.cwd).toBe('/work')
+ expect(c.data.chatSessionId).toBe('sess-1')
+ })
+
+ it('does NOT persist forkFrom (one-shot bootstrap, like initialCommand)', () => {
+ const round = nodeStatesToFlow(
+ flowToNodeStates([createChatNode(0, '/work', undefined, { forkFrom: 'source-sess' })])
+ )
+ const c = round.find((n) => n.type === 'chat')!
+ expect(c.data.forkFrom).toBeUndefined()
+ })
+})
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index 161e0c656..41546355d 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -24,6 +24,7 @@ const DINO_SIZE = { width: 600, height: 200 }
const VIDEO_SIZE = { width: 640, height: 420 }
const WEB_SIZE = { width: 720, height: 520 }
const BROWSER_SIZE = { width: 800, height: 560 }
+const CHAT_SIZE = { width: 420, height: 380 }
/** Height of a node when collapsed (header only). */
export const COLLAPSED_HEIGHT = 40
@@ -87,6 +88,16 @@ export interface NodeData {
* SSH-project editor still routes to the remote fs after reopen.
*/
sshFs?: boolean
+ /**
+ * chat-only: the SDK session id of this chat node's conversation. Persisted so a relaunch
+ * resumes the on-disk transcript (the SDK process dies with the app).
+ */
+ chatSessionId?: string
+ /**
+ * chat-only: source session id to fork from on first boot (Task 10). One-shot bootstrap —
+ * NOT persisted (like initialCommand); once the node's own chatSessionId arrives it's ignored.
+ */
+ forkFrom?: string
[key: string]: unknown
}
@@ -389,6 +400,31 @@ export function createBrowserNode(
}
}
+/** Creates an SDK-driven chat node (Claude conversation without a terminal). */
+export function createChatNode(
+ index: number,
+ cwd?: string,
+ center?: { x: number; y: number },
+ init?: { chatSessionId?: string; forkFrom?: string }
+): CanvasNode {
+ return {
+ id: nextId('chat'),
+ type: 'chat',
+ position: placeAt(center, index, CHAT_SIZE.width, CHAT_SIZE.height),
+ width: CHAT_SIZE.width,
+ height: CHAT_SIZE.height,
+ style: { width: CHAT_SIZE.width, height: CHAT_SIZE.height },
+ data: {
+ title: 'Chat',
+ color: '#d97757', // clay, matches agent nodes
+ group: null,
+ ...(cwd ? { cwd } : {}),
+ ...(init?.chatSessionId ? { chatSessionId: init.chatSessionId } : {}),
+ ...(init?.forkFrom ? { forkFrom: init.forkFrom } : {})
+ }
+ }
+}
+
/** Creates a diff editor node for a changed file (relative path + repo cwd). */
export function createDiffNode(
index: number,
@@ -717,7 +753,8 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {
ssh: n.ssh,
sshRemoteTmux: n.sshRemoteTmux,
sshFs: n.sshFs,
- worktree: n.worktree
+ worktree: n.worktree,
+ chatSessionId: n.chatSessionId
}
}
})
@@ -742,7 +779,9 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {
? WEB_SIZE
: kind === 'dino'
? DINO_SIZE
- : TERMINAL_SIZE
+ : kind === 'chat'
+ ? CHAT_SIZE
+ : TERMINAL_SIZE
return nodes
// Remote terminals are transient to a live relay connection — never persist them (their
// connectionId is dead after a restart, and they'd otherwise reattach to a stray local tmux).
@@ -780,7 +819,8 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {
ssh: n.data.ssh,
sshRemoteTmux: n.data.sshRemoteTmux,
sshFs: n.data.sshFs,
- worktree: n.data.worktree
+ worktree: n.data.worktree,
+ chatSessionId: n.data.chatSessionId as string | undefined
}
})
}
diff --git a/src/shared/types.ts b/src/shared/types.ts
index e59dd807d..77bbbda45 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -87,6 +87,8 @@ export interface CanvasNodeState {
commitOid?: string
/** group-only: when bound, the git worktree this group works in. */
worktree?: GroupWorktree
+ /** chat-only: SDK session id of this chat node's conversation, persisted so a relaunch resumes it. */
+ chatSessionId?: string
}
/**