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(canvas): sessions sidebar omits Delete by section, not by label

Mina Samehe72ddcef4c00
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 4261817f4..364d35eb2 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -16007,19 +16007,14 @@ export function Canvas() {
// Delete is swapped for End session rather than offered beside it.
const body: MenuItem[] =
projectId === activeProjectId
- ? (() => {
- const full = selectionItems([id])
- // Drop the canvas menu's trailing "Delete" (destructive deleteNodes) and any
- // separator left dangling before it, then append the session row's "End session".
- // Found by label rather than fixed index so this stays correct if the canvas
- // menu's tail changes — Delete is the only 'Delete'-labelled row.
- const withoutDelete = full.filter((it) => !('label' in it && it.label === 'Delete'))
- return [
- ...tidySeparators(withoutDelete),
- { type: 'separator' },
- { label: 'End session', icon: <IconTrash />, danger: true, onClick: () => closeSession(projectId, id) }
- ]
- })()
+ ? [
+ // The canvas menu minus its trailing "Delete" (destructive deleteNodes) — the
+ // builder drops the section and any rule it leaves dangling — then the session
+ // row's "End session" in its place.
+ ...selectionItems([id], undefined, { omit: ['delete'] }),
+ { type: 'separator' },
+ { label: 'End session', icon: <IconTrash />, danger: true, onClick: () => closeSession(projectId, id) }
+ ]
: [
// Non-active project: the shared rows read the active canvas's live nodes + per-node
// registered closures, which don't exist here. Keep the narrow set that works for any
diff --git a/src/renderer/lib/nodeActionItems.guard.test.ts b/src/renderer/lib/nodeActionItems.guard.test.ts
new file mode 100644
index 000000000..82b4d2e6a
--- /dev/null
+++ b/src/renderer/lib/nodeActionItems.guard.test.ts
@@ -0,0 +1,43 @@
+// Every surface that offers actions on a canvas node takes its rows from ONE builder,
+// lib/nodeActionItems: the canvas node menu, the sessions-sidebar row menu, and the kanban card
+// menus (per-project board and Omni lanes, through components/kanban/cardMenu.tsx). A second copy
+// of these rows is how the board fell behind the canvas in the first place; this fails the moment
+// one is written. Canvas.tsx cannot be mounted in a test, so the wiring is pinned at source level.
+import { readdirSync, readFileSync, statSync } from 'node:fs'
+import { join, relative } from 'node:path'
+import { describe, expect, it } from 'vitest'
+
+const RENDERER = join(__dirname, '..')
+const read = (rel: string): string => readFileSync(join(RENDERER, rel), 'utf8').replace(/\r\n/g, '\n')
+
+function sources(dir: string, out: string[] = []): string[] {
+ for (const entry of readdirSync(dir)) {
+ const full = join(dir, entry)
+ if (statSync(full).isDirectory()) sources(full, out)
+ else if (/\.tsx?$/.test(entry) && !/\.test\.tsx?$/.test(entry)) out.push(full)
+ }
+ return out
+}
+
+/** The source of one `const name = useCallback(…)` up to the next `const` at the same depth. */
+function callback(src: string, name: string): string {
+ const at = src.indexOf(`const ${name} = useCallback(`)
+ expect(at, name).toBeGreaterThan(-1)
+ const end = src.indexOf('\n const ', at + 10)
+ return src.slice(at, end === -1 ? undefined : end)
+}
+
+describe('node actions: one builder for every surface', () => {
+ const canvas = read('canvas/Canvas.tsx')
+
+ it('the canvas node menu is the builder', () => {
+ expect(callback(canvas, 'selectionItems')).toContain('buildNodeActionItems(ids, at, liveNodeActionCtx(), filter)')
+ })
+
+ it('the sessions-sidebar row menu is the builder minus Delete', () => {
+ const row = canvas.slice(canvas.indexOf('const onRowContextMenu = useCallback('))
+ const body = row.slice(0, row.indexOf('\n // Stream live subagent'))
+ expect(body).toContain("...selectionItems([id], undefined, { omit: ['delete'] }),")
+ expect(body).not.toContain("it.label === 'Delete'")
+ })
+})