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)!: remove the SDK chat node — renderer + sticky tombstone

enes5ad3f41fbc31
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 3b25a2a37..9a26f7391 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -32,7 +32,6 @@ 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'
@@ -51,7 +50,6 @@ import {
IconGear,
IconGrid,
IconGroup,
- IconChat,
IconDino,
IconJump,
IconKanban,
@@ -112,7 +110,6 @@ import { newEntryPath, parentDir } from '../lib/explorerCreate'
import { useProjects } from '../state/projects'
import { useAgentStatus } from '../state/agentStatus'
import { useTeamAccessEvents } from '../state/teamAccess'
-import { useChatSessions } from '../state/chatSessions'
import { useAgentNodes } from '../state/agentNodes'
import { SubagentNode } from '../nodes/SubagentNode'
import { LoopNode } from '../nodes/LoopNode'
@@ -209,7 +206,6 @@ import {
systemAccountDisplay,
createAgentNode,
createBrowserNode,
- createChatNode,
createDinoNode,
createDiffNode,
createEditorNode,
@@ -469,7 +465,7 @@ export function Canvas() {
const [scOpen, setScOpen] = useState(false)
const [shortcutsOpen, setShortcutsOpen] = useState(false)
const [dictationOpen, setDictationOpen] = useState(false)
- // Target = the first selected terminal/chat node AT OPEN TIME (not live-tracked while the
+ // Target = the first selected terminal node AT OPEN TIME (not live-tracked while the
// overlay is up — the design explicitly freezes it so a stray click elsewhere mid-dictation
// can't retarget an in-progress recording).
const [dictationTarget, setDictationTarget] = useState<DictationTarget | null>(null)
@@ -771,8 +767,7 @@ export function Canvas() {
dino: withNodeBoundary(DinoNode),
video: withNodeBoundary(VideoNode),
web: withNodeBoundary(WebNode),
- browser: withNodeBoundary(BrowserNode),
- chat: withNodeBoundary(ChatNode)
+ browser: withNodeBoundary(BrowserNode)
}),
[]
)
@@ -1010,7 +1005,7 @@ export function Canvas() {
}, [sessionsPinned])
// ⌘⌥D / Dock mic button: press-to-talk toggle. Closed → opens the dictation pill targeting the
- // first selected terminal/chat node (agent nodes are `type: 'terminal'` with `data.agentId`
+ // first selected terminal node (agent nodes are `type: 'terminal'` with `data.agentId`
// set — no separate case needed) and starts recording immediately (or, with no such node
// selected, shows a brief warning pill — see DictationOverlay's mount effect). Already open →
// does NOT close the overlay itself; it bumps `dictationStopSignal` so DictationOverlay can
@@ -1022,12 +1017,10 @@ export function Canvas() {
setDictationStopSignal((n) => n + 1)
return true
}
- const sel = nodesRef.current.find(
- (n) => n.selected && (n.type === 'terminal' || n.type === 'chat')
- )
+ const sel = nodesRef.current.find((n) => n.selected && n.type === 'terminal')
setDictationTarget(
sel
- ? { kind: sel.type === 'chat' ? 'chat' : 'terminal', nodeId: sel.id, title: (sel.data.title as string) || 'Untitled' }
+ ? { kind: 'terminal', nodeId: sel.id, title: (sel.data.title as string) || 'Untitled' }
: null
)
setDictationNonce((n) => n + 1)
@@ -2242,7 +2235,7 @@ export function Canvas() {
}
}, [openFile, revealProjectFile])
- // Mic button on a terminal/chat node's header (TerminalNode dispatches this — same
+ // Mic button on a terminal node's header (TerminalNode dispatches this — same
// no-direct-line-to-canvas pattern as nodeterm:open-file above). Unlike toggleDictation's
// shortcut path, which infers the target from the current selection, this opens the overlay
// targeting THAT node explicitly. If the overlay is already open — e.g. a different node was
@@ -2260,7 +2253,7 @@ export function Canvas() {
const n = nodesRef.current.find((x) => x.id === d.nodeId)
if (!n) return
setDictationTarget({
- kind: n.type === 'chat' ? 'chat' : 'terminal',
+ kind: 'terminal',
nodeId: n.id,
title: (n.data.title as string) || 'Untitled'
})
@@ -2433,24 +2426,6 @@ export function Canvas() {
[setNodes, markDirty, viewCenter]
)
- const addChatNode = useCallback(
- (center?: { x: number; y: number }, accountId?: string, groupId?: string) => {
- const project = useProjects.getState().getProject(activeProjectId)
- const cwd = cwdForNewNodeIn(groupId) ?? project?.cwd
- const account = resolveNewNodeAccount(
- accountId,
- project,
- useSettings.getState().settings.claudeAccounts
- )
- setNodes((ns) => {
- const node = createChatNode(ns.length, cwd, center ?? viewCenter(), undefined, account)
- return [...ns, groupId ? parentInto(node, groupId) : node]
- })
- markDirty()
- },
- [setNodes, markDirty, activeProjectId, viewCenter, cwdForNewNodeIn, parentInto]
- )
-
// Task 6: the Settings → Accounts "Add account" flow dispatches 'nodeterm:add-account-login'
// to open a terminal node running `claude /login` under the new account's config dir.
useEffect(() => {
@@ -2620,13 +2595,11 @@ export function Canvas() {
if (!chordHeld(e, combo, isMac)) return
armed = true
heldSince = Date.now()
- const sel = nodesRef.current.find(
- (n) => n.selected && (n.type === 'terminal' || n.type === 'chat')
- )
+ const sel = nodesRef.current.find((n) => n.selected && n.type === 'terminal')
setDictationTarget(
sel
? {
- kind: sel.type === 'chat' ? 'chat' : 'terminal',
+ kind: 'terminal',
nodeId: sel.id,
title: (sel.data.title as string) || 'Untitled'
}
@@ -2704,7 +2677,7 @@ export function Canvas() {
* `data.fileMissing` instead of rewritten. The node stays on the canvas (never auto-closed: it
* may hold unsaved Monaco edits the user hasn't copied out yet) and renders a persistent notice.
*
- * `respawn` separates the two callers (terminal/chat only — editor/diff has no session to touch):
+ * `respawn` separates the two callers (terminal only — editor/diff has no session to touch):
* - Remove (true): the directory is being deleted under live sessions, so their tmux sessions are
* destroyed and the terminals respawn straight into the fallback cwd.
* - Stale Unbind (false): unbind touches no process, by definition. The dead path is corrected on
@@ -2729,23 +2702,6 @@ export function Canvas() {
// every co-viewer's) and respawns into the fallback cwd. `destroy` would cast "closed
// by <name>" to co-viewers, permanently bricking their still-present node.
if (n.type === 'terminal') transport.recycle(n.id)
- // A chat node has no PTY, but it DOES have a live SDK driver — and that driver holds the
- // deleted cwd. Fixing only the persisted `data.cwd` (below) left the running query rooted
- // in a directory that no longer exists, where every tool call fails until the app is
- // restarted: the node looked fine and was quietly broken, which is worse than looking
- // broken. Recycling it is the exact same two steps the chat error bar's own "Reconnect"
- // button takes — dispose the driver, then `ensure` a new one — except the cwd it comes
- // back at is the fallback. `chatSessionId` is passed through, so the SDK RESUMES the same
- // conversation (history intact, on both sides); the renderer's message store is
- // deliberately NOT dropped, so the user sees no interruption at all.
- if (n.type === 'chat') {
- api.chat.dispose(n.id)
- void api.chat.ensure(n.id, {
- cwd: fallbackCwd,
- sessionId: n.data.chatSessionId as string | undefined,
- accountId: n.data.accountId as string | undefined
- })
- }
}
}
setNodes((ns) =>
@@ -2779,7 +2735,7 @@ export function Canvas() {
*
* For a STALE binding (the worktree directory was deleted behind git's back) that means:
* a. displace the children (`resetDisplacedCwd`, no respawn — nothing here ends a process):
- * terminals/chats get `data.cwd` off the dead path (left behind, that dead path is persisted
+ * terminals get `data.cwd` off the dead path (left behind, that dead path is persisted
* to project.json and tmux hides it until the next machine reboot cold-starts the terminal
* into a directory that is not there); editor/diff nodes get `data.fileMissing` instead,
* since there is nothing to re-point a dead `filePath` at; and
@@ -2822,13 +2778,6 @@ export function Canvas() {
if (n.type === 'terminal')
disposeTerminalOnUnmount(sessionForProject(useProjects.getState().activeProjectId ?? '').id, n.id)
if (n.type === 'terminal') 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') {
- api.chat.dispose(n.id)
- useChatSessions.getState().drop(n.id)
- }
// Permanent deletion → drop the node's persisted agent status (sessionId/session/
// unread/loop). Node unmount no longer does this, so deletion must. The loop card's
// UI overrides live in agentNodes and are skipped by unmount's clearForParent.
@@ -3270,12 +3219,12 @@ export function Canvas() {
// missed), plus editor/diff nodes anywhere on the canvas whose file was inside it:
// a. terminals: end the tmux session, which is now sitting in a directory that no longer
// exists;
- // b. terminals AND chats: reset `data.cwd` off the deleted path. Leaving it there is the
+ // b. terminals: reset `data.cwd` off the deleted path. Leaving it there is the
// exact trap this whole task exists to remove — on the next mount the node spawns into
// a path that is gone, pty-manager silently falls back to $HOME, and the dead cwd is
// persisted forever — only reached through the SANCTIONED Remove path.
// c. editor/diff: mark `data.fileMissing`. There is no fallback path to re-point a dead
- // `filePath` at — the file is genuinely gone — so unlike terminals/chats these are
+ // `filePath` at — the file is genuinely gone — so unlike terminals these are
// flagged, not rewritten, and the node shows a persistent notice instead of silently
// opening blank or failing a `git show`.
// The respawn (nonce bump) puts the terminal straight back in the fallback cwd rather than
@@ -3874,7 +3823,7 @@ export function Canvas() {
]
)
- /** "New <agent>" / "New chat" creation entries shared by the pane and group context menus.
+ /** "New <agent>" creation entries shared by the pane and group context menus.
* `at` is the flow position to create at; with `groupId` the node is parented into that group. */
const agentCreationItems = useCallback(
(at?: { x: number; y: number }, groupId?: string): MenuItem[] => {
@@ -3951,8 +3900,6 @@ export function Canvas() {
onClick: () => addAgentNode(c.id, at, groupId)
})
)
- // "New chat" is deliberately NOT here: the context menus stay session-focused; chat
- // nodes are created from the Dock + menu and the command palette.
]
},
[activeProjectId, addAgentNode]
@@ -4177,7 +4124,7 @@ export function Canvas() {
const kanbanSessions = useMemo(
() =>
nodes
- .filter((n) => n.type === 'terminal' || n.type === 'chat' || n.type === 'sticky')
+ .filter((n) => n.type === 'terminal' || n.type === 'sticky')
.map((n) => {
if (n.type === 'sticky') {
const text = ((n.data.text as string) ?? '').trim()
@@ -4188,7 +4135,7 @@ export function Canvas() {
color: (n.data.color as string) ?? NODE_COLORS[2],
kind: 'sticky' as const,
text,
- // Sticky/chat cards never open a live terminal — the modal reads no spawn info.
+ // Sticky cards never open a live terminal — the modal reads no spawn info.
spawn: {}
}
}
@@ -4196,10 +4143,10 @@ export function Canvas() {
id: n.id,
title: (n.data.title as string) ?? '',
color: (n.data.color as string) ?? NODE_COLORS[0],
- kind: n.type as 'terminal' | 'chat',
+ kind: 'terminal' as const,
agentId: n.data.agentId as string | undefined,
// What the card modal's co-attach terminal needs to join THIS node's session the same
- // way the canvas TerminalNode does (used for kind 'terminal'; a chat card ignores it).
+ // way the canvas TerminalNode does.
spawn: {
shell: n.data.shell as string | undefined,
cwd: n.data.cwd as string | undefined,
@@ -4996,10 +4943,6 @@ export function Canvas() {
} else {
disposeTerminalOnUnmount(sessionForProject(projectId).id, id) // node may be parked from the project switch
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.
- api.chat.dispose(id)
- useChatSessions.getState().drop(id)
useAgentStatus.getState().remove(id)
useProjects.getState().removeNode(projectId, id)
void writeDisk()
@@ -5636,10 +5579,6 @@ export function Canvas() {
disposeTerminalOnUnmount(sessionForProject(id).id, n.id) // may be parked from a recent switch away
transport.destroy(n.id)
}
- if ((n.kind ?? 'terminal') === 'chat') {
- api.chat.dispose(n.id)
- useChatSessions.getState().drop(n.id)
- }
useAgentStatus.getState().remove(n.id)
})
// SSH project: the per-node `transport.destroy` above only ends the REMOTE session for
@@ -5719,7 +5658,6 @@ export function Canvas() {
run: () => addAgentNode('claude', undefined, undefined, a.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() },
@@ -5825,7 +5763,6 @@ export function Canvas() {
}, [
addTerminal,
addAgentNode,
- addChatNode,
addSticky,
addDino,
addWebView,
@@ -6105,7 +6042,7 @@ export function Canvas() {
)}
{/* The active project's node subtree runs under ITS session (local for a local tab, the
relay session for a remote tab). Keyed by session id so an api swap REMOUNTS the nodes
- (obligation 3): TerminalNode/EditorNode/ChatNode capture `api` in []-effects, so a live
+ (obligation 3): TerminalNode/EditorNode capture `api` in []-effects, so a live
api change must remount them or they keep talking to the old core. For an all-local user
the key is always 'local', so this never remounts — zero behavior change. */}
<SessionProvider session={sessionForProject(activeProjectId || '')} key={sessionForProject(activeProjectId || '').id}>
@@ -6520,7 +6457,6 @@ export function Canvas() {
onAddSticky={addSticky}
onAddDino={addDino}
onAddAgent={(aid, accountId) => addAgentNode(aid, undefined, undefined, accountId)}
- onAddChat={() => addChatNode()}
onOpenFile={() => void openFileDialog()}
onAddRemote={() => openRemotePicker({ x: window.innerWidth / 2, y: window.innerHeight / 2 })}
onConnectRemote={() => void connectRemote()}
diff --git a/src/renderer/components/DictationOverlay.test.ts b/src/renderer/components/DictationOverlay.test.ts
index 28ab23ae0..254a6dfa0 100644
--- a/src/renderer/components/DictationOverlay.test.ts
+++ b/src/renderer/components/DictationOverlay.test.ts
@@ -2,33 +2,16 @@ import { describe, expect, it } from 'vitest'
import { dictationMode, isAtRecordingCap, isProGateError, type DictationTarget } from './DictationOverlay'
const terminalTarget: DictationTarget = { kind: 'terminal', nodeId: 'n1', title: 'shell' }
-const chatTarget: DictationTarget = { kind: 'chat', nodeId: 'n2', title: 'chat' }
-// Press-to-talk: the pill is the default surface for both target kinds while a take is in
-// flight; only a chat target's *transcribed* text ever reaches the editable card (a terminal
-// target inserts directly and never has a 'text' phase at all — see DictationOverlay.stopRecording).
+// Press-to-talk: the pill is the only surface for a terminal target — the transcript is inserted
+// straight into the terminal, so there is no editable card (chat nodes, which had one, are gone).
describe('dictationMode', () => {
- it('is "warning" whenever there is no target, regardless of phase', () => {
- expect(dictationMode(null, 'idle')).toBe('warning')
- expect(dictationMode(null, 'recording')).toBe('warning')
- expect(dictationMode(null, 'text')).toBe('warning')
+ it('is "warning" whenever there is no target', () => {
+ expect(dictationMode(null)).toBe('warning')
})
- it('is "pill" for a terminal target in every phase, including "text"', () => {
- expect(dictationMode(terminalTarget, 'idle')).toBe('pill')
- expect(dictationMode(terminalTarget, 'recording')).toBe('pill')
- expect(dictationMode(terminalTarget, 'transcribing')).toBe('pill')
- expect(dictationMode(terminalTarget, 'text')).toBe('pill')
- })
-
- it('is "pill" for a chat target until phase reaches "text"', () => {
- expect(dictationMode(chatTarget, 'idle')).toBe('pill')
- expect(dictationMode(chatTarget, 'recording')).toBe('pill')
- expect(dictationMode(chatTarget, 'transcribing')).toBe('pill')
- })
-
- it('is "card" only for a chat target once transcribed ("text" phase)', () => {
- expect(dictationMode(chatTarget, 'text')).toBe('card')
+ it('is "pill" for a terminal target', () => {
+ expect(dictationMode(terminalTarget)).toBe('pill')
})
})
diff --git a/src/renderer/components/DictationOverlay.tsx b/src/renderer/components/DictationOverlay.tsx
index 7440bd9e5..9673872d5 100644
--- a/src/renderer/components/DictationOverlay.tsx
+++ b/src/renderer/components/DictationOverlay.tsx
@@ -1,13 +1,12 @@
// Desktop press-to-talk: shortcut/Dock-mic press starts recording IMMEDIATELY into a compact
// bottom-center pill (stop icon + live equalizer + elapsed mm:ss); pressing again (or the pill's
-// own stop icon) stops → transcribes → for a terminal target inserts the text directly
+// own stop icon) stops → transcribes → inserts the text directly into the target terminal
// (`pty.sendText(id, text, { enter: false })`, no Enter — nothing here ever auto-submits) and the
-// pill closes; for a chat target (no external draft field to insert into) the transcript opens
-// in the v1 editable CARD instead, where the user still presses Send themselves.
+// pill closes.
//
// Two different ways to dismiss, not interchangeable:
// - STOP (shortcut second-press / the pill's stop icon) — ends the recording and PROCESSES it
-// (transcribe → insert/card).
+// (transcribe → insert).
// - CANCEL (Esc, or the ×/close affordances) — DISCARDS whatever was being recorded and closes
// the whole overlay. Esc mid-recording is cancel, not stop, even though both are triggered by
// a "press" — see handleClose vs the stopSignal branch below.
@@ -18,10 +17,9 @@ import { createPortal } from 'react-dom'
import { scaleLevel } from '../lib/dictation-equalizer'
import { PcmCapture } from '../lib/pcm-capture'
import { useSession } from '../session/session'
-import { useChatSessions } from '../state/chatSessions'
export interface DictationTarget {
- kind: 'terminal' | 'chat'
+ kind: 'terminal'
nodeId: string
title: string
}
@@ -45,19 +43,15 @@ export function isProGateError(message: string): boolean {
return message.includes('requires nodeterm Pro')
}
-type Phase = 'idle' | 'recording' | 'transcribing' | 'text'
+type Phase = 'idle' | 'recording' | 'transcribing'
/** 'warning' = no target at press time (never records). 'pill' = the compact recording/
- * transcribing/error capsule — used for BOTH targets while a take is in flight, and for a
- * terminal target start to finish (it never reaches 'card'). 'card' = the v1 editable text
- * card, reached only once a chat target's take has transcribed successfully (and again if the
- * user re-records another take from there — the re-record trip goes back out through 'pill'). */
-export type DictationMode = 'warning' | 'pill' | 'card'
+ * transcribing/error capsule — the whole surface for a terminal target, start to finish
+ * (the transcript is inserted straight into the terminal, so there is no editable card). */
+export type DictationMode = 'warning' | 'pill'
/** Pure — no side effects. Exported for its own unit coverage. */
-export function dictationMode(target: DictationTarget | null, phase: Phase): DictationMode {
- if (!target) return 'warning'
- if (target.kind === 'chat' && phase === 'text') return 'card'
- return 'pill'
+export function dictationMode(target: DictationTarget | null): DictationMode {
+ return target ? 'pill' : 'warning'
}
/** mm:ss, floored to whole seconds. Pure — no side effects. */
@@ -68,15 +62,6 @@ export function formatElapsed(ms: number): string {
return `${m}:${s.toString().padStart(2, '0')}`
}
-/** Appends a new take's text after any existing text, space-separated; trims both sides. */
-export function appendTake(existing: string, take: string): string {
- const a = existing.trim()
- const b = take.trim()
- if (!a) return b
- if (!b) return a
- return `${a} ${b}`
-}
-
// Faster than the visual 12-bar window needs on its own — the point is to feed more DISTINCT
// samples into that scrolling window (see dictation-equalizer.ts) so the equalizer reads as live
// motion instead of a slow crawl. PcmCapture.level() (RMS of the last chunk) is cheap enough that
@@ -99,17 +84,11 @@ const NO_TARGET_DISMISS_MS = 2500
export function DictationOverlay({ target, stopSignal, onClose, onOpenLicense }: DictationOverlayProps) {
const { api } = useSession()
- const addLocalUser = useChatSessions((s) => s.addLocalUser)
- const chatWorking = useChatSessions((s) =>
- target?.kind === 'chat' ? s.byId[target.nodeId]?.working : undefined
- )
const [phase, setPhase] = useState<Phase>('idle')
- const [text, setText] = useState('')
const [error, setError] = useState<string | null>(null)
const [elapsedMs, setElapsedMs] = useState(0)
const [levelHistory, setLevelHistory] = useState<number[]>([])
- const [sending, setSending] = useState(false)
const [capped, setCapped] = useState(false)
const captureRef = useRef<PcmCapture | null>(null)
@@ -164,33 +143,22 @@ export function DictationOverlay({ target, stopSignal, onClose, onOpenLicense }:
// An in-flight transcription can't be aborted — dropping the result honors the user's
// dismissal (nothing may land after a cancel).
if (discardedRef.current) return
- if (target.kind === 'terminal') {
- const ok = await api.pty.sendText(target.nodeId, transcribed, { enter: false })
- if (!ok) {
- setError('Could not insert — the terminal session is not available.')
- setPhase('idle')
- return
- }
- // A stale (remounted-over) instance still delivers its own transcript into the
- // terminal — the target closure is per-instance and correct — but must not close the
- // parent overlay state: a newer instance (a fresh hold-to-talk press that arrived while
- // this one was still transcribing) may be live and recording in it right now.
- if (mountedRef.current) onClose()
+ const ok = await api.pty.sendText(target.nodeId, transcribed, { enter: false })
+ if (!ok) {
+ setError('Could not insert — the terminal session is not available.')
+ setPhase('idle')
return
}
- // Chat: no external draft field to insert into (see the file header) — open the editable
- // card so the user can review/edit and press Send themselves. Appends onto any earlier take
- // (re-record from the card).
- setText((prev) => appendTake(prev, transcribed))
- setPhase('text')
+ // A stale (remounted-over) instance still delivers its own transcript into the
+ // terminal — the target closure is per-instance and correct — but must not close the
+ // parent overlay state: a newer instance (a fresh hold-to-talk press that arrived while
+ // this one was still transcribing) may be live and recording in it right now.
+ if (mountedRef.current) onClose()
} catch (err) {
setError(err instanceof Error ? err.message : 'Transcription failed.')
- // A chat target with an earlier successful take falls back to the card (keeping that text,
- // now alongside the error); everything else (terminal, or no prior text yet) falls back to
- // the pill so the user can retry.
- setPhase(text.trim() ? 'text' : 'idle')
+ setPhase('idle')
}
- }, [clearTimer, target, api, onClose, text])
+ }, [clearTimer, target, api, onClose])
const startRecording = useCallback(async () => {
if (!target) return
@@ -278,8 +246,8 @@ export function DictationOverlay({ target, stopSignal, onClose, onOpenLicense }:
// A second shortcut/Dock-mic press while this overlay is already open (Canvas bumps
// `stopSignal` rather than unmounting us — see DictationOverlayProps). While actively
- // recording that means STOP (transcribe → insert/card); in every other phase (warning,
- // transcribing, the editable card, an error pill) it means dismiss, same as Esc/×.
+ // recording that means STOP (transcribe → insert); in every other phase (warning,
+ // transcribing, an error pill) it means dismiss, same as Esc/×.
const prevStopSignalRef = useRef(stopSignal)
useEffect(() => {
if (stopSignal === prevStopSignalRef.current) return
@@ -291,39 +259,7 @@ export function DictationOverlay({ target, stopSignal, onClose, onOpenLicense }:
}
}, [stopSignal, phase, stopRecording, handleClose])
- const send = useCallback(async () => {
- if (!target) return
- const value = text.trim()
- if (!value) return
- setSending(true)
- setError(null)
- try {
- if (target.kind === 'terminal') {
- const ok = await api.pty.sendText(target.nodeId, value)
- if (!ok) {
- setError('Could not send — the terminal session is not available.')
- return
- }
- } else {
- api.chat.send(target.nodeId, value)
- if (!chatWorking) addLocalUser(target.nodeId, value)
- }
- onClose()
- } catch (err) {
- setError(err instanceof Error ? err.message : 'Failed to send.')
- } finally {
- setSending(false)
- }
- }, [target, text, api, chatWorking, addLocalUser, onClose])
-
- const copy = useCallback(() => {
- const value = text.trim()
- if (!value) return
- window.nodeTerminal.clipboard.writeText(value)
- }, [text])
-
- const hasText = !!text.trim()
- const mode = dictationMode(target, phase)
+ const mode = dictationMode(target)
const errorBlock = error && (
<div className="dictation__error">
@@ -342,7 +278,7 @@ export function DictationOverlay({ target, stopSignal, onClose, onOpenLicense }:
if (mode === 'warning') {
return createPortal(
<div className="dictation dictation--warning nodrag nowheel" onMouseDown={(e) => e.stopPropagation()}>
- <span className="dictation__warning-text">Select a terminal or chat node first.</span>
+ <span className="dictation__warning-text">Select a terminal node first.</span>
<button type="button" className="dictation__close" title="Dismiss" onClick={handleClose}>
×
</button>
@@ -351,8 +287,9 @@ export function DictationOverlay({ target, stopSignal, onClose, onOpenLicense }:
)
}
- if (mode === 'pill') {
- return createPortal(
+ // mode === 'pill' — the whole surface for a terminal target (a transcribed take is inserted
+ // straight into the terminal, so there is no editable card).
+ return createPortal(
<div className="dictation dictation--pill nodrag nowheel" onMouseDown={(e) => e.stopPropagation()}>
{phase === 'recording' && (
<div className="dictation__pill">
@@ -399,69 +336,6 @@ export function DictationOverlay({ target, stopSignal, onClose, onOpenLicense }:
</div>,
document.body
)
- }
-
- // mode === 'card' — chat only, reached once a take has transcribed. v1 editable card, minus
- // Insert (chat has no external draft field — see the file header; the quick pill flow above is
- // how a terminal target ever gets text inserted, so Insert has no reachable case here at all).
- return createPortal(
- <div className="dictation dictation--card nodrag nowheel" onMouseDown={(e) => e.stopPropagation()}>
- <div className="dictation__head">
- <span className="dictation__title">Dictate</span>
- <span className="dictation__target">→ {target?.title}</span>
- <button type="button" className="dictation__close" title="Close (Esc)" onClick={handleClose}>
- ×
- </button>
- </div>
-
- <div className="dictation__body">
- <div className="dictation__text-row">
- <textarea
- className="dictation__textarea"
- value={text}
- onChange={(e) => setText(e.target.value)}
- placeholder="Transcribed text…"
- autoFocus
- spellCheck
- />
- <button
- type="button"
- className="dictation__mic dictation__mic--small"
- onClick={() => void startRecording()}
- title="Record another take (appends)"
- >
- <MicIcon />
- </button>
- </div>
- </div>
-
- {errorBlock}
-
- <div className="dictation__actions">
- <button type="button" className="dictation__btn" onClick={copy} disabled={!hasText}>
- Copy
- </button>
- <button
- type="button"
- className="dictation__btn dictation__btn--primary"
- onClick={() => void send()}
- disabled={!target || !hasText || sending}
- >
- Send
- </button>
- </div>
- </div>,
- document.body
- )
-}
-
-function MicIcon() {
- return (
- <svg width={18} height={18} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.8} strokeLinecap="round" strokeLinejoin="round">
- <rect x="9" y="2" width="6" height="12" rx="3" />
- <path d="M5 11a7 7 0 0 0 14 0M12 18v4M8 22h8" />
- </svg>
- )
}
function PauseIcon() {
diff --git a/src/renderer/components/Dock.tsx b/src/renderer/components/Dock.tsx
index 94b317739..380c7bf74 100644
--- a/src/renderer/components/Dock.tsx
+++ b/src/renderer/components/Dock.tsx
@@ -18,7 +18,6 @@ interface DockProps {
onAddSticky: () => void
onAddDino: () => void
onAddAgent: (agentId: AgentId, accountId?: string) => void
- onAddChat: () => void
onOpenFile: () => void
onAddRemote: () => void
onConnectRemote: () => void
@@ -45,7 +44,6 @@ export function Dock({
onAddSticky,
onAddDino,
onAddAgent,
- onAddChat,
onOpenFile,
onAddRemote,
onConnectRemote,
@@ -137,10 +135,6 @@ 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>
@@ -294,14 +288,6 @@ 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/kanban/KanbanView.tsx b/src/renderer/components/kanban/KanbanView.tsx
index 8fd39cebc..498a4620e 100644
--- a/src/renderer/components/kanban/KanbanView.tsx
+++ b/src/renderer/components/kanban/KanbanView.tsx
@@ -18,12 +18,12 @@ export interface KanbanSession {
id: string
title: string
color: string
- kind: 'terminal' | 'chat' | 'sticky'
+ kind: 'terminal' | 'sticky'
agentId?: string
/** Sticky note body — shown in the expanded detail row. */
text?: string
/** The subset of the node's `data` the card modal's co-attach terminal needs to spawn/join the
- * same session (kind 'terminal' only; sticky/chat pass `{}`). */
+ * same session (kind 'terminal' only; sticky passes `{}`). */
spawn: ModalSpawn
}
diff --git a/src/renderer/components/kanban/SessionCard.tsx b/src/renderer/components/kanban/SessionCard.tsx
index de4d7f294..ee692c042 100644
--- a/src/renderer/components/kanban/SessionCard.tsx
+++ b/src/renderer/components/kanban/SessionCard.tsx
@@ -51,7 +51,6 @@ export function SessionCard({
<div className="kanban-card__row">
<span className="kanban-card__nodedot" style={{ background: session.color }} />
<span className="kanban-card__title">{session.title}</span>
- {session.kind === 'chat' && <span className="kanban-card__kind">chat</span>}
{sticky && <span className="kanban-card__kind">note</span>}
{badge === 'running' && <span className="kanban-badge kanban-badge--running">RUNNING</span>}
{badge === 'needs' && <span className="kanban-badge kanban-badge--needs">NEEDS YOU</span>}
@@ -71,9 +70,7 @@ export function SessionCard({
</span>
)}
{!status?.sessionId && (
- <span className="kanban-card__kindlabel">
- {session.kind === 'chat' ? 'chat' : 'terminal'}
- </span>
+ <span className="kanban-card__kindlabel">terminal</span>
)}
</>
)}
diff --git a/src/renderer/nodes/ChatNode.tsx b/src/renderer/nodes/ChatNode.tsx
deleted file mode 100644
index 2f43d3b82..000000000
--- a/src/renderer/nodes/ChatNode.tsx
+++ /dev/null
@@ -1,396 +0,0 @@
-// SDK-driven chat node: token-streaming conversation with Claude, permission cards,
-// send-while-working queue. Continuity is resume-based via data.chatSessionId — the
-// SDK process dies with the app; history reloads from the on-disk transcript.
-import {
- useCallback,
- useEffect,
- useRef,
- useState,
- type ClipboardEvent,
- type DragEvent,
- type KeyboardEvent,
- type Key
-} from 'react'
-import { NodeResizer, useReactFlow, type NodeProps } from '@xyflow/react'
-import { MarkdownText } from './ChatPanel'
-import { useChatSessions } from '../state/chatSessions'
-import { useAgentStatus } from '../state/agentStatus'
-import { useSession } from '../session/session'
-import { accountChipLabel, createDiffNode, type CanvasNode } from '../state/workspace'
-import { useSettings } from '../state/settings'
-import type { ChatImageAttachment, ChatToolSummary } from '@shared/types'
-import { ColumnPill } from '../components/kanban/ColumnPill'
-
-const MAX_IMAGES = 5
-const MAX_IMAGE_BYTES = 2 * 1024 * 1024 // 2 MB per image
-
-export default function ChatNode({ id, data, selected }: NodeProps<CanvasNode>) {
- // This node's core api (a stable context read — the local session's api IS window.nodeTerminal).
- // The boot effect below captures it in its CLOSURE and keeps its `[id]` dep array: it subscribes
- // to driver events and starts/reattaches the driver, and re-keying that on `api` would silently
- // re-create the driver subscription when 4c makes a remote session's api replaceable.
- const { api } = useSession()
- const chat = useChatSessions((s) => s.byId[id])
- const apply = useChatSessions((s) => s.apply)
- const seed = useChatSessions((s) => s.seed)
- const addLocalUser = useChatSessions((s) => s.addLocalUser)
- const clearError = useChatSessions((s) => s.clearError)
- const status = useAgentStatus((s) => s.byId[id])
- // The driver's agent-status event lands (IPC) before the store's first delta flips
- // chat.working, so OR both — this drives the badge, Stop button and typing indicator.
- const working = !!chat?.working || status?.state === 'working'
- const { setNodes, addNodes } = useReactFlow()
- const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)
- const accountChip = accountChipLabel(data.accountId as string | undefined, claudeAccounts)
- const [input, setInput] = useState('')
- const [images, setImages] = useState<ChatImageAttachment[]>([])
- const [attachNote, setAttachNote] = useState<string | null>(null)
- // Slash-command popup: an index into the filtered matches, plus a manual-dismiss flag
- // (Escape / after completion) so the popup can close without changing the input text.
- const [slashIdx, setSlashIdx] = useState(0)
- const [slashDismissed, setSlashDismissed] = useState(false)
- const msgsRef = useRef<HTMLDivElement>(null)
-
- // Boot: subscribe to driver events, seed history from disk, start/reattach the driver.
- useEffect(() => {
- const off = api.chat.onEvent(id, (e) => {
- apply(id, e)
- if (e.kind === 'session') {
- // Persist the session id on the node so a relaunch resumes it.
- setNodes((ns) => ns.map((n) => (n.id === id ? { ...n, data: { ...n.data, chatSessionId: e.sessionId } } : n)))
- }
- })
- const own = data.chatSessionId as string | undefined
- const forkFrom = data.forkFrom as string | undefined
- // Fork path (Task 10): until our own session id arrives, resume the SOURCE session with
- // fork:true; once the driver's `session` event persists chatSessionId, forkFrom is ignored.
- const sessionId = own ?? forkFrom
- const accountId = data.accountId as string | undefined
- if (sessionId) void api.chat.readTranscript(sessionId, data.cwd as string | undefined, accountId).then((m) => seed(id, m))
- void api.chat.ensure(id, {
- cwd: data.cwd as string | undefined,
- sessionId,
- fork: !own && !!forkFrom ? true : undefined,
- accountId
- })
- return off
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [id])
-
- // Fork bootstrap: forkFrom carries the source session id until our own id arrives.
- // (ensure() above passes fork:true with sessionId=data.forkFrom when set — see Task 10.)
-
- useEffect(() => {
- const el = msgsRef.current
- if (el) el.scrollTop = el.scrollHeight
- // `working` (not chat.working): the typing indicator is shown off the agent-status event,
- // which arrives before any delta touches the store — scroll must follow it too. toolOrder/
- // permission keep new tool cards and the permission card in view.
- }, [chat?.messages, chat?.streamText, chat?.streamThinking, working, chat?.toolOrder, chat?.permission])
-
- const send = useCallback(() => {
- const text = input.trim()
- if (!text && images.length === 0) return
- api.chat.send(id, text, images.length ? images : undefined)
- if (!chat?.working) addLocalUser(id, text)
- setInput('')
- setImages([])
- setAttachNote(null)
- setSlashDismissed(false)
- }, [api, input, images, id, chat?.working, addLocalUser])
-
- // --- Image attachments (paste + drag-drop) -------------------------------
- const addFiles = useCallback(
- (files: File[]) => {
- const imgs = files.filter((f) => f.type.startsWith('image/'))
- if (imgs.length === 0) return
- let dropped = imgs.length - imgs.filter((f) => f.size <= MAX_IMAGE_BYTES).length // oversized
- const ok = imgs.filter((f) => f.size <= MAX_IMAGE_BYTES)
- Promise.all(
- ok.map(
- (f) =>
- new Promise<ChatImageAttachment>((resolve, reject) => {
- const reader = new FileReader()
- reader.onload = () => {
- const res = String(reader.result)
- // strip the `data:<mime>;base64,` prefix → raw base64
- const comma = res.indexOf(',')
- resolve({ mediaType: f.type, data: comma >= 0 ? res.slice(comma + 1) : res })
- }
- reader.onerror = () => reject(reader.error)
- reader.readAsDataURL(f)
- })
- )
- ).then((atts) => {
- setImages((prev) => {
- const room = Math.max(0, MAX_IMAGES - prev.length)
- const accepted = atts.slice(0, room)
- dropped += atts.length - accepted.length // over the 5-image cap
- return accepted.length ? [...prev, ...accepted] : prev
- })
- setAttachNote(dropped > 0 ? `Skipped ${dropped} file(s) — max ${MAX_IMAGES} images, 2 MB each` : null)
- })
- },
- []
- )
-
- const removeImage = (i: number) => setImages((prev) => prev.filter((_, idx) => idx !== i))
-
- const onPaste = (e: ClipboardEvent<HTMLTextAreaElement>) => {
- const files = Array.from(e.clipboardData?.files ?? [])
- if (files.some((f) => f.type.startsWith('image/'))) {
- e.preventDefault() // don't also paste the image path/text
- addFiles(files)
- }
- }
- const onDrop = (e: DragEvent<HTMLTextAreaElement>) => {
- const files = Array.from(e.dataTransfer?.files ?? [])
- if (files.length) {
- e.preventDefault()
- addFiles(files)
- }
- }
- const onDragOver = (e: DragEvent<HTMLTextAreaElement>) => {
- if (Array.from(e.dataTransfer?.types ?? []).includes('Files')) e.preventDefault()
- }
-
- // --- Slash-command popup -------------------------------------------------
- const trimmed = input.trim()
- const slashMatches = trimmed.startsWith('/')
- ? (chat?.slashCommands ?? []).filter((c) => c.startsWith(trimmed)).slice(0, 8)
- : []
- const slashOpen = slashMatches.length > 0 && !slashDismissed
- const slashActive = slashOpen ? Math.min(slashIdx, slashMatches.length - 1) : -1
-
- const completeSlash = (cmd: string) => {
- setInput(cmd + ' ')
- setSlashDismissed(true) // programmatic setInput doesn't re-open the popup
- setSlashIdx(0)
- }
-
- const onInputChange = (value: string) => {
- setInput(value)
- setSlashIdx(0)
- setSlashDismissed(false)
- }
-
- // --- Diff-preview tool card ----------------------------------------------
- const openDiff = (filePath?: string) => {
- const cwd = data.cwd as string | undefined
- if (!filePath || !cwd || !filePath.startsWith(cwd)) return
- const rel = filePath.slice(cwd.length).replace(/^\//, '')
- if (!rel) return
- addNodes(createDiffNode(0, cwd, rel, false)) // false → unstaged (working ↔ index)
- }
-
- const onKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
- if (slashOpen) {
- if (e.key === 'ArrowDown') {
- e.preventDefault()
- setSlashIdx((i) => (i + 1) % slashMatches.length)
- return
- }
- if (e.key === 'ArrowUp') {
- e.preventDefault()
- setSlashIdx((i) => (i - 1 + slashMatches.length) % slashMatches.length)
- return
- }
- if (e.key === 'Tab' || (e.key === 'Enter' && !e.shiftKey)) {
- e.preventDefault()
- completeSlash(slashMatches[slashActive])
- return
- }
- if (e.key === 'Escape') {
- e.preventDefault()
- setSlashDismissed(true)
- return
- }
- }
- if (e.key === 'Enter' && !e.shiftKey) {
- e.preventDefault()
- send()
- }
- }
-
- const perm = chat?.permission
- const cwd = data.cwd as string | undefined
-
- // Shared tool-card renderer for both live (toolOrder) and committed (folded into history at
- // turn-done) tools, so both get the same summary label + diff-preview click treatment.
- const renderTool = (
- t: { name: string; arg: string; result?: string; summary?: ChatToolSummary },
- key: Key,
- open: boolean
- ) => {
- const diffPath = t.summary?.filePath
- const canDiff = !!diffPath && !!cwd && diffPath.startsWith(cwd)
- return (
- <details key={key} className="term-chat__tool" open={open}>
- <summary>
- <span className="term-chat__tool-name">{t.name}</span>
- <span
- className={`term-chat__tool-arg${canDiff ? ' term-chat__tool-arg--link' : ''}`}
- title={canDiff ? 'Open diff' : undefined}
- onClick={
- canDiff
- ? (e) => {
- e.preventDefault() // don't toggle the <details>
- e.stopPropagation()
- openDiff(diffPath)
- }
- : undefined
- }
- >
- {t.summary ? `${t.summary.filePath} +${t.summary.added} −${t.summary.removed}` : t.arg}
- </span>
- </summary>
- {t.result && <pre className="term-chat__tool-result">{t.result}</pre>}
- </details>
- )
- }
-
- return (
- <>
- {/* Sibling of the root: .chat-node is overflow:hidden and would clip the half-pill. */}
- <ColumnPill nodeId={id} />
- <div className={`chat-node${selected ? ' selected' : ''}`} style={{ borderTopColor: data.color }}>
- <NodeResizer isVisible={selected} minWidth={360} minHeight={280} />
- <div className="chat-node__header">
- <span className="chat-node__title">{(data.title as string) || 'Chat'}</span>
- {accountChip && (
- <span className="node-account-chip" title={accountChip.tooltip}>
- {accountChip.short}
- </span>
- )}
- {working && <span className="chat-node__badge chat-node__badge--working">RUNNING</span>}
- {perm && <span className="chat-node__badge chat-node__badge--needs">NEEDS YOU</span>}
- {/* Cost chip intentionally hidden: the SDK reports an API-equivalent estimate even on
- subscription auth, which reads as a real charge. costUsd still accumulates in the
- store — re-enable here once auth-aware display (or a settings toggle) exists. */}
- </div>
- <div className="chat-node__msgs nodrag nowheel" ref={msgsRef}>
- {chat?.messages.map((m, i) => (
- <div key={i} className={`term-chat__msg term-chat__msg--${m.role}`}>
- {m.parts.map((p, j) =>
- p.kind === 'text' ? (
- <MarkdownText key={j} text={p.text} />
- ) : p.kind === 'thinking' ? (
- <details key={j} className="chat-node__thinking"><summary>Thinking</summary><MarkdownText text={p.text} /></details>
- ) : (
- renderTool(p, j, false)
- )
- )}
- </div>
- ))}
- {/* Pre-stream gap: Enter → first SDK event has a noticeable latency (process/network).
- Show a pulsing typing indicator until anything from the turn arrives. */}
- {working &&
- !chat?.streamText &&
- !chat?.streamThinking &&
- (chat?.toolOrder.length ?? 0) === 0 && (
- <div className="chat-node__typing" aria-label="Claude is thinking">
- <span /><span /><span />
- </div>
- )}
- {/* Live turn: streaming thinking + text + tool cards */}
- {chat?.streamThinking && (
- <details className="chat-node__thinking"><summary>Thinking…</summary><MarkdownText text={chat.streamThinking} /></details>
- )}
- {chat?.toolOrder.map((tid) => renderTool(chat.tools[tid], tid, !chat.tools[tid].result))}
- {chat?.streamText && <div className="term-chat__msg term-chat__msg--assistant"><MarkdownText text={chat.streamText} /></div>}
- {/* Non-fatal errors: a dismissible inline line. Fatal errors get the reconnect bar
- in place of the compose box (below). */}
- {chat?.error && !chat.error.fatal && (
- <div className="chat-node__error">
- <span>{chat.error.message}</span>
- <button className="chat-node__error-dismiss" title="Dismiss" onClick={() => clearError(id)}>×</button>
- </div>
- )}
- {perm && (
- <div className="chat-node__permission">
- <div className="chat-node__permission-title">Allow {perm.toolName}?</div>
- <pre className="chat-node__permission-input">{JSON.stringify(perm.input, null, 2).slice(0, 600)}</pre>
- <div className="chat-node__permission-actions">
- <button onClick={() => api.chat.permissionReply(id, perm.requestId, { behavior: 'allow' })}>Allow</button>
- <button onClick={() => api.chat.permissionReply(id, perm.requestId, { behavior: 'allow', alwaysSession: true })}>Always (session)</button>
- <button onClick={() => api.chat.permissionReply(id, perm.requestId, { behavior: 'deny' })}>Deny</button>
- </div>
- </div>
- )}
- </div>
- {chat && chat.queue.length > 0 && (
- <div className="chat-node__queue">
- {chat.queue.map((q) => (
- <span key={q.id} className="chat-node__queue-item">
- {q.text.slice(0, 40)}
- <button onClick={() => api.chat.removeQueued(id, q.id)}>×</button>
- </span>
- ))}
- </div>
- )}
- {(images.length > 0 || attachNote) && (
- <div className="chat-node__attach nodrag">
- {images.map((img, i) => (
- <span key={i} className="chat-node__attach-chip">
- <img src={`data:${img.mediaType};base64,${img.data}`} alt="attachment" />
- <button onClick={() => removeImage(i)}>×</button>
- </span>
- ))}
- {attachNote && <div className="chat-node__attach-note">{attachNote}</div>}
- </div>
- )}
- {chat?.error?.fatal ? (
- <div className="chat-node__errorbar nodrag">
- <span className="chat-node__errorbar-msg">{chat.error.message || 'Chat session ended.'}</span>
- <button
- className="chat-node__errorbar-reconnect"
- onClick={() => {
- clearError(id)
- void api.chat.ensure(id, {
- cwd: data.cwd as string | undefined,
- sessionId: data.chatSessionId as string | undefined,
- accountId: data.accountId as string | undefined
- })
- }}
- >
- Reconnect
- </button>
- </div>
- ) : (
- <div className="chat-node__compose nodrag">
- {slashOpen && (
- <div className="chat-node__slash">
- {slashMatches.map((c, i) => (
- <div
- key={c}
- className={`chat-node__slash-item${i === slashActive ? ' chat-node__slash-item--active' : ''}`}
- onMouseEnter={() => setSlashIdx(i)}
- onMouseDown={(e) => {
- e.preventDefault() // keep focus on the textarea
- completeSlash(c)
- }}
- >
- {c}
- </div>
- ))}
- </div>
- )}
- <textarea
- className="term-chat__input"
- value={input}
- onChange={(e) => onInputChange(e.target.value)}
- onKeyDown={onKeyDown}
- onPaste={onPaste}
- onDrop={onDrop}
- onDragOver={onDragOver}
- placeholder={working ? 'Claude is working — message will queue…' : 'Message Claude… (Enter to send)'}
- rows={2}
- />
- {/* Stop = interrupt: the driver's turn-done then auto-flushes the next queued item (Task 5). */}
- {working && <button className="chat-node__stop" onClick={() => api.chat.interrupt(id)}>Stop</button>}
- </div>
- )}
- </div>
- </>
- )
-}
diff --git a/src/renderer/state/chatSessions.ts b/src/renderer/state/chatSessions.ts
deleted file mode 100644
index 5cac44707..000000000
--- a/src/renderer/state/chatSessions.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-// src/renderer/state/chatSessions.ts
-// Transient per-chat-node conversation state (agentNodes.ts pattern): fed by chat:event
-// IPC, seeded from the on-disk transcript, never persisted (the transcript already is).
-import { create } from 'zustand'
-import type { ChatEvent, ChatMessage } from '@shared/types'
-import { applyChatEvent, emptyChatNodeState, type ChatNodeState } from './chatSessionsCore'
-
-interface ChatSessionsStore {
- byId: Record<string, ChatNodeState>
- apply(nodeId: string, e: ChatEvent): void
- seed(nodeId: string, messages: ChatMessage[]): void
- addLocalUser(nodeId: string, text: string): void
- clearError(nodeId: string): void
- drop(nodeId: string): void
-}
-
-export const useChatSessions = create<ChatSessionsStore>((set) => ({
- byId: {},
- apply: (nodeId, e) =>
- set((st) => ({ byId: { ...st.byId, [nodeId]: applyChatEvent(st.byId[nodeId] ?? emptyChatNodeState, e) } })),
- seed: (nodeId, messages) =>
- set((st) => ({
- byId: { ...st.byId, [nodeId]: { ...(st.byId[nodeId] ?? emptyChatNodeState), messages } }
- })),
- addLocalUser: (nodeId, text) =>
- set((st) => {
- const s = st.byId[nodeId] ?? emptyChatNodeState
- return {
- byId: {
- ...st.byId,
- [nodeId]: { ...s, messages: [...s.messages, { role: 'user', parts: [{ kind: 'text', text }] }] }
- }
- }
- }),
- clearError: (nodeId) =>
- set((st) => {
- const s = st.byId[nodeId]
- if (!s) return {}
- // Clearing the error (Dismiss / Reconnect) must also drop a stale "working" badge and any
- // orphaned permission card left behind by a fatal crash mid-turn — otherwise they survive
- // the reconnect with no live driver behind them.
- return { byId: { ...st.byId, [nodeId]: { ...s, error: undefined, working: false, permission: undefined } } }
- }),
- drop: (nodeId) =>
- set((st) => {
- const byId = { ...st.byId }
- delete byId[nodeId]
- return { byId }
- })
-}))
diff --git a/src/renderer/state/chatSessionsCore.test.ts b/src/renderer/state/chatSessionsCore.test.ts
deleted file mode 100644
index 24a8df76c..000000000
--- a/src/renderer/state/chatSessionsCore.test.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-// src/renderer/state/chatSessionsCore.test.ts
-import { describe, expect, it } from 'vitest'
-import { applyChatEvent, emptyChatNodeState } from './chatSessionsCore'
-
-const s0 = emptyChatNodeState
-
-describe('applyChatEvent', () => {
- it('accumulates deltas into the stream buffers', () => {
- let s = applyChatEvent(s0, { kind: 'delta', block: 'text', text: 'he' })
- s = applyChatEvent(s, { kind: 'delta', block: 'text', text: 'y' })
- s = applyChatEvent(s, { kind: 'delta', block: 'thinking', text: 'hm' })
- expect(s.streamText).toBe('hey')
- expect(s.streamThinking).toBe('hm')
- })
-
- it('message commits and clears the stream buffers (reconcile)', () => {
- let s = applyChatEvent(s0, { kind: 'delta', block: 'text', text: 'partial…' })
- s = applyChatEvent(s, { kind: 'message', msg: { role: 'assistant', parts: [{ kind: 'text', text: 'full' }] } })
- expect(s.streamText).toBe('')
- expect(s.messages.at(-1)?.parts).toEqual([{ kind: 'text', text: 'full' }])
- })
-
- it('tool + tool-result pair up by toolUseId', () => {
- let s = applyChatEvent(s0, { kind: 'tool', toolUseId: 't1', name: 'Bash', arg: 'ls' })
- s = applyChatEvent(s, { kind: 'tool-result', toolUseId: 't1', result: 'ok' })
- expect(s.tools.t1).toMatchObject({ name: 'Bash', result: 'ok' })
- expect(s.toolOrder).toEqual(['t1'])
- })
-
- it('turn-done accumulates cost, clears working + per-turn tool order', () => {
- let s = { ...s0, working: true }
- s = applyChatEvent(s, { kind: 'turn-done', costUsd: 0.1 })
- s = applyChatEvent(s, { kind: 'turn-done', costUsd: 0.05 })
- expect(s.costUsd).toBeCloseTo(0.15)
- expect(s.working).toBe(false)
- expect(s.toolOrder).toEqual([])
- })
-
- it('turn-done folds the turn tools into a committed assistant message, then clears toolOrder', () => {
- let s = applyChatEvent(s0, { kind: 'tool', toolUseId: 't1', name: 'Bash', arg: 'ls', summary: undefined })
- s = applyChatEvent(s, { kind: 'tool', toolUseId: 't2', name: 'Write', arg: '/f.ts', summary: { filePath: '/f.ts', added: 3, removed: 0 } })
- s = applyChatEvent(s, { kind: 'tool-result', toolUseId: 't1', result: 'out' })
- s = applyChatEvent(s, { kind: 'turn-done', costUsd: 0.02 })
- expect(s.toolOrder).toEqual([])
- // A single synthetic assistant message carries both tools in order, preserving result + summary.
- expect(s.messages).toEqual([
- {
- role: 'assistant',
- parts: [
- { kind: 'tool', name: 'Bash', arg: 'ls', result: 'out', summary: undefined },
- { kind: 'tool', name: 'Write', arg: '/f.ts', result: undefined, summary: { filePath: '/f.ts', added: 3, removed: 0 } }
- ]
- }
- ])
- })
-
- it('turn-done with no tools appends no message', () => {
- let s = applyChatEvent(s0, { kind: 'message', msg: { role: 'assistant', parts: [{ kind: 'text', text: 'hi' }] } })
- const before = s.messages
- s = applyChatEvent(s, { kind: 'turn-done', costUsd: 0.01 })
- expect(s.messages).toBe(before)
- expect(s.toolOrder).toEqual([])
- })
-
- it('permission set + cleared', () => {
- let s = applyChatEvent(s0, { kind: 'permission', requestId: 'r1', toolName: 'Bash', input: {} })
- expect(s.permission?.requestId).toBe('r1')
- s = applyChatEvent(s, { kind: 'permission-done', requestId: 'r1' })
- expect(s.permission).toBeUndefined()
- })
-
- it('session stores id + slash commands; queue replaces; error stores', () => {
- let s = applyChatEvent(s0, { kind: 'session', sessionId: 'abc', slashCommands: ['/compact'] })
- s = applyChatEvent(s, { kind: 'queue', items: [{ id: 'q-1', text: 'next' }] })
- s = applyChatEvent(s, { kind: 'error', message: 'boom', fatal: true })
- expect(s.sessionId).toBe('abc')
- expect(s.slashCommands).toEqual(['/compact'])
- expect(s.queue).toEqual([{ id: 'q-1', text: 'next' }])
- expect(s.error).toEqual({ message: 'boom', fatal: true })
- })
-})
diff --git a/src/renderer/state/chatSessionsCore.ts b/src/renderer/state/chatSessionsCore.ts
deleted file mode 100644
index 7329a5a89..000000000
--- a/src/renderer/state/chatSessionsCore.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-// src/renderer/state/chatSessionsCore.ts
-// Pure reducer for chat node state — kept out of the zustand store so it's unit-testable
-// (same split as noteLink.ts / agentNodes patterns).
-import type { ChatEvent, ChatMessage, ChatQueueItem, ChatToolSummary } from '@shared/types'
-
-export interface ChatNodeState {
- messages: ChatMessage[]
- streamText: string
- streamThinking: string
- tools: Record<string, { name: string; arg: string; summary?: ChatToolSummary; result?: string }>
- toolOrder: string[]
- queue: ChatQueueItem[]
- permission?: { requestId: string; toolName: string; input: unknown }
- slashCommands: string[]
- sessionId?: string
- costUsd: number
- working: boolean
- error?: { message: string; fatal?: boolean }
-}
-
-export const emptyChatNodeState: ChatNodeState = {
- messages: [], streamText: '', streamThinking: '', tools: {}, toolOrder: [],
- queue: [], slashCommands: [], costUsd: 0, working: false
-}
-
-export function applyChatEvent(s: ChatNodeState, e: ChatEvent): ChatNodeState {
- switch (e.kind) {
- case 'session':
- return { ...s, sessionId: e.sessionId, slashCommands: e.slashCommands }
- case 'delta':
- return e.block === 'text'
- ? { ...s, streamText: s.streamText + e.text, working: true }
- : { ...s, streamThinking: s.streamThinking + e.text, working: true }
- case 'message':
- // The completed assistant message is authoritative — replace the delta-built buffer.
- return { ...s, messages: [...s.messages, e.msg], streamText: '', streamThinking: '' }
- case 'tool':
- return {
- ...s,
- tools: { ...s.tools, [e.toolUseId]: { name: e.name, arg: e.arg, summary: e.summary } },
- toolOrder: [...s.toolOrder, e.toolUseId]
- }
- case 'tool-result': {
- const t = s.tools[e.toolUseId]
- if (!t) return s
- return { ...s, tools: { ...s.tools, [e.toolUseId]: { ...t, result: e.result } } }
- }
- case 'permission':
- return { ...s, permission: { requestId: e.requestId, toolName: e.toolName, input: e.input } }
- case 'permission-done':
- return s.permission?.requestId === e.requestId ? { ...s, permission: undefined } : s
- case 'turn-done': {
- // Tool calls stream as live cards (toolOrder) but the completed 'message' event carries
- // only text/thinking. Before clearing toolOrder at turn end, fold this turn's tools into
- // committed history as a synthetic assistant message so the cards (incl. diff-preview
- // links) survive the turn instead of vanishing until a transcript reload.
- const committed: ChatMessage[] =
- s.toolOrder.length > 0
- ? [
- {
- role: 'assistant',
- parts: s.toolOrder.map((id) => {
- const t = s.tools[id]
- return { kind: 'tool', name: t.name, arg: t.arg, result: t.result, summary: t.summary }
- })
- }
- ]
- : []
- return {
- ...s,
- messages: committed.length ? [...s.messages, ...committed] : s.messages,
- working: false, toolOrder: [], streamText: '', streamThinking: '',
- costUsd: s.costUsd + (e.costUsd ?? 0)
- }
- }
- case 'queue':
- return { ...s, queue: e.items }
- case 'error':
- return { ...s, error: { message: e.message, fatal: e.fatal } }
- }
-}
diff --git a/src/renderer/state/workspace.chat.test.ts b/src/renderer/state/workspace.chat.test.ts
deleted file mode 100644
index 5e3d6eaa9..000000000
--- a/src/renderer/state/workspace.chat.test.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-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.test.ts b/src/renderer/state/workspace.test.ts
index bf3a7c3c5..1a9464b48 100644
--- a/src/renderer/state/workspace.test.ts
+++ b/src/renderer/state/workspace.test.ts
@@ -2,7 +2,6 @@ import { describe, it, expect } from 'vitest'
import {
createAccountLoginNode,
createAgentNode,
- createChatNode,
createDinoNode,
flowToNodeStates,
groupSelectedNodes,
@@ -229,10 +228,6 @@ describe('accountId on Claude node factories', () => {
const node = createAgentNode('claude', 0)
expect(node.data.accountId).toBeUndefined()
})
- it('stamps accountId onto a chat node', () => {
- const node = createChatNode(0, undefined, undefined, undefined, 'a1')
- expect(node.data.accountId).toBe('a1')
- })
})
describe('accountId serialization', () => {
@@ -297,6 +292,29 @@ describe('dino node serialization', () => {
})
})
+describe('chat node tombstone', () => {
+ it('converts a persisted chat node into a sticky with the resume hint', () => {
+ const flow = nodeStatesToFlow([
+ {
+ id: 'chat-1', kind: 'chat', x: 10, y: 20, width: 420, height: 520,
+ title: 'API brainstorm', color: '#8b5cf6', chatSessionId: 'sess-abc123'
+ } as any
+ ])
+ expect(flow).toHaveLength(1)
+ const n = flow[0]
+ expect(n.type).toBe('sticky')
+ expect(n.position).toEqual({ x: 10, y: 20 })
+ expect(n.data.title).toBe('API brainstorm')
+ expect(String(n.data.text)).toContain('claude --resume sess-abc123')
+ })
+ it('converts a chat node without a session id into a plain explanatory sticky', () => {
+ const flow = nodeStatesToFlow([{ id: 'chat-2', kind: 'chat', x: 0, y: 0 } as any])
+ expect(flow[0].type).toBe('sticky')
+ expect(String(flow[0].data.text)).toContain('removed')
+ expect(String(flow[0].data.text)).not.toContain('--resume')
+ })
+})
+
describe('createAgentNode permission mode', () => {
it('appends the flag for claude', () => {
const node = createAgentNode('claude', 0, undefined, undefined, undefined, undefined, undefined, 'auto')
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index e6b4be633..e8b43063b 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -35,7 +35,6 @@ 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
@@ -107,16 +106,6 @@ 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
}
@@ -534,34 +523,6 @@ 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 },
- accountId?: 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,
- // Chat nodes are always Claude — stamp the account when one was resolved/inherited.
- ...(accountId ? { accountId } : {}),
- ...(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,
@@ -918,7 +879,28 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {
if ((a.kind === 'group') === (b.kind === 'group')) return 0
return a.kind === 'group' ? -1 : 1
})
- return ordered.map((n) => {
+ return ordered.map((raw) => {
+ // The SDK chat node was removed (2026-07). A persisted chat node degrades into a sticky that
+ // keeps its place and tells the user how to continue the conversation — chat sessions are
+ // 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}`
+ : ''
+ n = {
+ ...n,
+ kind: 'sticky',
+ position: n.position ?? { x: (n as { x?: number }).x ?? 0, y: (n as { y?: number }).y ?? 0 },
+ size: n.size ?? {
+ 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
+ }
+ }
const collapsed = !!n.collapsed
const height = collapsed ? COLLAPSED_HEIGHT : n.size.height
// Legacy migration: nodes saved before `agentId` existed marked Claude via the 'claude'
@@ -958,8 +940,7 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {
ssh: n.ssh,
sshRemoteTmux: n.sshRemoteTmux,
sshFs: n.sshFs,
- worktree: n.worktree,
- chatSessionId: n.chatSessionId
+ worktree: n.worktree
}
}
})
@@ -984,9 +965,7 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {
? WEB_SIZE
: kind === 'dino'
? DINO_SIZE
- : kind === 'chat'
- ? CHAT_SIZE
- : TERMINAL_SIZE
+ : TERMINAL_SIZE
return nodes
.map((n) => {
const kind: NodeKind = (n.type as NodeKind) ?? 'terminal'
@@ -1023,8 +1002,7 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {
ssh: n.data.ssh,
sshRemoteTmux: n.data.sshRemoteTmux,
sshFs: n.data.sshFs,
- worktree: n.data.worktree,
- chatSessionId: n.data.chatSessionId
+ worktree: n.data.worktree
}
})
}
@@ -1038,7 +1016,7 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {
* every peer mutation — 20 times a second while a teammate drags:
* - SELECTION. `nodeStatesToFlow` never sets `selected`, so a teammate's drag wiped your
* box-select / shift-click / select-then-group the instant it landed.
- * - LOCAL-ONLY DATA. `initialCommand`, `respawnNonce`, `forkFrom` never survive a serialize.
+ * - LOCAL-ONLY DATA. `initialCommand`, `respawnNonce` never survive a serialize.
* - IDENTITY. Every node object was rebuilt → every node component re-rendered, per mutation.
* Patching in place keeps all four: untouched nodes keep their object identity (React.memo holds),
* and the touched one keeps `selected` and its local-only data.
@@ -1068,7 +1046,7 @@ export function applyMutationToFlow(nodes: CanvasNode[], m: CanvasMutation): Can
next[idx] = {
...incoming,
selected: prev.selected,
- // Local-only data (initialCommand / respawnNonce / remote / forkFrom) is not serialized, so it
+ // Local-only data (initialCommand / respawnNonce / remote) is not serialized, so it
// is not in `incoming` — carry it. Every serialized key IS present on incoming.data (as a value
// or an explicit undefined), so the spread still applies the peer's clears.
//