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
fix(kanban): report live-canvas node writes that find no node, and a failed icon picker
Mina Sameh72977203fa5f
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 123f13fd0..c5a53b999 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -8832,6 +8832,7 @@ export function Canvas() {createNodeWriteRouter({isLive: () =>liveCanvasHolds(nodesProjectIdRef.current, useProjects.getState().activeProjectId, projectId),+ liveHas: (nodeId) => nodesRef.current.some((n) => n.id === nodeId),live: { setColor: setNodesColor, setIcon: setNodeIcon, pickIcon: pickNodeIcon },storedNode: (nodeId) =>useProjects.getState().getProject(projectId)?.nodes.find((n) => n.id === nodeId),diff --git a/src/renderer/components/kanban/KanbanView.tsx b/src/renderer/components/kanban/KanbanView.tsxindex 79807c101..b07efaf48 100644--- a/src/renderer/components/kanban/KanbanView.tsx+++ b/src/renderer/components/kanban/KanbanView.tsx@@ -150,7 +150,7 @@ export interface KanbanViewProps {/*** "Start with agent ▸" rows for a GitHub issue card — the canvas's own agent + account picker* (`agentCreationEntries`), pointed at starting a bound session on that issue. Optional for the- * same reason as `accountMenuItems`: a board with no canvas behind it offers none.+ * same reason as `nodeActionItems`: a board with no canvas behind it offers none.*/issueAgentMenu?: (issue: GitHubIssueCardView) => MenuItem[]/**diff --git a/src/renderer/lib/nodeWriteRouter.test.ts b/src/renderer/lib/nodeWriteRouter.test.tsindex 56c733d91..281c40b51 100644--- a/src/renderer/lib/nodeWriteRouter.test.ts+++ b/src/renderer/lib/nodeWriteRouter.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from 'vitest'import type { CanvasNodeState } from '@shared/types'import {createNodeWriteRouter,+ ICON_PICKER_FAILED_MESSAGE,NODE_GONE_MESSAGE,SAVE_FAILED_MESSAGE,type NodeWriteRouterDeps@@ -13,6 +14,7 @@ const flush = (): Promise<void> => new Promise((r) => setTimeout(r, 0))function deps(over: Partial<NodeWriteRouterDeps> = {}): NodeWriteRouterDeps {return {isLive: () => false,+ liveHas: (id) => id === 'n1',live: { setColor: vi.fn(), setIcon: vi.fn(), pickIcon: vi.fn() },storedNode: (id) => (id === 'n1' ? stored('n1') : undefined),recolorStored: vi.fn(),@@ -75,4 +77,33 @@ describe('createNodeWriteRouter', () => {await flush()expect(d.setStoredIcon).not.toHaveBeenCalled()})++ it('a live node that is gone is reported and nothing is written', () => {+ const d = deps({ isLive: () => true })+ const w = createNodeWriteRouter(d)+ w.setColor(['gone'], '#0a84ff')+ w.setIcon('gone', undefined)+ w.pickIcon('gone')+ expect(d.toast).toHaveBeenCalledTimes(3)+ expect(d.toast).toHaveBeenCalledWith(NODE_GONE_MESSAGE)+ expect(d.live.setColor).not.toHaveBeenCalled()+ expect(d.live.setIcon).not.toHaveBeenCalled()+ expect(d.live.pickIcon).not.toHaveBeenCalled()+ })++ it('a live recolor writes the present nodes and reports the missing ones once', () => {+ const d = deps({ isLive: () => true })+ createNodeWriteRouter(d).setColor(['n1', 'gone', 'gone2'], '#0a84ff')+ expect(d.live.setColor).toHaveBeenCalledWith(['n1'], '#0a84ff')+ expect(d.toast).toHaveBeenCalledTimes(1)+ expect(d.toast).toHaveBeenCalledWith(NODE_GONE_MESSAGE)+ })++ it('an icon picker that fails to open is reported', async () => {+ const d = deps({ iconDialog: vi.fn(async () => { throw new Error('boom') }) })+ createNodeWriteRouter(d).pickIcon('n1')+ await flush()+ expect(d.toast).toHaveBeenCalledWith(ICON_PICKER_FAILED_MESSAGE)+ expect(d.setStoredIcon).not.toHaveBeenCalled()+ })})diff --git a/src/renderer/lib/nodeWriteRouter.ts b/src/renderer/lib/nodeWriteRouter.tsindex 94b838771..7718163de 100644--- a/src/renderer/lib/nodeWriteRouter.ts+++ b/src/renderer/lib/nodeWriteRouter.ts@@ -7,8 +7,9 @@* node and does nothing). That is the trap the kanban card menus — the Omni board above all — walk* into, because they act on nodes of projects that are not on the canvas.*- * Never silent: a node that is no longer in its project, and a save that fails, each raise a- * `nodeterm:toast` (the caller's `toast`).+ * Never silent: a node that is no longer in its project (on the live canvas or in the store), a+ * save that fails, and an icon picker that fails to open each raise a `nodeterm:toast` (the+ * caller's `toast`).*/import type { NodeIcon } from '@shared/node-icon'import type { CanvasNodeState } from '@shared/types'@@ -17,6 +18,7 @@ import { applyIconChoice } from './nodeIconChoice'export const NODE_GONE_MESSAGE = 'That session is no longer in its project — nothing was changed.'export const SAVE_FAILED_MESSAGE = 'The change could not be saved to disk.'+export const ICON_PICKER_FAILED_MESSAGE = "Couldn't open the icon picker."export interface NodeWrites {setColor: (ids: string[], color: string) => void@@ -28,6 +30,8 @@ export interface NodeWrites {export interface NodeWriteRouterDeps {/** React Flow holds this project right now. Asked on every write, never cached. */isLive: () => boolean+ /** The node is on the live canvas right now (the live funnels do nothing for a missing id). */+ liveHas: (nodeId: string) => boolean/** The live canvas's own funnels (Canvas `setNodesColor` / `setNodeIcon` / `pickNodeIcon`). */live: NodeWrites/** The node in the project's stored copy, or undefined when it is gone. */@@ -46,7 +50,8 @@ export function createNodeWriteRouter(d: NodeWriteRouterDeps): NodeWrites {}const setIcon = (nodeId: string, icon: NodeIcon | undefined): void => {if (d.isLive()) {- d.live.setIcon(nodeId, icon)+ if (d.liveHas(nodeId)) d.live.setIcon(nodeId, icon)+ else d.toast(NODE_GONE_MESSAGE)return}if (!d.storedNode(nodeId)) {@@ -59,7 +64,9 @@ export function createNodeWriteRouter(d: NodeWriteRouterDeps): NodeWrites {return {setColor(ids, color) {if (d.isLive()) {- d.live.setColor(ids, color)+ const live = ids.filter((id) => d.liveHas(id))+ if (live.length < ids.length) d.toast(NODE_GONE_MESSAGE)+ if (live.length > 0) d.live.setColor(live, color)return}const present = ids.filter((id) => d.storedNode(id))@@ -71,7 +78,8 @@ export function createNodeWriteRouter(d: NodeWriteRouterDeps): NodeWrites {setIcon,pickIcon(nodeId) {if (d.isLive()) {- d.live.pickIcon(nodeId)+ if (d.liveHas(nodeId)) d.live.pickIcon(nodeId)+ else d.toast(NODE_GONE_MESSAGE)return}const node = d.storedNode(nodeId)@@ -82,6 +90,7 @@ export function createNodeWriteRouter(d: NodeWriteRouterDeps): NodeWrites {void d.iconDialog({ nodeId, title: node.title ?? '', icon: node.icon }).then((choice) => applyIconChoice(choice, (icon) => setIcon(nodeId, icon)))+ .catch(() => d.toast(ICON_PICKER_FAILED_MESSAGE))}}}