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.

fix(kanban): Omni lane reads the live canvas, reports its modal, respects the lane's session

review988f9bd08a1f
diff --git a/CLAUDE.md b/CLAUDE.md
index d076b44de..23f3737ad 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -6260,7 +6260,7 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord mea
the phone's direct-SSH writer (`KanbanBoardWriter`) still appends without one — the next desktop
write into that column ranks it, and array order already shows it correctly. `KanbanDefaults`
should gain the three categories. All three are the iOS follow-up, not desktop work.
-- **Omni Kanban (global swimlanes)** (`components/kanban/GlobalKanbanView.tsx`; one swimlane per open project; `state/viewMode.ts` `globalKanban` (localStorage `nodeterm.globalKanban`, machine-local, like `viewByProject`) + `settings.omniKanbanEnabled` (feature gate, default OFF, `settings.json`) / `omniKanbanAsDefault` (when true, `view.kanbanToggle` — Cmd+Shift+B — opens Omni; otherwise per-project; `view.globalKanbanToggle` registry command — unbound, remappable — always opens Omni when enabled); `TabBar` and the menu IPC `onToggleKanban` share one `performKanbanToggle` decision, and `isGlobalKanbanOpen()` is the single gate (fail-closed, static import of `useSettings` — the earlier `require` failed open in the packaged renderer). The active project's lane is derived from serialized `p.nodes` via `toKanbanSessionState` — the persisted-state counterpart to `toKanbanSession` — and is committed (`commitActiveToStore`) before the overlay mounts so live React Flow edits are not stale; `pendingLaunch` never becomes `initialCommand` in the modal (the DAG launch must fire only when dependencies report done, and the canvas `TerminalNode` already delivers `initialCommand` via `writeWhenShellReady` after the `nodeterm:create-node` project switch). Active-project edits (rename / sticky / browser nav) route through Canvas live nodes (`setNodes` + `markDirty`), non-active through the store + `writeDisk`; delete uses `ConfirmDialog` (not `confirm`) and SSH-aware teardown (`transport.destroy` locally vs `sshProject.killSessions` with `everySocket` for a remote owner, plus `agentStatus` / `agentNodes` / `webviewKeepAlive` cleanup). The top bar's project pills and Cmd/Ctrl+1..9 (`nodeterm:swimlane-jump`) jump to the lane; header hint shows the correct mod (`Cmd` on Mac, `Ctrl` elsewhere). Server Edition works as-is, Mobile N/A.
+- **Omni Kanban (global swimlanes)** (`components/kanban/GlobalKanbanView.tsx`; one swimlane per open project; `state/viewMode.ts` `globalKanban` (localStorage `nodeterm.globalKanban`, machine-local, like `viewByProject`) + `settings.omniKanbanEnabled` (feature gate, default OFF, `settings.json`) / `omniKanbanAsDefault` (when true, `view.kanbanToggle` — Cmd+Shift+B — opens Omni; otherwise per-project; `view.globalKanbanToggle` registry command — unbound, remappable — always opens Omni when enabled); `TabBar` and the menu IPC `onToggleKanban` share one `performKanbanToggle` decision, and `isGlobalKanbanOpen()` is the single gate (fail-closed, static import of `useSettings` — the earlier `require` failed open in the packaged renderer). Non-active lanes are derived from serialized `p.nodes` via `toKanbanSessionState` (the persisted-state counterpart to `toKanbanSession`); the ACTIVE project's lane is fed LIVE by Canvas (`GlobalKanbanLive`: the same `kanbanSessionsFrom(nodes)` cards + live `teamStations` the per-project board uses), because its edits reach the store only at the next ~800 ms autosave — a store-fed lane reverted the card modal's controlled sticky textarea on every keystroke and pruned the assignment of a card created a moment earlier. The open card modal is ONE overview-level fact reported to Canvas's `setKanbanModalNode` (watched for Eco, wake-on-open, dictation target), never per-lane state; each lane's board write resolves ITS project's session (`sessionForProject`) for the hosted read-only refusal and the board-log api; `pendingLaunch` never becomes `initialCommand` in the modal (the DAG launch must fire only when dependencies report done, and the canvas `TerminalNode` already delivers `initialCommand` via `writeWhenShellReady` after the `nodeterm:create-node` project switch). Active-project edits (rename / sticky / browser nav) route through Canvas live nodes (`setNodes` + `markDirty`), non-active through the store + `writeDisk`; delete uses `ConfirmDialog` (not `confirm`) and then `deleteNodes` (active project) or `closeStoredNodes` (any other) — the existing cross-project teardown funnel, never a hand-rolled copy. The top bar's project pills and Cmd/Ctrl+1..9 (`nodeterm:swimlane-jump`) jump to the lane; header hint shows the correct mod (`Cmd` on Mac, `Ctrl` elsewhere). Server Edition works as-is, Mobile N/A.
- **Settings** (`SettingsPage.tsx`, ⚙ / ⌘,): font/cursor (live to xterm + Monaco), default
shell, grid + snap, **default node size** (`defaultNodeWidth`/`defaultNodeHeight` — new
terminal/agent nodes only, clamped in `terminalNodeSize()` in `state/workspace.ts`),
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index e98a12127..6aad1ea69 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -10226,9 +10226,11 @@ export function Canvas() {
// request's head branch is matched against (lib/pullLinks.ts) — except on an SSH project, where
// branch links are not supported and no card carries one (kanbanSessionsFrom).
const activeProjectSsh = useProjects((s) => !!s.projects.find((p) => p.id === s.activeProjectId)?.ssh)
+ // Derived while EITHER board is up: the Omni overview feeds the active project's lane from these
+ // live cards too (GlobalKanbanLive), never from the store copy that lags the canvas.
const kanbanSessions = useMemo(
- () => perProjectKanbanOpen ? kanbanSessionsFrom(nodes, { ssh: activeProjectSsh }) : NO_KANBAN_SESSIONS,
- [nodes, perProjectKanbanOpen, activeProjectSsh]
+ () => kanbanOpen ? kanbanSessionsFrom(nodes, { ssh: activeProjectSsh }) : NO_KANBAN_SESSIONS,
+ [nodes, kanbanOpen, activeProjectSsh]
)
// Team progress (lib/teamProgress): the stations each session opened, read off the live control
@@ -10246,6 +10248,10 @@ export function Canvas() {
useEffect(() => {
useTeamStations.getState().set(teamStations)
}, [teamStations])
+ const globalKanbanLive = useMemo(
+ () => activeProjectId ? { projectId: activeProjectId, sessions: kanbanSessions, teams: teamStations } : null,
+ [activeProjectId, kanbanSessions, teamStations]
+ )
// Create a node from the board's per-column "+ New" menu: it lands on the canvas (view
// center) and, for a real column, is assigned there. The assignment is written directly —
@@ -14393,8 +14399,8 @@ export function Canvas() {
// Global Kanban delegates active-project mutations to the live canvas (React Flow is
// source of truth — direct store writes for the active project would be clobbered by the
// next commitActiveToStore). Non-active projects write to the store and then to disk.
- // Delete uses ConfirmDialog and SSH-aware teardown (local transport.destroy vs remote
- // sshProject.killSessions with everySocket), not native confirm.
+ // Delete uses ConfirmDialog (not native confirm); an off-canvas delete tears down through
+ // `closeStoredNodes`, the one cross-project teardown funnel.
useEffect(() => {
const onGlobalRename = (e: CustomEvent<{ projectId: string; nodeId: string; title: string }>) => {
renameSession(e.detail.projectId, e.detail.nodeId, e.detail.title)
@@ -14441,34 +14447,17 @@ export function Canvas() {
deleteNodeFromKanban(nodeId)
return
}
+ // Off-canvas teardown: the SAME funnel the sessions sidebar and canvas control's off-canvas
+ // `close` use (parked-xterm dispose, remote-aware destroy, issue run-ended, agent/fan-out/
+ // attach-consent/webview cleanup, frame children freed). A hand-rolled copy here drifted —
+ // it skipped the parked dispose and swallowed a failed SSH kill.
const proj = useProjects.getState().getProject(projectId)
const label = proj?.nodes.find((n) => n.id === nodeId)?.title || 'this session'
setConfirm({
message: `Delete ${label}? Its terminal session will end.`,
- onConfirm: async () => {
- const doomed = proj?.nodes.find((n) => n.id === nodeId)
- if (doomed?.issueRef) logIssueRunEnded(projectId, doomed)
- useProjects.setState((s) => ({
- projects: s.projects.map((p) =>
- p.id === projectId ? { ...p, nodes: p.nodes.filter((n) => n.id !== nodeId) } : p
- )
- }))
- const owner = useProjects.getState().projects.find((p) => p.id === projectId)
- const isSsh = !!owner?.ssh
- try {
- if (isSsh) {
- await (window as unknown as { nodeTerminal: { sshProject: { killSessions: (a: string, b: string[], c: unknown) => Promise<void> } } }).nodeTerminal.sshProject.killSessions(projectId, [nodeId], { everySocket: true } as never)
- } else {
- transport.destroy(nodeId)
- }
- } catch {}
- useAgentStatus.getState().remove(nodeId)
- useAgentNodes.getState().clearForParent(nodeId)
- useAgentNodes.getState().clearLoop(nodeId)
- useWebviewKeepAlive.getState().drop(nodeId)
- clearAttachConsent(nodeId)
+ onConfirm: () => {
+ closeStoredNodes(projectId, [nodeId])
setConfirm(null)
- void writeDisk()
}
})
}
@@ -14498,7 +14487,7 @@ export function Canvas() {
window.removeEventListener('nodeterm:global-delete' as never, onGlobalDelete as never)
window.removeEventListener('nodeterm:global-set-icon' as never, onGlobalSetIcon as never)
}
- }, [renameSession, setNodes, markDirty, writeDisk, deleteNodeFromKanban, logIssueRunEnded])
+ }, [renameSession, setNodes, markDirty, writeDisk, deleteNodeFromKanban, closeStoredNodes])
// Sidebar "Name with AI": generate a title from the session's captured terminal output
// (same BYO-agent path as the terminal node's ✦), then apply it via renameSession.
@@ -16512,7 +16501,7 @@ export function Canvas() {
})()}
</div>
{globalKanbanOpen ? (
- <GlobalKanbanView />
+ <GlobalKanbanView live={globalKanbanLive} onModalNodeChange={setKanbanModalNode} />
) : perProjectKanbanOpen && (
<KanbanView
board={projectKanban ?? seedBoard}
diff --git a/src/renderer/canvas/issue-binding.source.test.ts b/src/renderer/canvas/issue-binding.source.test.ts
index 953b5f0b8..3c2a96375 100644
--- a/src/renderer/canvas/issue-binding.source.test.ts
+++ b/src/renderer/canvas/issue-binding.source.test.ts
@@ -116,11 +116,13 @@ describe('run history in the node-removal funnels', () => {
expect(log).toBeLessThan(body.indexOf('useAgentStatus.getState().remove(id)'))
})
- it('the Omni board delete files run-ended too', () => {
+ it('the Omni board delete files run-ended too — through the cross-project close, not a copy', () => {
+ // An off-canvas Omni delete routes through `closeStoredNodes` (pinned above), so it inherits
+ // run-ended and every other teardown step; the active project's delete goes through deleteNodes.
const body = code(between('const onGlobalDelete = ', 'const onGlobalSetIcon = '))
- const log = body.indexOf('logIssueRunEnded(projectId, doomed)')
- expect(log).toBeGreaterThan(-1)
- expect(log).toBeLessThan(body.indexOf('useAgentStatus.getState().remove(nodeId)'))
+ expect(body).toContain('deleteNodeFromKanban(nodeId)')
+ expect(body).toContain('closeStoredNodes(projectId, [nodeId])')
+ expect(body).not.toContain('transport.destroy(')
})
})
diff --git a/src/renderer/components/kanban/GlobalKanbanView.live.test.tsx b/src/renderer/components/kanban/GlobalKanbanView.live.test.tsx
new file mode 100644
index 000000000..46a8c33d3
--- /dev/null
+++ b/src/renderer/components/kanban/GlobalKanbanView.live.test.tsx
@@ -0,0 +1,164 @@
+// @vitest-environment jsdom
+//
+// The Omni overview's three contracts with the canvas underneath it:
+// 1. the ACTIVE project's lane is the live canvas (GlobalKanbanLive), not the store copy that
+// lags it by an autosave — a store-fed lane reverted the sticky textarea on every keystroke;
+// 2. the open card modal is ONE fact reported to Canvas (`onModalNodeChange`), so lanes without
+// a modal cannot clobber the lane that has one;
+// 3. a lane's board write belongs to ITS project's session — refused for a hosted read-only role,
+// and logged on that session's api, never the active one's.
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { act } from 'react'
+import { createRoot, type Root } from 'react-dom/client'
+import type { CanvasNodeState, Project, ProjectKanban } from '@shared/types'
+import { GlobalKanbanView, type GlobalKanbanLive } from './GlobalKanbanView'
+import type { KanbanSession } from './KanbanView'
+import { useProjects } from '../../state/projects'
+import { useViewMode } from '../../state/viewMode'
+import { useBoardLog } from '../../state/boardLog'
+import { addColumn, defaultKanban } from '../../lib/kanban'
+
+const localApi = { tag: 'local-api' }
+const hostedApi = { tag: 'hosted-api' }
+vi.mock('../../session/session', () => ({
+ useSession: () => ({ id: 'local', source: 'local', api: localApi }),
+ sessionForProject: (projectId: string) =>
+ projectId === 'hosted'
+ ? { id: 'hosted-session', source: 'relay', api: hostedApi }
+ : projectId === 'relay'
+ ? { id: 'relay-session', source: 'relay', api: hostedApi }
+ : { id: 'local', source: 'local', api: localApi }
+}))
+vi.mock('../../state/hostedTeams', () => ({
+ isHostedReadOnly: (sessionId: string) => sessionId === 'hosted-session'
+}))
+vi.mock('../ContextMeter', () => ({ ContextMeter: () => null }))
+// The modal itself is not under test — only what the overview hands it and hears back.
+vi.mock('./CardModal', () => ({
+ CardModal: (props: { session: KanbanSession; board: ProjectKanban; onChangeBoard: (b: ProjectKanban) => void; onClose: () => void }) => (
+ <div data-testid="modal" data-node={props.session.id} data-title={props.session.title}>
+ <button data-testid="add-col" onClick={() => props.onChangeBoard(addColumn(props.board, 'Added', '#fff'))} />
+ <button
+ data-testid="assign"
+ onClick={() => props.onChangeBoard({ ...props.board, assignments: [{ nodeId: props.session.id, columnId: props.board.columns[0].id }] })}
+ />
+ <button data-testid="close" onClick={props.onClose} />
+ </div>
+ )
+}))
+
+let root: Root | null = null
+let host: HTMLElement
+
+const sticky = (id: string, text: string): CanvasNodeState => ({
+ id, kind: 'sticky', position: { x: 0, y: 0 }, size: { width: 200, height: 200 },
+ title: '', color: '#fff', group: null, text
+} as CanvasNodeState)
+const project = (id: string, nodes: CanvasNodeState[]): Project => ({
+ id, name: id, color: '#7aa2f7', viewport: { x: 0, y: 0, zoom: 1 }, nodes
+} as unknown as Project)
+const liveCard = (id: string, text: string): KanbanSession => ({
+ id, title: text, color: '#fff', kind: 'sticky', text, spawn: {}
+} as unknown as KanbanSession)
+
+const appended: Array<{ api: unknown; projectId: string }> = []
+
+beforeEach(() => {
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
+ vi.stubGlobal('ResizeObserver', class { observe(): void {} unobserve(): void {} disconnect(): void {} })
+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {
+ boardLog: { list: async () => [], onChanged: () => () => {} },
+ settings: { save: async () => {} }
+ }
+ appended.length = 0
+ useBoardLog.setState({
+ append: (api: unknown, projectId: string) => { appended.push({ api, projectId }) }
+ } as never)
+ useViewMode.setState({ requestedCardNodeId: null } as never)
+})
+afterEach(() => {
+ if (root) act(() => root!.unmount())
+ root = null
+ host?.remove()
+ document.body.innerHTML = ''
+ vi.unstubAllGlobals()
+})
+
+function mount(projects: Project[], props: { live?: GlobalKanbanLive | null; onModalNodeChange?: (id: string | null) => void } = {}): void {
+ useProjects.setState({ projects, activeProjectId: projects[0].id } as never)
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+ act(() => root!.render(<GlobalKanbanView {...props} />))
+}
+const openCard = (nodeId: string): void => {
+ act(() => useViewMode.getState().requestCard(nodeId))
+}
+const modal = (): HTMLElement | null => document.querySelector('[data-testid="modal"]')
+const click = (testId: string): void => {
+ act(() => (document.querySelector(`[data-testid="${testId}"]`) as HTMLElement).click())
+}
+
+describe('Omni overview — the active lane is the live canvas', () => {
+ it('renders the live cards for the active project and the stored ones elsewhere', () => {
+ mount(
+ [project('p1', [sticky('a', 'stored text')]), project('p2', [sticky('b', 'other')])],
+ { live: { projectId: 'p1', sessions: [liveCard('a', 'typed just now'), liveCard('fresh', 'created a moment ago')], teams: new Map() } }
+ )
+ const p1 = document.querySelector('#swimlane-p1')!
+ expect(p1.querySelectorAll('.kanban-card--session').length).toBe(2)
+ expect(p1.textContent).toContain('created a moment ago')
+ expect(document.querySelector('#swimlane-p2')!.querySelectorAll('.kanban-card--session').length).toBe(1)
+ openCard('a')
+ // The modal edits what the canvas holds, not what the store held at the last autosave.
+ expect(modal()?.dataset.title).toBe('typed just now')
+ })
+
+ it('a board write keeps the assignment of a live card the store has not seen yet', () => {
+ const board = { ...defaultKanban(), assignments: [] as ProjectKanban['assignments'] }
+ const col = board.columns[0].id
+ board.assignments = [{ nodeId: 'fresh', columnId: col }]
+ const p1 = { ...project('p1', [sticky('a', 'x')]), kanban: board } as Project
+ mount([p1], { live: { projectId: 'p1', sessions: [liveCard('a', 'x'), liveCard('fresh', 'new')], teams: new Map() } })
+ openCard('a')
+ click('add-col')
+ const saved = useProjects.getState().getProject('p1')!.kanban!
+ expect(saved.assignments).toContainEqual({ nodeId: 'fresh', columnId: col })
+ })
+})
+
+describe('Omni overview — the open card modal is reported to the canvas', () => {
+ it('reports the open card, is not clobbered by the other lanes, and clears on close and unmount', () => {
+ const seen: Array<string | null> = []
+ mount([project('p1', [sticky('a', 'one')]), project('p2', [sticky('b', 'two')])], { onModalNodeChange: (id) => seen.push(id) })
+ openCard('b') // the SECOND lane — every lane before it used to report its own null after it
+ expect(modal()?.dataset.node).toBe('b')
+ expect(seen.at(-1)).toBe('b')
+ click('close')
+ expect(seen.at(-1)).toBeNull()
+ openCard('a')
+ expect(seen.at(-1)).toBe('a')
+ act(() => root!.unmount())
+ root = null
+ expect(seen.at(-1)).toBeNull()
+ })
+})
+
+describe("Omni overview — a lane's board belongs to its project's session", () => {
+ it('refuses a board write on a hosted read-only project', () => {
+ mount([project('p1', [sticky('a', 'x')]), project('hosted', [sticky('h', 'host')])])
+ openCard('h')
+ click('add-col')
+ expect(useProjects.getState().getProject('hosted')!.kanban).toBeUndefined()
+ expect(appended).toHaveLength(0)
+ })
+
+ it("logs a writable relay project's board change on that project's api", () => {
+ mount([project('p1', [sticky('a', 'x')]), project('relay', [sticky('r', 'relay')])])
+ openCard('r')
+ click('assign') // a card move — the diff funnel logs it
+ expect(useProjects.getState().getProject('relay')!.kanban!.assignments).toHaveLength(1)
+ expect(appended.length).toBeGreaterThan(0)
+ for (const entry of appended) expect(entry.api).toBe(hostedApi)
+ })
+})
diff --git a/src/renderer/components/kanban/GlobalKanbanView.teamProgress.test.tsx b/src/renderer/components/kanban/GlobalKanbanView.teamProgress.test.tsx
index e96b03faf..7d17844a2 100644
--- a/src/renderer/components/kanban/GlobalKanbanView.teamProgress.test.tsx
+++ b/src/renderer/components/kanban/GlobalKanbanView.teamProgress.test.tsx
@@ -11,7 +11,8 @@ import { useProjects } from '../../state/projects'
import { useAgentStatus, type AgentNodeStatus } from '../../state/agentStatus'
vi.mock('../../session/session', () => ({
- useSession: () => ({ source: 'local', api: window.nodeTerminal })
+ useSession: () => ({ source: 'local', api: window.nodeTerminal }),
+ sessionForProject: () => ({ id: 'local', source: 'local', api: window.nodeTerminal })
}))
vi.mock('../ContextMeter', () => ({ ContextMeter: () => null }))
diff --git a/src/renderer/components/kanban/GlobalKanbanView.tsx b/src/renderer/components/kanban/GlobalKanbanView.tsx
index d60c436f5..886d6f896 100644
--- a/src/renderer/components/kanban/GlobalKanbanView.tsx
+++ b/src/renderer/components/kanban/GlobalKanbanView.tsx
@@ -15,7 +15,8 @@ import { toKanbanSessionState } from '../../canvas/toKanbanSessionState'
import { createAgentNode, createBrowserNode, createStickyNode, createTerminalNode, flowToNodeStates, resolveNewNodeAccount } from '../../state/workspace'
import { markCanvasCovered } from '../../lib/canvasCovered'
import { useViewMode } from '../../state/viewMode'
-import { useSession } from '../../session/session'
+import { sessionForProject } from '../../session/session'
+import { isHostedReadOnly } from '../../state/hostedTeams'
import { activePermissionMode } from '../../state/permissionMode'
import { CardModal } from './CardModal'
import { ContextMenu, type MenuItem } from '../ContextMenu'
@@ -67,23 +68,28 @@ interface SwimlaneProps {
onEditSticky: (projectId: string, nodeId: string, text: string) => void
onBrowserNav: (projectId: string, nodeId: string, patch: { url?: string; title?: string }) => void
onSetIcon: (projectId: string, nodeId: string, icon: NodeIcon | undefined) => void
- onModalChange: (nodeId: string | null) => void
+ /** This lane's open card modal (null = none). Owned by the overview, not the lane: the modal is
+ * ONE app-wide fact (Canvas's `setKanbanModalNode`), and N lanes each reporting their own
+ * `null` would clobber whichever lane actually has one open. */
+ modalNodeId: string | null
+ onModalChange: (projectId: string, nodeId: string | null) => void
+ /** Team progress computed by the caller from LIVE canvas ropes — set for the active project's
+ * lane only; other lanes derive it from their persisted ropes. */
+ liveTeams?: ReadonlyMap<string, readonly TeamStation[]>
highlight?: boolean
}
const Swimlane = memo(function Swimlane({
- projectId, projectName, projectColor, board, sessions, ropes, nodes, onChangeBoard, onOpenNode, onCreateNode, onDeleteNode, onRenameNode, onEditSticky, onBrowserNav, onSetIcon, onModalChange, highlight
+ projectId, projectName, projectColor, board, sessions, ropes, nodes, onChangeBoard, onOpenNode, onCreateNode, onDeleteNode, onRenameNode, onEditSticky, onBrowserNav, onSetIcon, modalNodeId, onModalChange, liveTeams, highlight
}: SwimlaneProps) {
const dragRef = useRef<{ kind: 'column'; id: string } | { kind: 'card'; id: string } | null>(null)
- const [modalNodeId, setModalNodeId] = useState<string | null>(null)
+ const setModalNodeId = useCallback((nodeId: string | null) => onModalChange(projectId, nodeId), [onModalChange, projectId])
const [cardMenu, setCardMenu] = useState<{ x: number; y: number; nodeId: string } | null>(null)
const [labelFilter, setLabelFilter] = useState<string[]>([])
const [collapsed, setCollapsed] = useState(false)
const customAgents = useSettings((s) => s.settings.customAgents)
const disabledAgents = useSettings((s) => s.settings.disabledAgents)
- useEffect(() => { onModalChange(modalNodeId) }, [modalNodeId, onModalChange])
-
const requestedCardNodeId = useViewMode((s) => s.requestedCardNodeId)
useEffect(() => {
if (!requestedCardNodeId) return
@@ -91,16 +97,17 @@ const Swimlane = memo(function Swimlane({
setModalNodeId(requestedCardNodeId)
useViewMode.getState().clearCardRequest()
}
- }, [requestedCardNodeId, sessions])
+ }, [requestedCardNodeId, sessions, setModalNodeId])
const byId = useMemo(() => new Map(sessions.map(s => [s.id, s])), [sessions])
// Team progress per opener. The previous map is threaded back in so an unchanged team keeps its
// array identity and the memoized card does not re-render.
const teamsRef = useRef<ReadonlyMap<string, readonly TeamStation[]>>()
const teams = useMemo(() => {
+ if (liveTeams) return liveTeams
teamsRef.current = stationsByOpener(ropes, Array.isArray(nodes) ? nodes.map(stationNodeFromState) : [], teamsRef.current)
return teamsRef.current
- }, [ropes, nodes])
+ }, [liveTeams, ropes, nodes])
const travel = useCallback((nodeId: string) => onOpenNode(nodeId, projectId), [onOpenNode, projectId])
const sessionIds = useMemo(() => sessions.map(s => s.id), [sessions])
@@ -309,13 +316,45 @@ const Swimlane = memo(function Swimlane({
)
})
-export const GlobalKanbanView = memo(function GlobalKanbanView() {
+/**
+ * The ACTIVE project's lane, read from the live canvas rather than the store. React Flow is the
+ * source of truth for the active project, and its edits (a sticky keystroke, a rename, a node the
+ * board just created) reach `p.nodes` only at the next `commitActiveToStore` — ~800 ms later on
+ * the autosave. A lane fed from the store therefore reverted the card modal's controlled sticky
+ * textarea on every keystroke, and pruned the assignment of a card created a moment earlier.
+ */
+export interface GlobalKanbanLive {
+ projectId: string
+ sessions: KanbanSession[]
+ teams: ReadonlyMap<string, readonly TeamStation[]>
+}
+
+export interface GlobalKanbanViewProps {
+ live?: GlobalKanbanLive | null
+ /** Canvas's `setKanbanModalNode` — the same hook the per-project board reports to. It is what
+ * makes an open card "watched" (Eco must not hibernate it), wakes a hibernated agent on open,
+ * and points the dictation shortcut at the card instead of the selected canvas node. */
+ onModalNodeChange?: (nodeId: string | null) => void
+}
+
+export const GlobalKanbanView = memo(function GlobalKanbanView({ live = null, onModalNodeChange }: GlobalKanbanViewProps) {
// Same rule as the per-project board: the canvas is covered but mounted underneath.
useEffect(() => markCanvasCovered(document.documentElement), [])
const boardStyle = useBoardWallpaperStyle()
- const projects = useProjects(s => s.projects.filter(p => !p.closed))
- const { api } = useSession()
- const modalRef = useRef<string | null>(null)
+ const allProjects = useProjects(s => s.projects)
+ const projects = useMemo(() => allProjects.filter(p => !p.closed), [allProjects])
+ const liveRef = useRef(live)
+ liveRef.current = live
+ const [modal, setModal] = useState<{ projectId: string; nodeId: string } | null>(null)
+ const onModalChange = useCallback((projectId: string, nodeId: string | null) => {
+ setModal(nodeId ? { projectId, nodeId } : null)
+ }, [])
+ const modalNodeId = modal?.nodeId ?? null
+ useEffect(() => { onModalNodeChange?.(modalNodeId) }, [modalNodeId, onModalNodeChange])
+ // Closing the overview with a card open must not leave the node "watched" forever.
+ const onModalNodeChangeRef = useRef(onModalNodeChange)
+ onModalNodeChangeRef.current = onModalNodeChange
+ useEffect(() => () => onModalNodeChangeRef.current?.(null), [])
const highlightId = useViewMode(s => s.highlightedSwimlaneId)
const setHighlightId = useViewMode(s => s.setHighlightedSwimlaneId)
const containerRef = useRef<HTMLDivElement>(null)
@@ -334,10 +373,22 @@ export const GlobalKanbanView = memo(function GlobalKanbanView() {
}, [jumpTo])
const onChangeBoard = useCallback((projectId: string, next: ProjectKanban) => {
+ // Each lane belongs to ITS project's session — a relay/hosted tab's board is not the active
+ // session's. Same rule as the per-project board: a hosted Viewer/Commenter's board is the
+ // host's to change, and a move here would only diverge.
+ const session = sessionForProject(projectId)
+ if (isHostedReadOnly(session.id)) return
const prev = useProjects.getState().getProject(projectId)?.kanban ?? defaultKanban()
useProjects.getState().setProjectKanban(projectId, next)
markWorkspaceDirty()
+ const lv = liveRef.current
const cardTitle = (nodeId: string) => {
+ // The active lane's cards are live; a card created a moment ago is not in the store yet,
+ // and '' would read as "pruned removal" in the diff.
+ if (lv && lv.projectId === projectId) {
+ const card = lv.sessions.find(x => x.id === nodeId)
+ return card ? card.title || 'Untitled' : ''
+ }
const proj = useProjects.getState().getProject(projectId)
const n = proj?.nodes.find(x => x.id === nodeId)
if (!n) return ''
@@ -345,9 +396,9 @@ export const GlobalKanbanView = memo(function GlobalKanbanView() {
return s ? s.title || 'Untitled' : ''
}
for (const { nodeId, event } of boardLogEvents(prev, next, cardTitle)) {
- useBoardLog.getState().append(api, projectId, { kind: 'event', nodeId, event })
+ useBoardLog.getState().append(session.api, projectId, { kind: 'event', nodeId, event })
}
- }, [api])
+ }, [])
const onCreateNode = useCallback((projectId: string, choice: KanbanCreateChoice, columnId: string | null) => {
// Delegate to Canvas's createNodeInColumn which correctly mounts the TerminalNode
@@ -413,7 +464,10 @@ export const GlobalKanbanView = memo(function GlobalKanbanView() {
<div className="global-kanban__scroll">
{projects.map((p, idx) => {
const board = p.kanban ?? defaultKanban()
- const sessions = p.nodes.map(n => toKanbanSessionState(n as never)).filter((s): s is KanbanSession => s !== null)
+ const isLive = live !== null && live.projectId === p.id
+ const sessions = isLive
+ ? live.sessions
+ : p.nodes.map(n => toKanbanSessionState(n as never)).filter((s): s is KanbanSession => s !== null)
return (
<Swimlane
key={p.id}
@@ -432,7 +486,9 @@ export const GlobalKanbanView = memo(function GlobalKanbanView() {
onEditSticky={onEditSticky}
onBrowserNav={onBrowserNav}
onSetIcon={onSetIcon}
- onModalChange={id => { modalRef.current = id }}
+ modalNodeId={modal?.projectId === p.id ? modal.nodeId : null}
+ onModalChange={onModalChange}
+ liveTeams={isLive ? live.teams : undefined}
highlight={highlightId === p.id}
/>
)