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(claude): busy indicator, unread badge, completion notification
enesbf666af77570
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex e718afe16..3dc8cf34d 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -50,6 +50,7 @@ import { ConfirmDialog } from '../components/ConfirmDialog'import { ExplorerPanel } from '../components/ExplorerPanel'import { transport } from '../terminal/local-transport'import { useProjects } from '../state/projects'+import { useClaudeStatus } from '../state/claudeStatus'import { useSettings } from '../state/settings'import {COLLAPSED_HEIGHT,@@ -79,6 +80,8 @@ export function Canvas() {const [shortcutsOpen, setShortcutsOpen] = useState(false)const [explorerOpen, setExplorerOpen] = useState(false)const [confirm, setConfirm] = useState<{ message: string; onConfirm: () => void } | null>(null)+ // Node to center once its project finishes loading (cross-project notification click).+ const pendingFocusRef = useRef<string | null>(null)const settings = useSettings((s) => s.settings)const viewportRef = useRef<Viewport>({ x: 0, y: 0, zoom: 1 })const nodesRef = useRef<CanvasNode[]>(nodes)@@ -150,8 +153,20 @@ export function Canvas() {// Let load-induced changes settle before we start tracking edits as dirty.const t = setTimeout(() => {loadingRef.current = false+ // Consume a cross-project focus request (notification click on a background node).+ const pending = pendingFocusRef.current+ if (pending) {+ pendingFocusRef.current = null+ const node = nodesRef.current.find((n) => n.id === pending)+ if (node) {+ setNodes((ns) => ns.map((n) => ({ ...n, selected: n.id === pending })))+ goToNode(node)+ useClaudeStatus.getState().clearUnread(pending)+ }+ }}, 0)return () => clearTimeout(t)+ // eslint-disable-next-line react-hooks/exhaustive-deps}, [activeProjectId, setNodes, setViewport])const markDirty = useCallback(() => {@@ -691,6 +706,46 @@ export function Canvas() {[commitActiveToStore, writeDisk])+ // Focus a node by id (notification click): select + center it; if it lives in another+ // project, switch there first and let the project-load effect finish the focus.+ const focusNodeById = useCallback(+ (nodeId: string) => {+ const node = nodesRef.current.find((n) => n.id === nodeId)+ if (node) {+ setNodes((ns) => ns.map((n) => ({ ...n, selected: n.id === nodeId })))+ goToNode(node)+ useClaudeStatus.getState().clearUnread(nodeId)+ return+ }+ const owner = useProjects+ .getState()+ .projects.find((p) => p.nodes.some((n) => n.id === nodeId))+ if (owner && owner.id !== useProjects.getState().activeProjectId) {+ pendingFocusRef.current = nodeId+ switchProject(owner.id)+ }+ },+ [setNodes, goToNode, switchProject]+ )++ useEffect(() => window.nodeTerminal.onFocusNode(focusNodeById), [focusNodeById])++ // One-time consent: the first time a Claude turn finishes in the background, ask whether+ // to enable completion notifications (default off until accepted).+ const anyUnread = useClaudeStatus((s) => Object.values(s.byId).some((v) => v.unread))+ const notifyConsentAsked = useSettings((s) => s.settings.notifyConsentAsked)+ useEffect(() => {+ if (!anyUnread || notifyConsentAsked) return+ useSettings.getState().update({ notifyConsentAsked: true, notifyOnClaudeDone: false })+ setConfirm({+ message: 'Notify you when Claude Code finishes while nodeterm is in the background?',+ onConfirm: () => {+ useSettings.getState().update({ notifyOnClaudeDone: true })+ setConfirm(null)+ }+ })+ }, [anyUnread, notifyConsentAsked])+const addProject = useCallback(() => {commitActiveToStore()const project = useProjects.getState().addProject()@@ -878,7 +933,12 @@ export function Canvas() {zoomablemaskColor="rgba(10,12,18,0.6)"nodeColor={(n) => (n.data as { color?: string })?.color ?? '#0a84ff'}- nodeStrokeColor={(n) => (n.data as { color?: string })?.color ?? '#0a84ff'}+ nodeStrokeColor={(n) => {+ const st = useClaudeStatus.getState().byId[n.id]+ if (st?.busy) return '#30d158'+ if (st?.unread) return '#0a84ff'+ return (n.data as { color?: string })?.color ?? '#0a84ff'+ }}/></ReactFlow>diff --git a/src/renderer/components/SettingsPanel.tsx b/src/renderer/components/SettingsPanel.tsxindex 7e9db6d70..46af602c8 100644--- a/src/renderer/components/SettingsPanel.tsx+++ b/src/renderer/components/SettingsPanel.tsx@@ -106,6 +106,20 @@ export function SettingsPanel({ onClose }: SettingsPanelProps) {</label></section>+ <section>+ <h3>Claude Code</h3>+ <label className="set-row">+ <span>Notify when a turn finishes in the background</span>+ <input+ type="checkbox"+ checked={settings.notifyOnClaudeDone}+ onChange={(e) =>+ update({ notifyOnClaudeDone: e.target.checked, notifyConsentAsked: true })+ }+ />+ </label>+ </section>+<section><h3>Appearance</h3><div className="set-row">diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsxindex 06c1bf741..e89701c95 100644--- a/src/renderer/components/TabBar.tsx+++ b/src/renderer/components/TabBar.tsx@@ -1,6 +1,7 @@import { useState } from 'react'import { createPortal } from 'react-dom'import { useProjects } from '../state/projects'+import { useClaudeStatus } from '../state/claudeStatus'interface TabBarProps {onSwitch: (id: string) => void@@ -27,6 +28,7 @@ export function TabBar({}: TabBarProps) {const projects = useProjects((s) => s.projects)const activeId = useProjects((s) => s.activeProjectId)+ const statusById = useClaudeStatus((s) => s.byId)const [menuId, setMenuId] = useState<string | null>(null)const [menuPos, setMenuPos] = useState<{ top: number; left: number } | null>(null)const [addPos, setAddPos] = useState<{ top: number; left: number } | null>(null)@@ -100,17 +102,18 @@ export function TabBar({<div className="tabbar__tabs">{projects.map((p) => {const active = p.id === activeId+ const hasUnread = !active && p.nodes.some((n) => statusById[n.id]?.unread)return (<divkey={p.id}- className={`tab${active ? ' active' : ''}`}+ className={`tab${active ? ' active' : ''}${hasUnread ? ' has-unread' : ''}`}style={active ? { color: p.color } : undefined}onClick={() => !editingId && onSwitch(p.id)}title={p.cwd || undefined}><spanclassName="tab__dot"- style={{ background: active ? p.color : 'rgba(255,255,255,0.3)' }}+ style={active ? { background: p.color } : undefined}/>{editingId === p.id ? (<inputdiff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex c4eca401e..f695ed052 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -8,6 +8,8 @@ import { patchTerminalScale } from '../terminal/scale-fix'import { NodeTags } from '../components/NodeTags'import { Tooltip } from '../components/Tooltip'import { useSettings } from '../state/settings'+import { useClaudeStatus } from '../state/claudeStatus'+import { createClaudeBusyDetector } from '../terminal/claudeBusy'import { COLLAPSED_HEIGHT, NODE_COLORS, type CanvasNode } from '../state/workspace'/**@@ -32,6 +34,11 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {const mdMode = !!data.mdModeconst collapsed = !!data.collapsedconst tags = (data.tags as string[]) ?? []+ const isClaude = tags.includes('claude')+ const status = useClaudeStatus((s) => s.byId[id])+ // Latest data for use inside the once-only lifecycle effect (avoids stale closures).+ const dataRef = useRef(data)+ dataRef.current = data// Terminal lifecycle — set up exactly once.useEffect(() => {@@ -58,6 +65,30 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {let disposed = falseconst cleanups: Array<() => void> = []+ // Claude Code nodes: watch the output for working/idle transitions.+ const onBusyChange = (busy: boolean) => {+ const cs = useClaudeStatus.getState()+ cs.setBusy(id, busy)+ // On a turn finishing while the user isn't looking: mark unread + (maybe) notify.+ // Notifications only fire once consent has been given (Canvas shows a one-time prompt+ // the first time a background completion happens).+ if (!busy && !document.hasFocus()) {+ cs.markUnread(id)+ const s = useSettings.getState().settings+ if (s.notifyOnClaudeDone && s.notifyConsentAsked) {+ void window.nodeTerminal.notify({+ title: 'Claude Code finished',+ body: dataRef.current.title || 'Claude Code',+ nodeId: id+ })+ }+ }+ }+ const detector = isClaude+ ? createClaudeBusyDetector((busy) => onBusyChange(busy))+ : null+ if (detector) cleanups.push(term.onBell(() => detector.bell()).dispose)+transport.create({ cols: term.cols, rows: term.rows, shell: data.shell, cwd: data.cwd, persistKey: id }).then((sid) => {@@ -66,7 +97,12 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {return}sessionId = sid- cleanups.push(transport.onData(sid, (chunk) => term.write(chunk)))+ cleanups.push(+ transport.onData(sid, (chunk) => {+ term.write(chunk)+ detector?.feed(chunk)+ })+ )cleanups.push(transport.onExit(sid, (code) => {term.write(`\r\n\x1b[90m[process exited with code ${code}]\x1b[0m\r\n`)@@ -96,6 +132,8 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {observer.disconnect()if (dwellRef.current) clearTimeout(dwellRef.current)cleanups.forEach((fn) => fn())+ detector?.dispose()+ if (isClaude) useClaudeStatus.getState().remove(id)if (sessionId) transport.kill(sessionId)term.dispose()termRef.current = null@@ -141,6 +179,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {dwellRef.current = setTimeout(() => {setArmed(false)termRef.current?.focus()+ if (isClaude) useClaudeStatus.getState().clearUnread(id)}, settings.panHoverDelay)}const onBodyLeave = () => {@@ -161,6 +200,11 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {if (r.ok) updateNodeData(id, { title: r.message })}+ // Selecting a Claude node clears its unread badge.+ useEffect(() => {+ if (isClaude && selected) useClaudeStatus.getState().clearUnread(id)+ }, [isClaude, selected, id])+// Cmd/Ctrl+M toggles markdown view of this terminal's output (only when hovered).useEffect(() => {return window.nodeTerminal.onMarkdownToggle(() => {@@ -229,6 +273,18 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {{data.title || 'Untitled'}</span>)}+ {isClaude && status?.busy && (+ <span className="term-node__status term-node__status--busy" title="Claude is working">+ <span className="term-node__status-dot" />+ RUNNING+ </span>+ )}+ {isClaude && !status?.busy && status?.unread && (+ <span+ className="term-node__status term-node__status--unread"+ title="Finished — click to mark read"+ />+ )}{!editingTitle && <span className="term-node__spacer" />}<Tooltip label="Name with AI (from terminal output)"><button className="term-node__ai nodrag" disabled={naming} onClick={nameWithAi}>diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex cb6218cc2..2e7358839 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -132,6 +132,13 @@ body,height: 9px;border-radius: 50%;flex-shrink: 0;+ background: rgba(255, 255, 255, 0.3);+}++/* A background project with an unread Claude completion. */+.tab.has-unread .tab__dot {+ background: var(--accent);+ box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.25);}.tab__name {@@ -454,6 +461,51 @@ body,flex: 1;}+/* Claude Code status: RUNNING badge while working, unread dot when finished. */+.term-node__status {+ display: inline-flex;+ align-items: center;+ gap: 5px;+ margin-left: 8px;+ flex-shrink: 0;+ font-size: 9.5px;+ font-weight: 700;+ letter-spacing: 0.06em;+ color: #30d158;+}++.term-node__status-dot {+ width: 7px;+ height: 7px;+ border-radius: 50%;+ background: currentColor;+}++.term-node__status--busy .term-node__status-dot {+ animation: nt-pulse 1.1s ease-in-out infinite;+}++.term-node__status--unread {+ margin-left: 8px;+ width: 8px;+ height: 8px;+ border-radius: 50%;+ background: var(--accent);+ box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.22);+}++@keyframes nt-pulse {+ 0%,+ 100% {+ opacity: 1;+ transform: scale(1);+ }+ 50% {+ opacity: 0.35;+ transform: scale(0.7);+ }+}+.tooltip-trigger {display: inline-flex;}diff --git a/src/renderer/terminal/claudeBusy.ts b/src/renderer/terminal/claudeBusy.tsnew file mode 100644index 000000000..767c5373d--- /dev/null+++ b/src/renderer/terminal/claudeBusy.ts@@ -0,0 +1,59 @@+// Detects whether a Claude Code session is actively working, from its terminal output.+//+// Signals (layered, so it works regardless of which ones a given Claude build emits):+// - PRIMARY: the working line Claude redraws each frame while a turn runs — it contains+// "esc to interrupt" plus a spinner glyph. While that keeps appearing we stay "busy".+// - COMPLETION: when the working line stops appearing for IDLE_MS, we flip to idle. A+// terminal bell (if Claude rings one on turn end) shortens that wait.+// We test the raw chunk: "esc to interrupt" is contiguous ASCII (ANSI color codes wrap the+// whole line, not the phrase), so no escape-sequence stripping is needed. If Claude changes+// its UI wording, update WORKING below — it's the single source of truth.++const WORKING =+ /esc to interrupt|[✶✻✽✺✳✢⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]\s|\b(?:Working|Thinking|Forging|Cogitating|Pondering|Brewing|Herding|Simmering|Spelunking|Reticulating)…?/i++const IDLE_MS = 1500+const BELL_IDLE_MS = 400++export interface ClaudeBusyDetector {+ /** Feed a raw output chunk. */+ feed(chunk: string): void+ /** Call when the terminal bell fires. */+ bell(): void+ dispose(): void+}++export function createClaudeBusyDetector(+ onChange: (busy: boolean) => void+): ClaudeBusyDetector {+ let busy = false+ let idleTimer: ReturnType<typeof setTimeout> | null = null++ const setBusy = (b: boolean) => {+ if (b === busy) return+ busy = b+ onChange(b)+ }++ const armIdle = (ms = IDLE_MS) => {+ if (idleTimer) clearTimeout(idleTimer)+ idleTimer = setTimeout(() => setBusy(false), ms)+ }++ return {+ feed(chunk) {+ if (WORKING.test(chunk)) {+ setBusy(true)+ armIdle()+ }+ },+ bell() {+ // A bell usually marks the end of a turn; flip to idle soon (unless work resumes).+ if (busy) armIdle(BELL_IDLE_MS)+ },+ dispose() {+ if (idleTimer) clearTimeout(idleTimer)+ idleTimer = null+ }+ }+}