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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(chat)!: remove chat driver, IPC surface and SDK types
enes27c7700fa3f9
diff --git a/src/core/chat-driver.ts b/src/core/chat-driver.tsdeleted file mode 100644index b4eddd61d..000000000--- a/src/core/chat-driver.ts+++ /dev/null@@ -1,233 +0,0 @@-// One long-lived Claude Agent SDK query per chat node (streaming input mode). The renderer-// talks to this over the narrow chat:* IPC surface; SDK messages are reduced by-// chat-events.ts and pushed on chat:event:<nodeId>. Continuity is resume-based: the-// process dies with the app; the node's persisted chatSessionId resumes the transcript.-import { IPC } from '../shared/ipc'-import type { ChatEvent, ChatImageAttachment, ChatPermissionDecision } from '../shared/types'-import type { NormalizedAgentEvent } from '../shared/agents/normalize'-import { sdkMessageToEvents } from './chat-events'-import { ChatInputQueue, createPushIterable } from './chat-queue'-import { resolveTranscriptPath } from './transcript-reader'-import { claudeConfigDirFor } from './claude-config-dir'-import { recordAgentEvent } from './agent-status-mirror'-import { AUTH_ENV_STRIP } from './claude-accounts-core'--interface PendingPermission { resolve: (d: ChatPermissionDecision) => void }--interface ChatSession {- nodeId: string- cwd?: string- sessionId?: string- // Managed account this chat runs on (its CLAUDE_CONFIG_DIR); undefined = default login.- accountId?: string- working: boolean- input: ReturnType<typeof createPushIterable<unknown>>- queue: ChatInputQueue- pending: Map<string, PendingPermission>- allowedForSession: Set<string>- interrupt?: () => Promise<void>- // Set by interrupt() before it fires the SDK interrupt, so the resulting turn-done is treated- // as a user Stop: it must NOT auto-flush the queue and its done status carries interrupted:true- // (so Canvas skips the completion notification). Cleared when that turn-done is handled.- interruptedByUser: boolean- disposed: boolean-}--type SendToMain = (channel: string, payload: unknown) => void--// Minimal structural view of the send target. The codebase resolves the live window at send-// time via getMainWindow() (returns MainWindowLike, never a raw BrowserWindow — capturing one-// leaves a dead webContents after a macOS close→dock-reopen), so we accept anything that can-// send on its webContents rather than the full BrowserWindow type.-type WindowLike = { webContents: { send(channel: string, ...args: unknown[]): void } }--export class ChatDriver {- private sessions = new Map<string, ChatSession>()- constructor(- private getWindow: () => WindowLike | null,- private sendToMain: SendToMain- ) {}-- private emit(nodeId: string, event: ChatEvent): void {- this.getWindow()?.webContents.send(IPC.chatEvent(nodeId), event)- }-- private status(- s: ChatSession,- state: 'working' | 'blocked' | 'done',- newTurn = false,- interrupted = false- ): void {- const ev: NormalizedAgentEvent = {- nodeId: s.nodeId, agentId: 'claude', kind: 'state', state, newTurn,- sessionId: s.sessionId, ...(interrupted ? { interrupted: true } : {})- }- this.sendToMain(IPC.agentStatus, ev)- recordAgentEvent(ev)- }-- async ensure(- nodeId: string,- opts: { cwd?: string; sessionId?: string; fork?: boolean; accountId?: string }- ): Promise<{ ok: boolean; error?: string }> {- if (this.sessions.has(nodeId)) return { ok: true }- // Resume validation: a sessionId whose transcript is gone would silently start a- // fresh session with mismatched history — surface it instead. Look in the account dir.- let resume = opts.sessionId- if (resume && !(await resolveTranscriptPath(resume, opts.accountId))) {- this.emit(nodeId, { kind: 'error', message: 'Previous session transcript not found — starting fresh.' })- resume = undefined- }- const s: ChatSession = {- nodeId, cwd: opts.cwd, sessionId: resume, accountId: opts.accountId, working: false,- input: createPushIterable<unknown>(), queue: new ChatInputQueue(),- pending: new Map(), allowedForSession: new Set(),- interruptedByUser: false, disposed: false- }- this.sessions.set(nodeId, s)- void this.run(s, resume, opts.fork === true).catch((err) => {- this.emit(nodeId, { kind: 'error', message: String(err?.message ?? err), fatal: true })- // Tear down like dispose(): resolve/clear any pending permission cards and end input, so a- // fatal crash doesn't leave a stale permission prompt or "working" badge before Reconnect.- this.teardown(s)- this.sessions.delete(nodeId)- })- return { ok: true }- }-- private async run(s: ChatSession, resume: string | undefined, fork: boolean): Promise<void> {- // Task-1 spike result: the SDK runs under Electron main with no env/executable- // overrides (ELECTRON_RUN_AS_NODE inheritance is harmless), so no special spawn handling.- const { query } = await import('@anthropic-ai/claude-agent-sdk')- const q = query({- prompt: s.input.iterable as AsyncIterable<never>,- options: {- cwd: s.cwd,- ...(resume ? { resume } : {}),- ...(fork ? { forkSession: true } : {}),- // Managed account: the SDK's claude subprocess inherits this env, so credentials- // AND the transcript live in the account dir. AUTH_ENV_STRIP mirrors the PTY path.- // Account-less sessions get no env option at all (inherit the default login untouched).- ...(s.accountId- ? {- env: (() => {- const env: NodeJS.ProcessEnv = { ...process.env, CLAUDE_CONFIG_DIR: claudeConfigDirFor(s.accountId) }- for (const k of AUTH_ENV_STRIP) delete env[k]- return env as Record<string, string>- })()- }- : {}),- includePartialMessages: true,- permissionMode: 'default',- canUseTool: async (toolName: string, input: Record<string, unknown>, { toolUseID }: { toolUseID: string }) => {- if (s.allowedForSession.has(toolName)) return { behavior: 'allow' as const, updatedInput: input }- const requestId = toolUseID- this.emit(s.nodeId, { kind: 'permission', requestId, toolName, input })- this.status(s, 'blocked')- const decision = await new Promise<ChatPermissionDecision>((resolve) => {- s.pending.set(requestId, { resolve })- })- s.pending.delete(requestId)- this.emit(s.nodeId, { kind: 'permission-done', requestId })- this.status(s, 'working')- if (decision.behavior === 'allow') {- if (decision.alwaysSession) s.allowedForSession.add(toolName)- return { behavior: 'allow' as const, updatedInput: input }- }- return { behavior: 'deny' as const, message: 'User denied in nodeterm chat.' }- }- }- })- s.interrupt = () => q.interrupt()- for await (const msg of q) {- if (s.disposed) break- for (const event of sdkMessageToEvents(msg as never)) {- if (event.kind === 'session') s.sessionId = event.sessionId- this.emit(s.nodeId, event)- if (event.kind === 'turn-done') {- s.working = false- // A user Stop (interrupt) ends the turn too — but the queue must stay put (items are- // individually deletable) and Canvas must skip the "finished" notification.- const interrupted = s.interruptedByUser- s.interruptedByUser = false- this.status(s, 'done', false, interrupted)- if (!interrupted) this.flushQueue(s)- }- }- }- }-- private pushUser(s: ChatSession, text: string, images?: ChatImageAttachment[]): void {- const content: unknown = images?.length- ? [- ...images.map((i) => ({ type: 'image', source: { type: 'base64', media_type: i.mediaType, data: i.data } })),- { type: 'text', text }- ]- : text- s.input.push({ type: 'user', message: { role: 'user', content } })- s.working = true- this.status(s, 'working', true)- }-- private flushQueue(s: ChatSession): void {- const next = s.queue.takeNext()- this.emit(s.nodeId, { kind: 'queue', items: s.queue.items() })- if (next) this.pushUser(s, next.text)- }-- send(nodeId: string, text: string, images?: ChatImageAttachment[]): void {- const s = this.sessions.get(nodeId)- if (!s) return- if (s.working) {- s.queue.add(text) // images only send immediately in v1; queued items are text- this.emit(nodeId, { kind: 'queue', items: s.queue.items() })- return- }- this.pushUser(s, text, images)- }-- interrupt(nodeId: string): void {- const s = this.sessions.get(nodeId)- if (!s) return- // Flag the turn as user-stopped BEFORE firing the SDK interrupt, so the turn-done it- // triggers is handled as a Stop (no auto-flush, interrupted status).- s.interruptedByUser = true- void s.interrupt?.().catch(() => {})- }-- permissionReply(nodeId: string, requestId: string, decision: ChatPermissionDecision): void {- this.sessions.get(nodeId)?.pending.get(requestId)?.resolve(decision)- }-- removeQueued(nodeId: string, queueId: string): void {- const s = this.sessions.get(nodeId)- if (!s) return- s.queue.remove(queueId)- this.emit(nodeId, { kind: 'queue', items: s.queue.items() })- }-- // Shared teardown for both dispose() and the fatal catch path: deny + clear every pending- // permission (resolving the awaiting canUseTool promise AND clearing its renderer card via- // permission-done), then end the input stream so the SDK query settles.- private teardown(s: ChatSession): void {- for (const [requestId, p] of s.pending) {- p.resolve({ behavior: 'deny' })- this.emit(s.nodeId, { kind: 'permission-done', requestId })- }- s.pending.clear()- s.input.end()- }-- dispose(nodeId: string): void {- const s = this.sessions.get(nodeId)- if (!s) return- s.disposed = true- this.teardown(s)- void s.interrupt?.().catch(() => {})- this.sessions.delete(nodeId)- }-- disposeAll(): void {- for (const id of [...this.sessions.keys()]) this.dispose(id)- }-}diff --git a/src/core/chat-events.test.ts b/src/core/chat-events.test.tsdeleted file mode 100644index 71fef1fe3..000000000--- a/src/core/chat-events.test.ts+++ /dev/null@@ -1,78 +0,0 @@-import { describe, expect, it } from 'vitest'-import { sdkMessageToEvents, summarizeToolInput } from './chat-events'--describe('sdkMessageToEvents', () => {- it('maps init system message to session event', () => {- const ev = sdkMessageToEvents({- type: 'system', subtype: 'init', session_id: 'abc', slash_commands: ['/compact']- })- expect(ev).toEqual([{ kind: 'session', sessionId: 'abc', slashCommands: ['/compact'] }])- })-- it('maps text and thinking deltas', () => {- expect(sdkMessageToEvents({- type: 'stream_event', event: { type: 'content_block_delta', delta: { type: 'text_delta', text: 'he' } }- })).toEqual([{ kind: 'delta', block: 'text', text: 'he' }])- expect(sdkMessageToEvents({- type: 'stream_event', event: { type: 'content_block_delta', delta: { type: 'thinking_delta', thinking: 'hm' } }- })).toEqual([{ kind: 'delta', block: 'thinking', text: 'hm' }])- })-- it('maps a completed assistant message to message + tool events', () => {- const ev = sdkMessageToEvents({- type: 'assistant',- message: {- role: 'assistant',- content: [- { type: 'text', text: 'done' },- { type: 'tool_use', id: 't1', name: 'Edit', input: { file_path: '/a/b.ts', old_string: 'x\ny', new_string: 'z' } }- ]- }- })- expect(ev[0]).toEqual({ kind: 'message', msg: { role: 'assistant', parts: [{ kind: 'text', text: 'done' }] } })- expect(ev[1]).toMatchObject({ kind: 'tool', toolUseId: 't1', name: 'Edit', summary: { filePath: '/a/b.ts' } })- })-- it('maps tool results from user messages', () => {- const ev = sdkMessageToEvents({- type: 'user',- message: { role: 'user', content: [{ type: 'tool_result', tool_use_id: 't1', content: 'ok' }] }- })- expect(ev).toEqual([{ kind: 'tool-result', toolUseId: 't1', result: 'ok' }])- })-- it('maps result to turn-done with cost and usage', () => {- const ev = sdkMessageToEvents({- type: 'result', subtype: 'success', total_cost_usd: 0.12,- usage: { input_tokens: 10, output_tokens: 20 }- })- expect(ev).toEqual([{ kind: 'turn-done', costUsd: 0.12, usage: { inputTokens: 10, outputTokens: 20 } }])- })-- it('maps error result subtypes to turn-done + error', () => {- const ev = sdkMessageToEvents({ type: 'result', subtype: 'error_max_turns', total_cost_usd: 0.01 })- expect(ev[0].kind).toBe('turn-done')- expect(ev[1]).toMatchObject({ kind: 'error', fatal: false })- })-- it('ignores unknown messages', () => {- expect(sdkMessageToEvents({ type: 'whatever' })).toEqual([])- })-})--describe('summarizeToolInput', () => {- it('summarizes Edit with line counts from old/new strings', () => {- const s = summarizeToolInput('Edit', { file_path: '/x.ts', old_string: 'a\nb', new_string: 'c' })- expect(s.summary).toEqual({ filePath: '/x.ts', added: 1, removed: 2 })- expect(s.arg).toBe('/x.ts')- })- it('summarizes Write as all-added', () => {- const s = summarizeToolInput('Write', { file_path: '/x.ts', content: 'a\nb\nc' })- expect(s.summary).toEqual({ filePath: '/x.ts', added: 3, removed: 0 })- })- it('falls back to a compact arg for other tools', () => {- const s = summarizeToolInput('Bash', { command: 'ls -la' })- expect(s.arg).toBe('ls -la')- expect(s.summary).toBeUndefined()- })-})diff --git a/src/core/chat-events.ts b/src/core/chat-events.tsdeleted file mode 100644index ad9d91de0..000000000--- a/src/core/chat-events.ts+++ /dev/null@@ -1,92 +0,0 @@-// Pure reducer: one SDK message (structurally typed — no SDK import, so tests use plain-// JSON fixtures) → zero or more ChatEvents for the renderer. Owned by chat-driver.ts.-import type { ChatEvent, ChatMessage, ChatPart, ChatToolSummary } from '../shared/types'--/** The subset of SDK message shapes we consume, typed structurally. */-export interface SdkMessageLike {- type?: string- subtype?: string- session_id?: string- slash_commands?: string[]- total_cost_usd?: number- usage?: { input_tokens?: number; output_tokens?: number }- event?: { type?: string; delta?: { type?: string; text?: string; thinking?: string } }- message?: { role?: string; content?: unknown }-}--const lines = (s: unknown): number => (typeof s === 'string' && s.length ? s.split('\n').length : 0)--/** Compact one-line arg + optional file/line summary for a tool_use block. */-export function summarizeToolInput(- name: string,- input: Record<string, unknown>-): { arg: string; summary?: ChatToolSummary } {- const filePath = typeof input.file_path === 'string' ? input.file_path : undefined- if ((name === 'Edit' || name === 'MultiEdit') && filePath) {- return { arg: filePath, summary: { filePath, added: lines(input.new_string), removed: lines(input.old_string) } }- }- if (name === 'Write' && filePath) {- return { arg: filePath, summary: { filePath, added: lines(input.content), removed: 0 } }- }- const first = input.command ?? input.file_path ?? input.pattern ?? input.url ?? input.prompt- const arg = typeof first === 'string' ? first : JSON.stringify(input ?? {})- return { arg: arg.length > 200 ? arg.slice(0, 200) + '…' : arg }-}--const toolResultText = (content: unknown): string => {- if (typeof content === 'string') return content- if (Array.isArray(content))- return content- .map((b) => (b && typeof b === 'object' && 'text' in b ? String((b as { text: unknown }).text) : ''))- .join('\n')- return ''-}--export function sdkMessageToEvents(msg: SdkMessageLike): ChatEvent[] {- if (msg.type === 'system' && msg.subtype === 'init' && msg.session_id) {- return [{ kind: 'session', sessionId: msg.session_id, slashCommands: msg.slash_commands ?? [] }]- }- if (msg.type === 'stream_event') {- const d = msg.event?.delta- if (msg.event?.type === 'content_block_delta' && d) {- if (d.type === 'text_delta' && d.text) return [{ kind: 'delta', block: 'text', text: d.text }]- if (d.type === 'thinking_delta' && d.thinking) return [{ kind: 'delta', block: 'thinking', text: d.thinking }]- }- return []- }- if (msg.type === 'assistant' && Array.isArray((msg.message as { content?: unknown })?.content)) {- const out: ChatEvent[] = []- const parts: ChatPart[] = []- for (const block of (msg.message as { content: Array<Record<string, unknown>> }).content) {- if (block.type === 'text' && typeof block.text === 'string') parts.push({ kind: 'text', text: block.text })- else if (block.type === 'thinking' && typeof block.thinking === 'string')- parts.push({ kind: 'thinking', text: block.thinking })- else if (block.type === 'tool_use' && typeof block.id === 'string' && typeof block.name === 'string') {- const { arg, summary } = summarizeToolInput(block.name, (block.input as Record<string, unknown>) ?? {})- out.push({ kind: 'tool', toolUseId: block.id, name: block.name, arg, summary })- }- }- const msgEvent: ChatEvent[] = parts.length- ? [{ kind: 'message', msg: { role: 'assistant', parts } satisfies ChatMessage }]- : []- return [...msgEvent, ...out]- }- if (msg.type === 'user' && Array.isArray((msg.message as { content?: unknown })?.content)) {- const out: ChatEvent[] = []- for (const block of (msg.message as { content: Array<Record<string, unknown>> }).content) {- if (block.type === 'tool_result' && typeof block.tool_use_id === 'string')- out.push({ kind: 'tool-result', toolUseId: block.tool_use_id, result: toolResultText(block.content) })- }- return out- }- if (msg.type === 'result') {- const usage = msg.usage- ? { inputTokens: msg.usage.input_tokens ?? 0, outputTokens: msg.usage.output_tokens ?? 0 }- : undefined- const done: ChatEvent = { kind: 'turn-done', costUsd: msg.total_cost_usd, usage }- if (msg.subtype && msg.subtype !== 'success')- return [done, { kind: 'error', message: `Turn ended: ${msg.subtype}`, fatal: false }]- return [done]- }- return []-}diff --git a/src/core/chat-queue.test.ts b/src/core/chat-queue.test.tsdeleted file mode 100644index 27d7dbe9d..000000000--- a/src/core/chat-queue.test.ts+++ /dev/null@@ -1,53 +0,0 @@-import { describe, expect, it } from 'vitest'-import { ChatInputQueue, createPushIterable } from './chat-queue'--describe('createPushIterable', () => {- it('yields pushed items in order and finishes on end()', async () => {- const { iterable, push, end } = createPushIterable<number>()- push(1); push(2)- const seen: number[] = []- const done = (async () => { for await (const v of iterable) seen.push(v) })()- // push after consumption started, then close- push(3); end()- await done- expect(seen).toEqual([1, 2, 3])- })-- it('parks a consumer on an empty iterable and wakes it when a value is pushed', async () => {- const { iterable, push, end } = createPushIterable<number>()- const seen: number[] = []- // Start consuming an EMPTY iterable — the loop parks on the internal notify promise.- const done = (async () => { for await (const v of iterable) seen.push(v) })()- // Let the microtask/timer queue drain so the consumer is actually parked.- await new Promise((r) => setTimeout(r, 0))- expect(seen).toEqual([])- // Now push: this must wake the parked consumer and deliver the value.- push(42)- await new Promise((r) => setTimeout(r, 0))- expect(seen).toEqual([42])- end()- await done- expect(seen).toEqual([42])- })-- it('drops items pushed after end()', async () => {- const { iterable, push, end } = createPushIterable<number>()- push(1); end()- // push-after-end is ignored — nothing new is delivered.- push(2)- const seen: number[] = []- for await (const v of iterable) seen.push(v)- expect(seen).toEqual([1])- })-})--describe('ChatInputQueue', () => {- it('is FIFO with stable ids and removal', () => {- const q = new ChatInputQueue()- const a = q.add('first'); const b = q.add('second')- expect(q.items().map((i) => i.text)).toEqual(['first', 'second'])- expect(q.remove(a.id)).toBe(true)- expect(q.takeNext()).toEqual(b)- expect(q.takeNext()).toBeUndefined()- })-})diff --git a/src/core/chat-queue.ts b/src/core/chat-queue.tsdeleted file mode 100644index 3f50c1e8a..000000000--- a/src/core/chat-queue.ts+++ /dev/null@@ -1,43 +0,0 @@-// Pure helpers for the chat driver: a push-based AsyncIterable (the SDK's streaming-// prompt input) and the driver-side FIFO of messages typed while a turn is running.-import type { ChatQueueItem } from '../shared/types'--// Single-consumer only: one shared buffer + one notify slot. A second concurrent-// consumer would clobber the parked waiter (the last one to await wins the notify),-// so only ever drive one `for await` loop over the returned iterable.-export function createPushIterable<T>(): { iterable: AsyncIterable<T>; push(item: T): void; end(): void } {- const buffer: T[] = []- let notify: (() => void) | null = null- let ended = false- const wake = () => { notify?.(); notify = null }- return {- push(item: T) { if (ended) return; buffer.push(item); wake() },- end() { ended = true; wake() },- iterable: {- async *[Symbol.asyncIterator]() {- for (;;) {- while (buffer.length) yield buffer.shift() as T- if (ended) return- await new Promise<void>((r) => { notify = r })- }- }- }- }-}--export class ChatInputQueue {- private list: ChatQueueItem[] = []- private seq = 0- items(): ChatQueueItem[] { return [...this.list] }- add(text: string): ChatQueueItem {- const item = { id: `q-${++this.seq}`, text }- this.list.push(item)- return item- }- remove(id: string): boolean {- const before = this.list.length- this.list = this.list.filter((i) => i.id !== id)- return this.list.length < before- }- takeNext(): ChatQueueItem | undefined { return this.list.shift() }-}diff --git a/src/core/claude-config-dir.ts b/src/core/claude-config-dir.tsindex 26bca8f05..1fbf295a1 100644--- a/src/core/claude-config-dir.ts+++ b/src/core/claude-config-dir.ts@@ -1,7 +1,7 @@// Resolve a managed Claude account's config dir under this app's persistent state root.// The account LIST + login lifecycle live in main/claude-accounts.ts; this is just the// impure path resolution (needs the platform seam for userDataDir) split out so core-// modules (chat-driver, pty-manager) can use it without importing electron.+// modules (pty-manager, etc.) can use it without importing electron.import { platform } from './platform'import { accountConfigDir } from './claude-accounts-core'diff --git a/src/main/index.ts b/src/main/index.tsindex c5c260d6a..a8536471c 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -60,7 +60,6 @@ import { RemoteFile, type RemoteFileRef } from './remote-ssh/remote-file'import { childArgs } from '../core/remote-ssh/control-master'import { posixQuote } from '../shared/ssh'import { buildHandoff } from './handoff'-import { ChatDriver } from '../core/chat-driver'import { initContextLink, setNodeTranscript } from '../core/context-link'import { initCanvasControl, installCanvasSkillInto } from './canvas-control'import { initTranscriptIndex, searchTranscripts } from '../core/transcript-index'@@ -195,9 +194,6 @@ const workspaceWatcher = new WorkspaceWatcher({})workspaceStore.onPersist = () => workspaceWatcher.sync()const gitService = new GitService()-// One driver for all chat nodes. Resolves the live window at send time (getMainWindow) so-// pushes survive a macOS close→dock-reopen; disposed on quit next to ptyManager.killAll().-const chatDriver = new ChatDriver(getMainWindow, sendToMain)// Markers delimiting the `projects.list` relay blob. The iOS client splits on these exact// strings to recover [workspace.json | newline-joined tmux session names | agent-status.json],@@ -981,17 +977,6 @@ app.whenReady().then(async () => {accountId: string | undefined) => buildHandoff({ sessionId, agentId, sourceNodeId, cwd, accountId }))- // Chat nodes: one long-lived Claude Agent SDK query per node, bridged over chat:* IPC. On the- // platform: the driver runs on THIS host, and a remote tab's chat node drives the same one.- corePlatform.handle(IPC.chatEnsure, (nodeId: string, opts) => chatDriver.ensure(nodeId, opts))- corePlatform.on(IPC.chatSend, (nodeId: string, text: string, images) =>- chatDriver.send(nodeId, text, images))- corePlatform.on(IPC.chatInterrupt, (nodeId: string) => chatDriver.interrupt(nodeId))- corePlatform.on(IPC.chatPermissionReply, (nodeId: string, requestId: string, decision) =>- chatDriver.permissionReply(nodeId, requestId, decision))- corePlatform.on(IPC.chatRemoveQueued, (nodeId: string, queueId: string) =>- chatDriver.removeQueued(nodeId, queueId))- corePlatform.on(IPC.chatDispose, (nodeId: string) => chatDriver.dispose(nodeId))installManagedAgentHooks()// Managed accounts each carry their own settings.json AND skills/ (Claude Code resolves both@@ -1421,7 +1406,6 @@ let quitFlushed = falseapp.on('before-quit', (e) => {quitting = true // from here on, window close-events must NOT be turned into hideworkspaceWatcher.dispose()- chatDriver.disposeAll() // tear down every chat node's SDK query (resume-based, so this is safe)if (quitFlushed) {// Second pass (the deferred app.quit() below): the flush had its chance — drop the masters.sshProjectManager?.disconnectAll()diff --git a/src/preload/index.ts b/src/preload/index.tsindex dd59896a5..e92a4c47a 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -367,20 +367,7 @@ const api: NodeTerminalApi = {},chat: {readTranscript: (sessionId, cwd, accountId) =>- ipcRenderer.invoke(IPC.chatReadTranscript, sessionId, cwd, accountId),- ensure: (nodeId, opts) => ipcRenderer.invoke(IPC.chatEnsure, nodeId, opts),- send: (nodeId, text, images) => ipcRenderer.send(IPC.chatSend, nodeId, text, images),- interrupt: (nodeId) => ipcRenderer.send(IPC.chatInterrupt, nodeId),- permissionReply: (nodeId, requestId, decision) =>- ipcRenderer.send(IPC.chatPermissionReply, nodeId, requestId, decision),- removeQueued: (nodeId, queueId) => ipcRenderer.send(IPC.chatRemoveQueued, nodeId, queueId),- dispose: (nodeId) => ipcRenderer.send(IPC.chatDispose, nodeId),- onEvent: (nodeId, listener) => {- const ch = IPC.chatEvent(nodeId)- const handler = (_e: unknown, payload: Parameters<typeof listener>[0]) => listener(payload)- ipcRenderer.on(ch, handler)- return () => ipcRenderer.removeListener(ch, handler)- }+ ipcRenderer.invoke(IPC.chatReadTranscript, sessionId, cwd, accountId)},claudeAccounts: {add: (ctx) => ipcRenderer.invoke(IPC.claudeAccountsAdd, ctx),diff --git a/src/renderer/bridge/relay-api.ts b/src/renderer/bridge/relay-api.tsindex e97e2cbf0..37418b900 100644--- a/src/renderer/bridge/relay-api.ts+++ b/src/renderer/bridge/relay-api.ts@@ -122,10 +122,10 @@ export function buildRelayApi(connectionId: string, transport?: FrameTransport):// ── Deferred over the relay in v1 — documented degrades (a clean refusal, not a wrong-machine// silent no-op): ──- // The SDK chat node has no relay chat builder yet (the Server Edition defers it too). Routing to- // the local chat driver would run it on the WRONG machine (a host cwd that does not exist- // locally), so refuse with E_UNSUPPORTED instead. contextLink / transcripts / handoff / boardLog- // stay LOCAL by way of `...local` (a v1 degrade: they read/write on this machine, not the host).+ // `chat` is now just readTranscript (the SDK chat node was removed). It has no relay builder:+ // reading a transcript over the relay would read THIS machine's transcript, not the host's, so+ // refuse with E_UNSUPPORTED instead. contextLink / transcripts / handoff / boardLog stay LOCAL+ // by way of `...local` (a v1 degrade: they read/write on this machine, not the host).chat: stub.chat,// Agent canvas-control (`agent:control`) is not wired over the relay (matches the Server// Edition); inert no-ops rather than a local subscription that never carries the host's events.diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.tsindex e560d24cf..0e1487ed7 100644--- a/src/renderer/bridge/stubs.ts+++ b/src/renderer/bridge/stubs.ts@@ -239,14 +239,7 @@ export function buildStubApi(): Omit<readTranscript: U('claude.readTranscript')},chat: {- readTranscript: U('chat.readTranscript'),- ensure: U('chat.ensure'),- send: noop,- interrupt: noop,- permissionReply: noop,- removeQueued: noop,- dispose: noop,- onEvent: noopUnsub+ readTranscript: U('chat.readTranscript')},claudeAccounts: {add: U('claudeAccounts.add'),diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex e8b43063b..0a631534b 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -885,9 +885,12 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {// ordinary Claude sessions, resumable in any terminal. (position/size are normalized// defensively so a legacy chat node still lands even if its shape is minimal.)let n = raw- if (n.kind === 'chat') {- const resume = n.chatSessionId- ? `\n\nContinue it in a terminal:\nclaude --resume ${n.chatSessionId}`+ // Legacy read: `chat` is no longer a NodeKind, so a persisted chat node arrives as an+ // unknown-kind blob — detect it by its string kind and read its old `chatSessionId` field.+ if ((n.kind as string) === 'chat') {+ const chatSessionId = (n as { chatSessionId?: string }).chatSessionId+ const resume = chatSessionId+ ? `\n\nContinue it in a terminal:\nclaude --resume ${chatSessionId}`: ''n = {...n,@@ -897,8 +900,7 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {width: (n as { width?: number }).width ?? STICKY_SIZE.width,height: (n as { height?: number }).height ?? STICKY_SIZE.height},- text: `This was a chat node — the chat node type was removed.${resume}`,- chatSessionId: undefined+ text: `This was a chat node — the chat node type was removed.${resume}`}}const collapsed = !!n.collapseddiff --git a/src/shared/ipc.ts b/src/shared/ipc.tsindex d9bd759f0..81a2bb974 100644--- a/src/shared/ipc.ts+++ b/src/shared/ipc.ts@@ -21,13 +21,6 @@ export const IPC = {ptyReadSessionName: 'pty:read-session-name',claudeReadTranscript: 'claude:read-transcript',chatReadTranscript: 'chat:read-transcript',- chatEnsure: 'chat:ensure',- chatSend: 'chat:send',- chatInterrupt: 'chat:interrupt',- chatPermissionReply: 'chat:permission-reply',- chatRemoveQueued: 'chat:remove-queued',- chatDispose: 'chat:dispose',- chatEvent: (nodeId: string) => `chat:event:${nodeId}`,claudeAccountsAdd: 'claude-accounts:add',claudeAccountsWaitLogin: 'claude-accounts:wait-login',claudeAccountsCancelWait: 'claude-accounts:cancel-wait',@@ -60,7 +53,7 @@ export const IPC = {* the local fs.watch (or the desktop-ssh 5s poll); the last one stops it. */boardLogSubscribe: 'board-log:subscribe',boardLogUnsubscribe: 'board-log:unsubscribe',- /** Per-project push fired when a project's board log changes (mirrors ptyData/chatEvent naming). */+ /** Per-project push fired when a project's board log changes (mirrors the ptyData naming). */boardLogChanged: (projectId: string) => `board-log:changed:${projectId}`,appUpdateAvailable: 'app:update-available',appUpdateDownloaded: 'app:update-downloaded',diff --git a/src/shared/types.ts b/src/shared/types.tsindex 5aa6ca08d..f48d5cc41 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -91,7 +91,7 @@ export interface RecycledInfo {}// 'subagent' and 'loop' are render-only (ephemeral hook-driven viz) and never persisted.-export type NodeKind = 'terminal' | 'sticky' | 'group' | 'editor' | 'diff' | 'video' | 'web' | 'browser' | 'subagent' | 'loop' | 'dino' | 'chat'+export type NodeKind = 'terminal' | 'sticky' | 'group' | 'editor' | 'diff' | 'video' | 'web' | 'browser' | 'subagent' | 'loop' | 'dino'/** Persisted state of a single canvas node (terminal, sticky note, group frame, or editor). */export interface CanvasNodeState {@@ -151,8 +151,6 @@ 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}/**@@ -1188,34 +1186,6 @@ export interface ChatToolSummary {removed?: number}-/** One queued (not-yet-sent) chat input. */-export interface ChatQueueItem {- id: string- text: string-}--/** A base64-encoded image attachment sent with a chat message. */-export interface ChatImageAttachment {- mediaType: string- data: string // base64-}--/** The renderer's reply to a chat permission request. */-export type ChatPermissionDecision = { behavior: 'allow' | 'deny'; alwaysSession?: boolean }--/** One streamed chat-driver event, pushed on chat:event:<nodeId>. */-export type ChatEvent =- | { kind: 'session'; sessionId: string; slashCommands: string[] }- | { kind: 'delta'; block: 'text' | 'thinking'; text: string }- | { kind: 'message'; msg: ChatMessage }- | { kind: 'tool'; toolUseId: string; name: string; arg: string; summary?: ChatToolSummary }- | { kind: 'tool-result'; toolUseId: string; result: string }- | { kind: 'permission'; requestId: string; toolName: string; input: unknown }- | { kind: 'permission-done'; requestId: string }- | { kind: 'turn-done'; costUsd?: number; usage?: { inputTokens: number; outputTokens: number } }- | { kind: 'queue'; items: ChatQueueItem[] }- | { kind: 'error'; message: string; fatal?: boolean }-export interface ChatApi {/*** Reads a Claude session transcript as structured chat messages ([] if unavailable).@@ -1227,18 +1197,6 @@ export interface ChatApi {cwd: string | undefined,accountId?: string): Promise<ChatMessage[]>- /** Start (or reattach) the driver for a node. fork=true resumes by forking (terminal takeover). */- ensure(- nodeId: string,- opts: { cwd?: string; sessionId?: string; fork?: boolean; accountId?: string }- ): Promise<{ ok: boolean; error?: string }>- send(nodeId: string, text: string, images?: ChatImageAttachment[]): void- interrupt(nodeId: string): void- permissionReply(nodeId: string, requestId: string, decision: ChatPermissionDecision): void- removeQueued(nodeId: string, queueId: string): void- /** Node closed for good: kill the driver process. */- dispose(nodeId: string): void- onEvent(nodeId: string, listener: (e: ChatEvent) => void): () => void}/** Optional SSH context for account ops. When `projectId` names a connected SSH project, the