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): address review for omni swimlane overview
Alexd0917c53de41
diff --git a/package-lock.json b/package-lock.jsonindex 39c8de8b9..71f4d123f 100644--- a/package-lock.json+++ b/package-lock.json@@ -19,7 +19,7 @@"emoji-picker-react": "^4.19.1","lucide-react": "^0.545.0","marked": "^12.0.2",- "monaco-editor": "0.56.0",+ "monaco-editor": "^0.56.0","node-pty": "^1.0.0","qrcode": "^1.5.4","sharp": "^0.35.4",diff --git a/package.json b/package.jsonindex 1403d263f..a5d888ca5 100644--- a/package.json+++ b/package.json@@ -151,7 +151,7 @@"emoji-picker-react": "^4.19.1","lucide-react": "^0.545.0","marked": "^12.0.2",- "monaco-editor": "0.56.0",+ "monaco-editor": "^0.56.0","node-pty": "^1.0.0","qrcode": "^1.5.4","sharp": "^0.35.4",diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 3fae51bf7..c2f0fc7b2 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -423,7 +423,7 @@ import { canClearDirty, canCommitCanvas, canCreateOnCanvas } from '../state/persimport { isHidden } from '../lib/ui-visibility'import { boardLogEvents } from '../lib/boardLogDiff'import { useBoardLog } from '../state/boardLog'-import { isGlobalKanbanOpen, isKanbanOpen, useViewMode, viewFor } from '../state/viewMode'+import { isGlobalKanbanOpen, isKanbanOpen, isOmniKanbanEnabled, useViewMode, viewFor } from '../state/viewMode'import { GlobalKanbanView } from '../components/kanban/GlobalKanbanView'import { useFocusNode, FOCUS_SURFACE_ID } from '../state/focusNode'import { focusTargetId } from '../lib/focusTarget'@@ -2254,7 +2254,7 @@ export function Canvas() {const perProjectKanbanOpen = useViewMode((s) => !!activeProjectId && viewFor(s, activeProjectId) === 'kanban')const rawGlobalKanban = useViewMode((s) => s.globalKanban)- const omniEnabled = useSettings((s) => s.settings.omniKanbanEnabled !== false)+ const omniEnabled = useSettings((s) => isOmniKanbanEnabled(s.settings))const globalKanbanOpen = rawGlobalKanban && omniEnabledconst kanbanOpen = globalKanbanOpen || perProjectKanbanOpenconst projectKanban = useProjects((s) => s.projects.find((p) => p.id === s.activeProjectId)?.kanban)@@ -2345,6 +2345,14 @@ export function Canvas() {await writeDisk()}, [commitActiveToStore, writeDisk])+ // Global kanban reads ALL lanes from serialized `p.nodes`, but the active project's+ // live React Flow nodes may have uncommitted edits (title rename, new node). Commit+ // before the board mounts so the active lane matches the canvas — the other lanes are+ // already serialized and correct. This is the one-definition discipline from the review.+ useEffect(() => {+ if (globalKanbanOpen) commitActiveToStore()+ }, [globalKanbanOpen, commitActiveToStore])+// Mirror `dirty` into a ref so the external-change listener (mounted once) reads the// live value without re-subscribing on every edit.const dirtyRef = useRef(false)@@ -6532,8 +6540,10 @@ export function Canvas() {'app.settings': () => { setSettingsSection(undefined); setSettingsOpen(true); return true },'app.shortcutsPanel': () => { setShortcutsOpen((v) => !v); return true },'view.kanbanToggle': () => {- const omniEnabled = useSettings.getState().settings.omniKanbanEnabled !== false+ const omniEnabled = isOmniKanbanEnabled(useSettings.getState().settings)if (omniEnabled) {+ // Ensure the active lane is not stale when the overview opens (live nodes → serialized p.nodes).+ if (!isGlobalKanbanOpen()) commitActiveToStore()useViewMode.getState().toggleGlobalKanban()} else {const id = useProjects.getState().activeProjectIddiff --git a/src/renderer/canvas/toKanbanSessionState.test.ts b/src/renderer/canvas/toKanbanSessionState.test.tsnew file mode 100644index 000000000..1667b20b8--- /dev/null+++ b/src/renderer/canvas/toKanbanSessionState.test.ts@@ -0,0 +1,76 @@+import { describe, expect, it } from 'vitest'+import type { CanvasNodeState } from '@shared/types'+import { toKanbanSessionState } from './toKanbanSessionState'++function base(overrides: Partial<CanvasNodeState>): CanvasNodeState {+ return {+ id: 'n1',+ kind: 'terminal',+ position: { x: 0, y: 0 },+ size: { width: 100, height: 100 },+ title: 'hello',+ color: '#fff',+ group: null,+ ...overrides+ } as CanvasNodeState+}++describe('toKanbanSessionState', () => {+ it('returns null for non-card kinds', () => {+ expect(toKanbanSessionState(base({ kind: 'editor' as never, title: 'file' }))).toBeNull()+ expect(toKanbanSessionState(base({ kind: 'group' as never }))).toBeNull()+ })++ it('maps terminal nodes (persisted shape)', () => {+ const s = toKanbanSessionState(base({ kind: 'terminal', title: 'term', agentId: 'claude', shell: '/bin/zsh', cwd: '/tmp' }))!+ expect(s.kind).toBe('terminal')+ expect(s.title).toBe('term')+ expect(s.spawn.shell).toBe('/bin/zsh')+ expect(s.spawn.cwd).toBe('/tmp')+ expect(s.spawn.agentId).toBe('claude')+ expect(s.spawn.initialCommand).toBeUndefined()+ })++ it('carries pendingLaunch.command as initialCommand', () => {+ const s = toKanbanSessionState(+ base({ kind: 'terminal', pendingLaunch: { after: [], command: 'claude --resume' } })+ )!+ expect(s.spawn.initialCommand).toBe('claude --resume')+ })++ it('maps sticky notes with title derivation', () => {+ const s = toKanbanSessionState(base({ kind: 'sticky', text: ' hello world \nsecond line' }))!+ expect(s.kind).toBe('sticky')+ expect(s.title).toBe('hello world')+ expect(s.text).toBe(' hello world \nsecond line')+ })++ it('derives sticky title stripping markdown heading', () => {+ const s = toKanbanSessionState(base({ kind: 'sticky', text: '## Plan \nbody' }))!+ expect(s.title).toBe('Plan')+ })++ it('clamps sticky title at 80 chars', () => {+ const long = 'a'.repeat(100)+ const s = toKanbanSessionState(base({ kind: 'sticky', text: long }))!+ expect(s.title!.length).toBe(80)+ })++ it('falls back to Note for empty sticky', () => {+ const s = toKanbanSessionState(base({ kind: 'sticky', text: ' ' }))!+ expect(s.title).toBe('Note')+ })++ it('maps browser nodes', () => {+ const s = toKanbanSessionState(base({ kind: 'browser', title: '', url: 'https://example.com', partition: 'persist:foo' }))!+ expect(s.kind).toBe('browser')+ expect(s.title).toBe('Browser')+ expect(s.url).toBe('https://example.com')+ expect(s.partition).toBe('persist:foo')+ })++ it('preserves browser title when present', () => {+ const s = toKanbanSessionState(base({ kind: 'browser', title: 'My site', url: 'https://example.com' }))!+ expect(s.title).toBe('My site')+ })+})diff --git a/src/renderer/canvas/toKanbanSessionState.ts b/src/renderer/canvas/toKanbanSessionState.tsindex a44a5bc8b..5010845cc 100644--- a/src/renderer/canvas/toKanbanSessionState.ts+++ b/src/renderer/canvas/toKanbanSessionState.ts@@ -1,7 +1,20 @@import type { CanvasNodeState } from '@shared/types'import { NODE_COLORS } from '../state/workspace'import type { KanbanSession } from '../components/kanban/KanbanView'+import type { ModalSpawn } from '../components/kanban/ModalTerminal'+/** First-line sticky title, same rule as `toKanbanSession` — markdown heading marker is presentation. */+function stickyTitle(text: string): string {+ return text.trim().split('\n')[0].replace(/^#{1,6}\s+/, '').trim().slice(0, 80) || 'Note'+}++/**+ * Persisted-state counterpart to `toKanbanSession` (which reads live React Flow `CanvasNode`s).+ * This reads `CanvasNodeState` from the projects store — the source for every *non-active*+ * project's lane in the global board. The two functions derive the SAME card shape and must+ * agree on titles, colors and sticky handling; they share the title helper and spawn shape.+ * Keep them in sync when adding fields — see `ModalSpawn`.+ */export function toKanbanSessionState(n: CanvasNodeState): KanbanSession | null {if (n.kind === 'browser') {return {@@ -11,39 +24,39 @@ export function toKanbanSessionState(n: CanvasNodeState): KanbanSession | null {kind: 'browser',url: n.url,partition: n.partition,- spawn: {}+ spawn: {} as ModalSpawn}}if (n.kind === 'sticky') {const txt = n.text ?? ''return {id: n.id,- title: txt.trim().split('\n')[0].replace(/^#{1,6}\s+/, '').trim().slice(0, 80) || 'Note',+ title: stickyTitle(txt),color: n.color ?? NODE_COLORS[2],kind: 'sticky',text: txt,textUpdatedAt: n.textUpdatedAt,textUpdatedBy: n.textUpdatedBy,- spawn: {}+ spawn: {} as ModalSpawn}}if (n.kind !== 'terminal') return null- const raw = n as unknown as Record<string, unknown>- const initialCommand = (raw.initialCommand as string | undefined) ?? (raw.pendingLaunch as { command?: string } | undefined)?.command+ const pendingCommand = n.pendingLaunch?.command+ const spawn: ModalSpawn = {+ shell: n.shell,+ cwd: n.cwd,+ agentId: n.agentId,+ accountId: n.accountId,+ ssh: n.ssh,+ sshRemoteTmux: !!n.sshRemoteTmux,+ ...(pendingCommand ? { initialCommand: pendingCommand } : {})+ }return {id: n.id,title: n.title ?? '',color: n.color ?? NODE_COLORS[0],kind: 'terminal',- agentId: n.agentId as string | undefined,- spawn: {- shell: n.shell,- cwd: n.cwd,- agentId: n.agentId as string | undefined,- accountId: n.accountId as string | undefined,- ssh: n.ssh,- sshRemoteTmux: !!n.sshRemoteTmux,- ...(initialCommand ? { initialCommand } : {})- } as never+ agentId: n.agentId,+ spawn}}diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsxindex d42f2122e..3918b40bd 100644--- a/src/renderer/components/TabBar.tsx+++ b/src/renderer/components/TabBar.tsx@@ -1,7 +1,7 @@import { useEffect, useMemo, useRef, useState } from 'react'import { createPortal } from 'react-dom'import { useProjects } from '../state/projects'-import { useViewMode, viewFor } from '../state/viewMode'+import { isOmniKanbanEnabled, useViewMode, viewFor } from '../state/viewMode'import { useAgentStatus } from '../state/agentStatus'import { useSettings } from '../state/settings'import { accountsForProject, sshAccountsHint, systemAccountDisplay } from '../state/workspace'@@ -87,10 +87,11 @@ export function TabBar({// Closed projects are hidden here (reopen them from the start screen's "Recently closed").const projects = useMemo(() => allProjects.filter((p) => !p.closed), [allProjects])const activeId = useProjects((s) => s.activeProjectId)- const omniEnabled = useSettings((s) => s.settings.omniKanbanEnabled !== false)+ const omniEnabled = useSettings((s) => isOmniKanbanEnabled(s.settings))const globalKanban = useViewMode((s) => s.globalKanban)const isGlobal = omniEnabled && globalKanban- const kanbanActive = useViewMode((s) => (omniEnabled && s.globalKanban) || (!!activeId && viewFor(s, activeId) === 'kanban'))+ const perProjectKanban = useViewMode((s) => !!activeId && viewFor(s, activeId) === 'kanban')+ const kanbanActive = isGlobal || perProjectKanbanconst highlightedId = useViewMode((s) => s.highlightedSwimlaneId)// Unread dots need only the unread id set — subscribing to the whole status map re-rendered// the TabBar on every working/waiting flip of any agent. Primitive signature → rare updates.@@ -369,7 +370,7 @@ export function TabBar({onClick={(e) => {e.stopPropagation() // a tab click switches projects, this only flips the viewconst vm = useViewMode.getState()- const omni = (useSettings.getState().settings.omniKanbanEnabled !== false)+ const omni = isOmniKanbanEnabled(useSettings.getState().settings)if (omni) {if (vm.globalKanban || viewFor(vm, p.id) === 'kanban') {if (vm.globalKanban) vm.toggleGlobalKanban()diff --git a/src/renderer/components/kanban/GlobalKanbanView.tsx b/src/renderer/components/kanban/GlobalKanbanView.tsxindex 56ab6f245..10db3355c 100644--- a/src/renderer/components/kanban/GlobalKanbanView.tsx+++ b/src/renderer/components/kanban/GlobalKanbanView.tsx@@ -23,6 +23,25 @@ import { boardLogEvents } from '../../lib/boardLogDiff'import { markWorkspaceDirty } from '../../state/workspaceDirty'import type { KanbanCreateChoice, KanbanSession } from './KanbanView'+/**+ * Global (Omni) Kanban overview — one swimlane per open project.+ *+ * Three surfaces:+ * - Desktop: full (pure renderer + workspace.save; same stack as per-project KanbanView).+ * - Server Edition: works as-is (same renderer bundle via bridge, no Electron-specific code).+ * - Mobile (nodeterm-ios, private repo): N/A — no canvas/kanban there (separate transport protocol).+ *+ * Closed projects (`p.closed`) are filtered out — an open board that showed closed lanes would+ * surface parked sessions the user deliberately hid. Board writes (column/boardLog) go to the+ * owning project's `.nodeterm/project.json` (`useProjects.setProjectKanban` → `markWorkspaceDirty` →+ * debounced `workspace.save`), so a cross-project drag is a write in that project's repo — intentional+ * (the board file travels with the repo, like per-project kanban already does). A card modal for a+ * non-active SSH project co-attaches via `ModalTerminal`'s transport — if its ControlMaster is down,+ * core refuses with `PtyCreateResult.unavailable` (`requireRemote` rule) and the modal shows no+ * session rather than a local shell fallback; verified by the `create`/`join` contract in+ * `src/core/pty-manager.ts` (`requireRemote` refuses, never falls through to local tmux).+ */+// One swimlane = one project's boardinterface SwimlaneProps {projectId: stringdiff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 7a8dcf75c..5e67f8b76 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -144,7 +144,7 @@ import { PresenceChips } from '../components/PresenceChips'import { useAgentNodes } from '../state/agentNodes'import { useTerminalFocus } from '../state/terminalFocus'import { useProjects } from '../state/projects'-import { isGlobalKanbanOpen, isKanbanOpen, useViewMode, viewFor } from '../state/viewMode'+import { isGlobalKanbanOpen, isKanbanOpen, isOmniKanbanEnabled, useViewMode, viewFor } from '../state/viewMode'import { useSshConn } from '../state/sshConn'import { useWorktrees } from '../state/worktrees'import { isRemoteSessionNode } from '@shared/worktree'@@ -1143,7 +1143,7 @@ export function TerminalNode({// an agent's input box off the bottom. So while the board is up we report "not viewing" (null),// exactly like a park, and the visible modal drives the shared grid. A node only ever lives in the// ACTIVE project's React Flow, so the active project's view is the one that matters.- const omniKanbanEnabled = useSettings((s) => s.settings.omniKanbanEnabled !== false)+ const omniKanbanEnabled = useSettings((s) => isOmniKanbanEnabled(s.settings))const boardOpen = useViewMode((s) =>(omniKanbanEnabled && s.globalKanban) ||diff --git a/src/renderer/state/viewMode.ts b/src/renderer/state/viewMode.tsindex ae87154b9..2865c326a 100644--- a/src/renderer/state/viewMode.ts+++ b/src/renderer/state/viewMode.ts@@ -65,6 +65,18 @@ export function viewFor(s: Pick<ViewModeState, 'viewByProject' | 'defaultView'>,return s.viewByProject[projectId] ?? s.defaultView}+/**+ * Feature flag: does the global swimlane overview exist at all?+ * `settings.omniKanbanEnabled` is the *feature* toggle (Settings → Behavior → Omni Kanban,+ * default ON, `true` when the key is absent for existing installs). `globalKanban` below is the+ * *view* toggle (whether the overview is currently shown). The two have opposite defaults+ * deliberately: the feature is on, the view is off until the user opens it. Use this helper+ * instead of spelling `!== false` inline — five call sites were doing it.+ */+export function isOmniKanbanEnabled(settings: { omniKanbanEnabled?: boolean }): boolean {+ return settings.omniKanbanEnabled !== false+}+function readGlobalKanban(): boolean {try {const raw = readLocal(GLOBAL_KANBAN_KEY)@@ -112,16 +124,21 @@ export function isKanbanOpen(projectId: string): boolean {return !!projectId && viewFor(useViewMode.getState(), projectId) === 'kanban'}-/** True when the global swimlane overview is active (all projects as swimlanes).- * Gated by Settings → Behavior → Omni Kanban: when disabled, the flag is ignored and- * per-project tabs remain. `omniKanbanEnabled` defaults to true for new installs and- * migrates to true for existing settings.json without the key. */+/**+ * True when the global swimlane overview is *currently shown* (all projects as swimlanes).+ * Gated by the feature flag `omniKanbanEnabled` — when the feature is off, the view flag is+ * ignored and per-project tabs remain. `globalKanban` itself is persisted in localStorage+ * (`nodeterm.globalKanban`) so an explicit "open overview" survives a restart; this is+ * intentional (like `viewByProject`), not transient — a lock that survives restart would read+ * as "frozen", but a board that survives restart reads as "you left it open". If that proves+ * surprising, make this transient; the call site is this one helper.+ */export function isGlobalKanbanOpen(): boolean {try {// Lazy import to avoid circular init — viewMode is imported by settings consumers.// eslint-disable-next-line @typescript-eslint/no-require-importsconst settings = (require('./settings') as typeof import('./settings')).useSettings.getState().settings as { omniKanbanEnabled?: boolean }- if (settings.omniKanbanEnabled === false) return false+ if (!isOmniKanbanEnabled(settings)) return false} catch { /* settings store not ready — treat as enabled */ }return useViewMode.getState().globalKanban}diff --git a/src/renderer/terminal/terminal-config.ts b/src/renderer/terminal/terminal-config.tsindex 818367633..7e4c61a47 100644--- a/src/renderer/terminal/terminal-config.ts+++ b/src/renderer/terminal/terminal-config.ts@@ -779,12 +779,15 @@ export type TerminalKeyAction = CopyKeyAction | 'shift-enter' | 'bubble'* `ownsProjectJump` is the Cmd/Ctrl+1-9 "jump to the Nth project" decision, made by the caller* (`liveProjectJumpTarget` in `lib/projectJump.ts`) and passed in — this module deliberately does* NOT re-derive it. There is exactly one matcher for that chord, because it has to agree with the- * Canvas handler that performs the switch. When it is true the key must be swallowed HERE: xterm's- * own handler runs first (via `attachCustomKeyEventHandler`), and by the time Canvas's bubble-phase- * listener calls `preventDefault()` the control byte has already gone to the pty (on Linux/Windows- * Ctrl+2..Ctrl+8 are `^@ ^[ ^\ ^] ^^ ^_`).+ * Canvas handler that performs the switch. When it is true we return `'bubble'`: xterm's own+ * handler runs first (via `attachCustomKeyEventHandler`), so we must suppress xterm's control-byte+ * write (on Linux/Windows Ctrl+2..Ctrl+8 are `^@ ^[ ^\ ^] ^^ ^_`) without calling+ * `preventDefault()` — a swallowed event is marked `defaultPrevented` and the window's bubble-phase+ * dispatcher bails, which is why the jump stopped working from a focused terminal. `'bubble'`+ * returns `false` from the xterm handler (skips the keymap) while the untouched event still bubbles+ * to `Canvas.projectJumpGesture` which performs the actual switch.*- * It defaults to `false` = never swallow = the byte-identical pre-feature behavior, which is also+ * It defaults to `false` = never intercept = the byte-identical pre-feature behavior, which is also* what the Server Edition wants: browsers reserve the chord, so nothing there can act on it.*/export function terminalKeyAction(