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.

refactor(agents): rename claudeStatus store to agentStatus (+agentId, ls migrate)

enes445844606140
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 93066a487..1736b4330 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -57,7 +57,7 @@ import { ExplorerPanel } from '../components/ExplorerPanel'
import { UsageIndicator } from '../components/UsageIndicator'
import { transport } from '../terminal/local-transport'
import { useProjects } from '../state/projects'
-import { useClaudeStatus } from '../state/claudeStatus'
+import { useAgentStatus } from '../state/agentStatus'
import { useAgentNodes } from '../state/agentNodes'
import { SubagentNode } from '../nodes/SubagentNode'
import { LoopNode } from '../nodes/LoopNode'
@@ -158,7 +158,7 @@ export function Canvas() {
const ephemeralPos = useAgentNodes((s) => s.positions)
const ephSizes = useAgentNodes((s) => s.sizes)
const ephExpanded = useAgentNodes((s) => s.expanded)
- const claudeById = useClaudeStatus((s) => s.byId)
+ const claudeById = useAgentStatus((s) => s.byId)
// Selection state for ephemeral nodes (they live outside React Flow's managed nodes).
const [ephSel, setEphSel] = useState<Record<string, boolean>>({})
const { ephemeralNodes, ephemeralEdges } = useMemo(() => {
@@ -361,7 +361,7 @@ export function Canvas() {
if (node) {
setNodes((ns) => ns.map((n) => ({ ...n, selected: n.id === pending })))
goToNode(node)
- useClaudeStatus.getState().clearUnread(pending)
+ useAgentStatus.getState().clearUnread(pending)
}
}
}, 0)
@@ -844,7 +844,7 @@ export function Canvas() {
async (nodeId: string) => {
const source = nodesRef.current.find((n) => n.id === nodeId) as CanvasNode | undefined
if (!source) return
- const known = useClaudeStatus.getState().byId[nodeId]?.sessionId
+ const known = useAgentStatus.getState().byId[nodeId]?.sessionId
let originalId = known
if (known) {
await window.nodeTerminal.pty.sendText(nodeId, '/branch')
@@ -1139,7 +1139,7 @@ export function Canvas() {
if (node) {
setNodes((ns) => ns.map((n) => ({ ...n, selected: n.id === nodeId })))
goToNode(node)
- useClaudeStatus.getState().clearUnread(nodeId)
+ useAgentStatus.getState().clearUnread(nodeId)
return
}
const owner = useProjects
@@ -1183,7 +1183,7 @@ export function Canvas() {
return t.length <= max ? t : `${t.slice(0, max - 1)}…`
}
return window.nodeTerminal.onClaudeStatus((e) => {
- const cs = useClaudeStatus.getState()
+ const cs = useAgentStatus.getState()
if (e.sessionId) cs.setSessionId(e.nodeId, e.sessionId)
// REF-style: "<folder> — Claude finished" + last assistant message as the body.
const alert = (statusText: string, fallbackBody: string) => {
@@ -1389,7 +1389,7 @@ export function Canvas() {
run: () => switchProject(p.id)
})
)
- const cs = useClaudeStatus.getState()
+ const cs = useAgentStatus.getState()
nodesRef.current
.filter((n) => n.type !== 'group')
.forEach((n) => {
@@ -1514,7 +1514,7 @@ export function Canvas() {
maskColor="rgba(10,12,18,0.6)"
nodeColor={(n) => (n.data as { color?: string })?.color ?? '#0a84ff'}
nodeStrokeColor={(n) => {
- const st = useClaudeStatus.getState().byId[n.id]
+ const st = useAgentStatus.getState().byId[n.id]
if (st?.state === 'working') return '#30d158'
if (st?.state === 'waiting' || st?.state === 'blocked') return '#ff9f0a'
if (st?.unread) return '#0a84ff'
diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsx
index 14b6f6740..d7b59eb10 100644
--- a/src/renderer/components/TabBar.tsx
+++ b/src/renderer/components/TabBar.tsx
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { createPortal } from 'react-dom'
import { useProjects } from '../state/projects'
-import { useClaudeStatus } from '../state/claudeStatus'
+import { useAgentStatus } from '../state/agentStatus'
interface TabBarProps {
onSwitch: (id: string) => void
@@ -28,7 +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 statusById = useAgentStatus((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)
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index ce37a05dd..6d5d67e33 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -16,7 +16,7 @@ import { NodeTags } from '../components/NodeTags'
import { Tooltip } from '../components/Tooltip'
import { ContextMeter } from '../components/ContextMeter'
import { useSettings } from '../state/settings'
-import { useClaudeStatus } from '../state/claudeStatus'
+import { useAgentStatus } from '../state/agentStatus'
import { useAgentNodes } from '../state/agentNodes'
import { COLLAPSED_HEIGHT, NODE_COLORS, type CanvasNode } from '../state/workspace'
@@ -55,7 +55,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
const collapsed = !!data.collapsed
const tags = (data.tags as string[]) ?? []
const isClaude = tags.includes('claude')
- const status = useClaudeStatus((s) => s.byId[id])
+ const status = useAgentStatus((s) => s.byId[id])
const updateNodeInternals = useUpdateNodeInternals()
// The bridge handles are added/positioned dynamically for Claude nodes; make React Flow
@@ -109,7 +109,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
term.onTitleChange((t) => {
const title = t.trim()
// Ignore path/prompt-like titles (e.g. "user@host: ~/dir") which aren't session names.
- if (title && !/[/:~]/.test(title)) useClaudeStatus.getState().setSession(id, title)
+ if (title && !/[/:~]/.test(title)) useAgentStatus.getState().setSession(id, title)
}).dispose
)
}
@@ -174,8 +174,8 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
observer.disconnect()
if (dwellRef.current) clearTimeout(dwellRef.current)
cleanups.forEach((fn) => fn())
- useClaudeStatus.getState().setActive(id, false)
- useClaudeStatus.getState().remove(id)
+ useAgentStatus.getState().setActive(id, false)
+ useAgentStatus.getState().remove(id)
useAgentNodes.getState().clearForParent(id)
if (sessionId) transport.kill(sessionId)
term.dispose()
@@ -222,15 +222,15 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
dwellRef.current = setTimeout(() => {
setArmed(false)
termRef.current?.focus()
- useClaudeStatus.getState().setActive(id, true)
- useClaudeStatus.getState().clearUnread(id)
+ useAgentStatus.getState().setActive(id, true)
+ useAgentStatus.getState().clearUnread(id)
}, panHoverDelay)
}
const onBodyLeave = () => {
if (dwellRef.current) clearTimeout(dwellRef.current)
setArmed(true)
termRef.current?.blur()
- useClaudeStatus.getState().setActive(id, false)
+ useAgentStatus.getState().setActive(id, false)
}
// While armed, a mousedown might start a node drag — pause the dwell timer so the
// terminal doesn't grab focus mid-drag; restart it on release.
@@ -267,7 +267,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
setArmed(false)
term.focus()
term.paste(paths.join(' ') + ' ')
- useClaudeStatus.getState().setActive(id, true)
+ useAgentStatus.getState().setActive(id, true)
}
const nameWithAi = async () => {
@@ -279,7 +279,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
// Selecting a node clears its unread badge.
useEffect(() => {
- if (selected) useClaudeStatus.getState().clearUnread(id)
+ if (selected) useAgentStatus.getState().clearUnread(id)
}, [selected, id])
// Cmd/Ctrl+M toggles markdown view of this terminal's output (only when hovered).
diff --git a/src/renderer/state/claudeStatus.ts b/src/renderer/state/agentStatus.ts
similarity index 83%
rename from src/renderer/state/claudeStatus.ts
rename to src/renderer/state/agentStatus.ts
index 3b8533b31..045d43dfb 100644
--- a/src/renderer/state/claudeStatus.ts
+++ b/src/renderer/state/agentStatus.ts
@@ -1,7 +1,8 @@
import { create } from 'zustand'
+import type { AgentId } from '@shared/agents/config'
/**
- * Transient per-node status for Claude Code sessions, driven by Claude's hooks.
+ * Transient per-node status for agent (e.g. Claude Code) sessions, driven by the agent's hooks.
* `unread`, `session` and `sessionId` are persisted to localStorage so they survive a
* reload/restart; the live `state` (working/waiting/…) is not (it'd be stale on relaunch).
*/
@@ -10,6 +11,8 @@ export type ClaudeState = 'working' | 'waiting' | 'blocked' | 'done'
export interface ClaudeNodeStatus {
/** Live activity; undefined = idle/unknown. */
state?: ClaudeState
+ /** Which agent this node is running (claude/codex/gemini/…), when known. */
+ agentId?: AgentId
/** A turn finished / needs attention while the user wasn't looking. */
unread: boolean
/** Claude's own session name/title (from the terminal title), shown beside the title. */
@@ -34,7 +37,7 @@ interface ClaudeStatusState {
/** The terminal node the user is currently focused in (for unread decisions). */
activeId: string | null
setActive(id: string, active: boolean): void
- setState(id: string, state: ClaudeState | undefined): void
+ setState(id: string, state: ClaudeState | undefined, agentId?: AgentId): void
setSession(id: string, session: string): void
setSessionId(id: string, sessionId: string): void
markUnread(id: string): void
@@ -52,7 +55,18 @@ interface ClaudeStatusState {
}
const EMPTY: ClaudeNodeStatus = { unread: false }
-const KEY = 'nodeterm.claudeStatus'
+const KEY = 'nodeterm.agentStatus'
+
+// One-time localStorage migration from the old key. Runs before the store hydrates.
+const LEGACY_KEY = 'nodeterm.claudeStatus'
+try {
+ if (!localStorage.getItem(KEY)) {
+ const legacy = localStorage.getItem(LEGACY_KEY)
+ if (legacy) localStorage.setItem(KEY, legacy)
+ }
+} catch {
+ /* ignore */
+}
function load(): Record<string, ClaudeNodeStatus> {
try {
@@ -84,7 +98,7 @@ function save(byId: Record<string, ClaudeNodeStatus>): void {
}
}
-export const useClaudeStatus = create<ClaudeStatusState>((set) => ({
+export const useAgentStatus = create<ClaudeStatusState>((set) => ({
byId: load(),
activeId: null,
@@ -94,11 +108,13 @@ export const useClaudeStatus = create<ClaudeStatusState>((set) => ({
return s.activeId === id ? { activeId: null } : s
}),
- setState: (id, state) =>
+ setState: (id, state, agentId) =>
set((s) => {
const prev = s.byId[id] ?? EMPTY
- if (prev.state === state) return s
- return { byId: { ...s.byId, [id]: { ...prev, state } } }
+ if (prev.state === state && (agentId === undefined || prev.agentId === agentId)) return s
+ const next = { ...prev, state }
+ if (agentId !== undefined) next.agentId = agentId
+ return { byId: { ...s.byId, [id]: next } }
}),
setSession: (id, session) =>