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.

feat(kanban): multi-select cards and act on them together

review67aa03dd4a19
diff --git a/CLAUDE.md b/CLAUDE.md
index a2bfbe969..a3d869fda 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -9171,7 +9171,21 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord mea
events are stored but no card feed shows them; canvas-born nodes get no card-created; no
card-deleted type.
Per-column "+ New session" menus create agents/terminal/sticky nodes assigned to the column
- (assignment written UN-pruned — the fresh node isn't in the derived list yet). The column
+ (assignment written UN-pruned — the fresh node isn't in the derived list yet).
+ **Multi-select** (2026-11, both boards): ⌘/Ctrl-click toggles a session card, Shift-click extends
+ from the last picked card in BOARD order, and while anything is selected a plain click keeps
+ picking instead of opening the modal (Esc / the bar's ✕ leave; the card menu's **Select** row is
+ the way in without a modifier). The floating `CardSelectionBar` and the right-click menu of a card
+ INSIDE a multi-card selection (`buildBulkCardMenuItems`) act on all of them — **Move to**
+ (`assignNodes`, which lands the group together and in board order at every anchor; a loop of
+ `assignNode` would reverse it at the top) and **Delete** (ONE canvas confirm: `onDeleteNodes`, or
+ `nodeterm:global-delete` with `nodeIds` from an Omni lane) — and dragging a selected card carries
+ the selection. Load-bearing: the selection is pruned against the cards ON SCREEN and callers read
+ the pruned value in the same render (`useCardSelection`), so a bulk delete can never reach a card
+ that a filter, a collapsed lane or a hidden closed column took out of sight; GitHub cards are
+ never selectable (their column is the provider's); on the Omni board a selection lives in ONE
+ lane (`selectionOwner` — two projects share no columns). Rules are pure in
+ `lib/cardSelection.ts`. No keyboard chord yet (no `board.*` registry command selects or deletes). The column
half-pill itself: (`components/kanban/ColumnPill.tsx`, `columnForNode` in lib/kanban; rendered
as a SIBLING of the node root — the roots are overflow:hidden — hidden for Ungrouped/dangling,
click opens the board). Server Edition works as-is (pure renderer + workspace.save). Scope: no
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index c2ae2fae2..f84574c90 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -12961,6 +12961,32 @@ export function Canvas() {
[deleteNodes]
)
+ // The board's multi-select Delete: ONE confirm for every selected card, then the same teardown.
+ // Ids are re-resolved against the live nodes at click AND at confirm time — a card deleted from
+ // elsewhere while the dialog was up is simply not there to delete.
+ const deleteNodesFromKanban = useCallback(
+ (nodeIds: string[]) => {
+ const live = (): string[] => {
+ const have = new Set(nodesRef.current.map((n) => n.id))
+ return [...new Set(nodeIds)].filter((id) => have.has(id))
+ }
+ const ids = live()
+ if (ids.length === 0) return
+ if (ids.length === 1) {
+ deleteNodeFromKanban(ids[0])
+ return
+ }
+ setConfirm({
+ message: `Delete ${ids.length} cards? Open terminal sessions will end.`,
+ onConfirm: () => {
+ deleteNodes(live())
+ setConfirm(null)
+ }
+ })
+ },
+ [deleteNodes, deleteNodeFromKanban]
+ )
+
// Persist a browser card's navigation (url/title) from the modal webview back to the node.
const browserNavFromKanban = useCallback(
(nodeId: string, patch: { url?: string; title?: string }) => {
@@ -16951,8 +16977,37 @@ export function Canvas() {
void writeDisk()
}
}
- const onGlobalDelete = (e: CustomEvent<{ projectId: string; nodeId: string }>) => {
- const { projectId, nodeId } = e.detail
+ const onGlobalDelete = (e: CustomEvent<{ projectId: string; nodeId?: string; nodeIds?: string[] }>) => {
+ const { projectId } = e.detail
+ // A lane's multi-select Delete names several cards (`nodeIds`); one confirm covers them all.
+ if (Array.isArray(e.detail.nodeIds)) {
+ const asked = [...new Set(e.detail.nodeIds.filter((id): id is string => typeof id === 'string'))]
+ if (projectId === useProjects.getState().activeProjectId) {
+ deleteNodesFromKanban(asked)
+ return
+ }
+ const stored = (): string[] => {
+ const have = new Set(useProjects.getState().getProject(projectId)?.nodes.map((n) => n.id) ?? [])
+ return asked.filter((id) => have.has(id))
+ }
+ const ids = stored()
+ if (ids.length === 0) return
+ const only = ids.length === 1
+ ? useProjects.getState().getProject(projectId)?.nodes.find((n) => n.id === ids[0])?.title || 'this session'
+ : ''
+ setConfirm({
+ message: only
+ ? `Delete ${only}? Its terminal session will end.`
+ : `Delete ${ids.length} cards? Open terminal sessions will end.`,
+ onConfirm: () => {
+ closeStoredNodes(projectId, stored())
+ setConfirm(null)
+ }
+ })
+ return
+ }
+ const nodeId = e.detail.nodeId
+ if (typeof nodeId !== 'string') return
if (projectId === useProjects.getState().activeProjectId) {
deleteNodeFromKanban(nodeId)
return
@@ -16987,7 +17042,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, closeStoredNodes, nodeWritesFor])
+ }, [renameSession, setNodes, markDirty, writeDisk, deleteNodeFromKanban, deleteNodesFromKanban, closeStoredNodes, nodeWritesFor])
// 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.
@@ -19811,6 +19866,7 @@ export function Canvas() {
onRenameNode={renameNodeFromKanban}
onEditSticky={editStickyText}
onDeleteNode={deleteNodeFromKanban}
+ onDeleteNodes={deleteNodesFromKanban}
onModalNodeChange={setKanbanModalNode}
onBrowserNav={browserNavFromKanban}
onSetIcon={setActiveCardIcon}
diff --git a/src/renderer/components/kanban/CardSelectionBar.tsx b/src/renderer/components/kanban/CardSelectionBar.tsx
new file mode 100644
index 000000000..0566e9707
--- /dev/null
+++ b/src/renderer/components/kanban/CardSelectionBar.tsx
@@ -0,0 +1,66 @@
+import { useState } from 'react'
+import { createPortal } from 'react-dom'
+import { ContextMenu, type MenuItem } from '../ContextMenu'
+import { IconClose, IconSwitch, IconTrash } from '../icons'
+import { cardCount } from './cardMenu'
+
+interface CardSelectionBarProps {
+ count: number
+ /** Where the selection can go (cardMenu `bulkMoveTargets`). Empty = no Move button. */
+ moveTargets: MenuItem[]
+ /** Delete every selected card (the caller confirms once). Absent = no Delete button. */
+ onDelete?: () => void
+ onClear: () => void
+}
+
+/**
+ * The floating bar a board shows while session cards are selected: how many, and what can be done
+ * to all of them at once. It is the visible half of multi-select — the count is also what tells
+ * the user a plain click now picks cards instead of opening them.
+ */
+export function CardSelectionBar({ count, moveTargets, onDelete, onClear }: CardSelectionBarProps) {
+ const [moveMenu, setMoveMenu] = useState<{ x: number; y: number } | null>(null)
+ // A body portal: `position: fixed` resolves against the nearest ancestor with a transform or a
+ // backdrop-filter, and a swimlane (or a themed board) is free to have one.
+ return createPortal(
+ <div className="kanban-select-bar" role="toolbar" aria-label="Selected cards">
+ <span className="kanban-select-bar__count" aria-live="polite">{cardCount(count)} selected</span>
+ {moveTargets.length > 0 && (
+ <button
+ className="kanban-select-bar__btn"
+ onClick={(e) => {
+ const r = (e.currentTarget as HTMLElement).getBoundingClientRect()
+ setMoveMenu({ x: r.left, y: r.top - 4 })
+ }}
+ >
+ <IconSwitch />
+ Move to…
+ </button>
+ )}
+ {onDelete && (
+ <button className="kanban-select-bar__btn kanban-select-bar__btn--danger" onClick={onDelete}>
+ <IconTrash />
+ Delete
+ </button>
+ )}
+ <button
+ className="kanban-select-bar__btn kanban-select-bar__clear"
+ title="Clear selection (Esc)"
+ aria-label="Clear selection"
+ onClick={onClear}
+ >
+ <IconClose />
+ </button>
+ {moveMenu && (
+ <ContextMenu
+ x={moveMenu.x}
+ y={moveMenu.y}
+ zIndex={60}
+ items={moveTargets}
+ onClose={() => setMoveMenu(null)}
+ />
+ )}
+ </div>,
+ document.body
+ )
+}
diff --git a/src/renderer/components/kanban/GlobalKanbanView.selection.test.tsx b/src/renderer/components/kanban/GlobalKanbanView.selection.test.tsx
new file mode 100644
index 000000000..51e619985
--- /dev/null
+++ b/src/renderer/components/kanban/GlobalKanbanView.selection.test.tsx
@@ -0,0 +1,124 @@
+// @vitest-environment jsdom
+//
+// Multi-select on the Omni (all-projects) board. Each lane is its own board, so:
+// - a selection lives in ONE lane — picking a card in another lane starts over there (cards of
+// two projects share no columns to be moved to together);
+// - the bulk Delete is delegated to Canvas like the single one, naming the lane's project and
+// every selected card in one event, so Canvas asks ONCE.
+// The click rules and the per-project board's wiring are pinned in lib/cardSelection.test.ts and
+// KanbanView.selection.test.tsx.
+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 } from '@shared/types'
+import { GlobalKanbanView } from './GlobalKanbanView'
+import { useProjects } from '../../state/projects'
+import { useViewMode } from '../../state/viewMode'
+
+vi.mock('../../session/session', async () => {
+ const { defaultAgentStatus } = await import('../../state/agentStatus')
+ return {
+ useSession: () => ({ id: 'local', source: 'local', api: {} }),
+ sessionForProject: () => ({ id: 'local', source: 'local', api: {} }),
+ agentStatusForProject: () => defaultAgentStatus,
+ useSessionRegistryVersion: () => 0,
+ useSessionStores: () => ({ agentStatus: defaultAgentStatus })
+ }
+})
+vi.mock('../ContextMeter', () => ({ ContextMeter: () => null }))
+vi.mock('./CardModal', () => ({ CardModal: () => null }))
+
+const note = (id: string): CanvasNodeState =>
+ ({ id, kind: 'sticky', position: { x: 0, y: 0 }, size: { width: 200, height: 200 }, title: id, color: '#fff', group: null, text: id }) 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
+
+let root: Root | null = null
+let host: HTMLElement
+const deletes: Array<{ projectId: string; nodeId?: string; nodeIds?: string[] }> = []
+const onDelete = (e: Event): void => {
+ deletes.push((e as CustomEvent).detail)
+}
+
+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 () => {} }
+ }
+ useViewMode.setState({ requestedCardNodeId: null } as never)
+ // jsdom has no scrollIntoView, and a lane's header calls it when it collapses.
+ Element.prototype.scrollIntoView = () => {}
+ deletes.length = 0
+ window.addEventListener('nodeterm:global-delete', onDelete)
+ useProjects.setState({
+ projects: [project('a', [note('a1'), note('a2'), note('a3')]), project('b', [note('b1'), note('b2')])],
+ activeProjectId: 'a'
+ } as never)
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+ act(() => root!.render(<GlobalKanbanView />))
+})
+afterEach(() => {
+ window.removeEventListener('nodeterm:global-delete', onDelete)
+ if (root) act(() => root!.unmount())
+ root = null
+ host?.remove()
+ document.body.innerHTML = ''
+ vi.unstubAllGlobals()
+})
+
+const cardEl = (id: string): HTMLElement =>
+ document.querySelector<HTMLElement>(`[data-kanban-card="${id}"]`)!
+const click = (id: string, mods: { metaKey?: boolean; shiftKey?: boolean } = {}): void =>
+ act(() => {
+ cardEl(id).dispatchEvent(new MouseEvent('click', { bubbles: true, ...mods }))
+ })
+const selected = (): string[] =>
+ [...document.querySelectorAll('.kanban-card--selected')].map((el) => el.getAttribute('data-kanban-card')!)
+const bars = (): HTMLElement[] => [...document.querySelectorAll<HTMLElement>('.kanban-select-bar')]
+const press = (el: Element, label: string): void => {
+ const target = [...el.querySelectorAll('button')].find((b) => b.textContent?.trim() === label)!
+ act(() => target.click())
+}
+
+describe('Omni board — multi-select', () => {
+ it('selects within a lane and deletes the lot through ONE delegated event', () => {
+ click('a3', { metaKey: true })
+ click('a1')
+ expect(selected()).toEqual(['a1', 'a3'])
+ expect(bars()).toHaveLength(1)
+ expect(bars()[0].textContent).toContain('2 cards selected')
+ press(bars()[0], 'Delete')
+ expect(deletes).toEqual([{ projectId: 'a', nodeIds: ['a1', 'a3'] }])
+ })
+
+ it('picking a card in another lane starts over there — one selection, one bar', () => {
+ click('a1', { metaKey: true })
+ click('a2')
+ click('b1', { metaKey: true })
+ expect(selected()).toEqual(['b1'])
+ expect(bars()).toHaveLength(1)
+ press(bars()[0], 'Delete')
+ expect(deletes).toEqual([{ projectId: 'b', nodeIds: ['b1'] }])
+ // …and back again.
+ click('a3', { metaKey: true })
+ expect(selected()).toEqual(['a3'])
+ })
+
+ it('Shift-click ranges stay inside the lane', () => {
+ click('a1', { metaKey: true })
+ click('a3', { shiftKey: true })
+ expect(selected()).toEqual(['a1', 'a2', 'a3'])
+ })
+
+ it('collapsing a lane drops its selection — nothing out of sight stays selected', () => {
+ click('a1', { metaKey: true })
+ act(() => document.querySelector<HTMLElement>('#swimlane-a .kanban-swimlane__header')!.click())
+ expect(bars()).toHaveLength(0)
+ act(() => document.querySelector<HTMLElement>('#swimlane-a .kanban-swimlane__header')!.click())
+ expect(selected()).toEqual([])
+ })
+})
diff --git a/src/renderer/components/kanban/GlobalKanbanView.tsx b/src/renderer/components/kanban/GlobalKanbanView.tsx
index 5b6b9ecbb..4c3bd1d0e 100644
--- a/src/renderer/components/kanban/GlobalKanbanView.tsx
+++ b/src/renderer/components/kanban/GlobalKanbanView.tsx
@@ -6,7 +6,7 @@ import { useSettings } from '../../state/settings'
import { useBoardWallpaperStyle } from '../../state/wallpaper'
import { AerialWallpaper } from '../AerialWallpaper'
import {
- addColumn, assignNode, assignedTo, boardLabels, cardMatchesLabelFilter, cardMeta, columnForNode,
+ addColumn, assignNodes, assignedTo, boardLabels, cardMatchesLabelFilter, cardMeta, columnForNode,
deleteColumn, labelsForCard, moveColumn,
nextColumnColor, pruneAssignments, recolorColumn, renameColumn, unassigned, defaultKanban, AT_COLUMN_END
} from '../../lib/kanban'
@@ -25,7 +25,10 @@ import { activePermissionMode } from '../../state/permissionMode'
import { CardModal } from './CardModal'
import { ContextMenu, type MenuItem } from '../ContextMenu'
import { IconAgent, IconNote, IconTerminal, IconWeb } from '../icons'
-import { buildCardMenuItems } from './cardMenu'
+import { buildBulkCardMenuItems, buildCardMenuItems, bulkMoveTargets } from './cardMenu'
+import { CardSelectionBar } from './CardSelectionBar'
+import { useCardSelection } from './useCardSelection'
+import { dragGroup, inBoardOrder } from '../../lib/cardSelection'
import { useBoardLog } from '../../state/boardLog'
import { boardLogEvents } from '../../lib/boardLogDiff'
import { markWorkspaceDirty } from '../../state/workspaceDirty'
@@ -70,6 +73,13 @@ interface SwimlaneProps {
onOpenNode: (nodeId: string, projectId: string) => void
onCreateNode: (projectId: string, choice: KanbanCreateChoice, columnId: string | null) => void
onDeleteNode: (projectId: string, nodeId: string) => void
+ /** Delete several of this lane's cards at once (multi-select) — one confirm for all of them. */
+ onDeleteNodes: (projectId: string, nodeIds: string[]) => void
+ /** The lane that holds the overview's ONE multi-selection (null = none). Cards of different
+ * projects cannot be moved together (their columns are different boards), so picking a card in
+ * another lane starts over there: a lane that is not the owner drops its selection. */
+ selectionOwner: string | null
+ onSelectionOwner: (projectId: string) => void
onRenameNode: (projectId: string, nodeId: string, title: string) => void
onEditSticky: (projectId: string, nodeId: string, text: string) => void
onBrowserNav: (projectId: string, nodeId: string, patch: { url?: string; title?: string }) => void
@@ -101,7 +111,7 @@ interface SwimlaneProps {
}
const Swimlane = memo(function Swimlane({
- projectId, projectName, projectIndex, projectColor, board, sessions, ropes, nodes, onChangeBoard, onOpenNode, onCreateNode, onDeleteNode, onRenameNode, onEditSticky, onBrowserNav, onSetIcon, modalNodeId, modalView, onModalChange, liveTeams, highlight, nodeActionItems, sessionActionItems, onAiName, onSetColor, onRunQueued
+ projectId, projectName, projectIndex, projectColor, board, sessions, ropes, nodes, onChangeBoard, onOpenNode, onCreateNode, onDeleteNode, onDeleteNodes, selectionOwner, onSelectionOwner, onRenameNode, onEditSticky, onBrowserNav, onSetIcon, modalNodeId, modalView, onModalChange, liveTeams, highlight, nodeActionItems, sessionActionItems, onAiName, onSetColor, onRunQueued
}: SwimlaneProps) {
const dragRef = useRef<{ kind: 'column'; id: string } | { kind: 'card'; id: string } | null>(null)
const setModalNodeId = useCallback(
@@ -211,6 +221,27 @@ const Swimlane = memo(function Swimlane({
}
}, [board, byId, sessionIds, activeLocalFilter])
+ // Multi-select over this lane's cards, in the order the lane shows them (a collapsed lane shows
+ // none, so collapsing drops its selection — a bulk action never reaches a card out of sight).
+ const boardOrder = useMemo(
+ () => collapsed
+ ? []
+ : [...columnCards.ungrouped, ...board.columns.flatMap(c => columnCards.byColumn.get(c.id) ?? [])].map(c => c.id),
+ [collapsed, columnCards, board.columns]
+ )
+ const selection = useCardSelection(boardOrder)
+ const selectedInOrder = useMemo(() => inBoardOrder(boardOrder, selection.ids), [boardOrder, selection.ids])
+ const selectedRef = useRef<{ ids: readonly string[]; order: readonly string[] }>({ ids: [], order: [] })
+ selectedRef.current = { ids: selection.ids, order: boardOrder }
+ const selecting = selection.ids.length > 0
+ const clearSelection = selection.clear
+ useEffect(() => {
+ if (selecting) onSelectionOwner(projectId)
+ }, [selecting, projectId, onSelectionOwner])
+ useEffect(() => {
+ if (selectionOwner !== projectId) clearSelection()
+ }, [selectionOwner, projectId, clearSelection])
+
const handleCardDragStart = useCallback((id: string) => { dragRef.current = { kind: 'card', id } }, [])
const handleColumnDragStart = useCallback((id: string) => { dragRef.current = { kind: 'column', id } }, [])
const handleDragEnd = useCallback(() => { dragRef.current = null }, [])
@@ -220,7 +251,8 @@ const Swimlane = memo(function Swimlane({
if (drag.kind === 'column') {
if (columnId !== null) commit(moveColumn(board, drag.id, columnId))
} else {
- commit(assignNode(board, drag.id, columnId, AT_COLUMN_END))
+ // Dragging one of several selected cards carries the whole selection.
+ commit(assignNodes(board, dragGroup(selectedRef.current.order, selectedRef.current.ids, drag.id), columnId, AT_COLUMN_END))
}
}, [board, commit])
@@ -236,7 +268,7 @@ const Swimlane = memo(function Swimlane({
const i = ids.indexOf(targetNodeId)
beforeId = i >= 0 && i + 1 < ids.length ? ids[i+1] : AT_COLUMN_END
}
- commit(assignNode(board, drag.id, columnId, beforeId))
+ commit(assignNodes(board, dragGroup(selectedRef.current.order, selectedRef.current.ids, drag.id), columnId, beforeId))
}, [board, commit, sessionIds])
const dropAtCardFor = useMemo(() => {
@@ -263,6 +295,8 @@ const Swimlane = memo(function Swimlane({
meta={cardMeta(board, s.id)}
labels={labelsByCard.get(s.id) ?? []}
onOpen={setModalNodeId}
+ selected={selection.set.has(s.id)}
+ onSelectClick={selection.onSelectClick}
onContext={(id, x, y) => setCardMenu({ nodeId: id, x, y })}
onDragStart={handleCardDragStart}
onDragEnd={handleDragEnd}
@@ -284,6 +318,16 @@ const Swimlane = memo(function Swimlane({
const cardMenuItems = (nodeId: string): MenuItem[] => {
const card = byId.get(nodeId)
if (!card) return []
+ // Same rule as the per-project board: a card inside a multi-card selection speaks for all.
+ if (selectedInOrder.length > 1 && selection.set.has(nodeId)) {
+ return buildBulkCardMenuItems({
+ ids: selectedInOrder,
+ board,
+ commit,
+ clear: selection.clear,
+ remove: (ids) => onDeleteNodes(projectId, ids)
+ })
+ }
return buildCardMenuItems({
card,
board,
@@ -294,7 +338,8 @@ const Swimlane = memo(function Swimlane({
rename: (id, title) => onRenameNode(projectId, id, title),
aiName: onAiName ? (id) => onAiName(projectId, id) : undefined,
nodeActions: nodeActionItems ? (id) => nodeActionItems(id, projectId) : undefined,
- remove: (id) => onDeleteNode(projectId, id)
+ remove: (id) => onDeleteNode(projectId, id),
+ select: { selected: selection.set.has(nodeId), toggle: selection.toggle }
})
}
@@ -357,6 +402,14 @@ const Swimlane = memo(function Swimlane({
</div>
</div>
)}
+ {selectedInOrder.length > 0 && (
+ <CardSelectionBar
+ count={selectedInOrder.length}
+ moveTargets={bulkMoveTargets(board, selectedInOrder, commit)}
+ onDelete={() => onDeleteNodes(projectId, selectedInOrder)}
+ onClear={selection.clear}
+ />
+ )}
{cardMenu && byId.has(cardMenu.nodeId) && (
<ContextMenu x={cardMenu.x} y={cardMenu.y} zIndex={60} items={cardMenuItems(cardMenu.nodeId)} onClose={() => setCardMenu(null)} />
)}
@@ -512,6 +565,13 @@ export const GlobalKanbanView = memo(function GlobalKanbanView({ live = null, on
window.dispatchEvent(new CustomEvent('nodeterm:global-delete', { detail: { projectId, nodeId } }))
}, [])
+ const onDeleteNodes = useCallback((projectId: string, nodeIds: string[]) => {
+ // Same delegate as the single delete, naming several cards: Canvas asks ONCE for all of them.
+ window.dispatchEvent(new CustomEvent('nodeterm:global-delete', { detail: { projectId, nodeIds } }))
+ }, [])
+ // The one lane whose cards are selected (see SwimlaneProps.selectionOwner).
+ const [selectionOwner, setSelectionOwner] = useState<string | null>(null)
+
const onRenameNode = useCallback((projectId: string, nodeId: string, title: string) => {
// The LANE's project, like every sibling here: it is known, and looking the node up in the
// STORED projects instead dropped a rename of a live-lane node created since the last autosave
@@ -580,6 +640,9 @@ export const GlobalKanbanView = memo(function GlobalKanbanView({ live = null, on
onOpenNode={onOpenNode}
onCreateNode={onCreateNode}
onDeleteNode={onDeleteNode}
+ onDeleteNodes={onDeleteNodes}
+ selectionOwner={selectionOwner}
+ onSelectionOwner={setSelectionOwner}
onRenameNode={onRenameNode}
onEditSticky={onEditSticky}
onBrowserNav={onBrowserNav}
diff --git a/src/renderer/components/kanban/KanbanView.selection.test.tsx b/src/renderer/components/kanban/KanbanView.selection.test.tsx
new file mode 100644
index 000000000..59d625afb
--- /dev/null
+++ b/src/renderer/components/kanban/KanbanView.selection.test.tsx
@@ -0,0 +1,313 @@
+// @vitest-environment jsdom
+//
+// The board's multi-select: ⌘/Ctrl-click and Shift-click pick session cards, a floating bar (and
+// the right-click menu of a selected card) acts on all of them at once — move, delete — and a drag
+// of a selected card carries the selection. The click rules themselves are lib/cardSelection's
+// (unit-tested there); this pins that the board wires them to the cards, the bar and the canvas.
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { act, useEffect } from 'react'
+import { createRoot, type Root } from 'react-dom/client'
+import { KanbanView, type KanbanSession, type KanbanViewProps } from './KanbanView'
+import type { ProjectKanban } from '@shared/types'
+import { assignedTo } from '../../lib/kanban'
+import { popDialog, pushDialog, resetDialogStack } from '../dialog-stack'
+
+vi.mock('../../session/session', async () => {
+ const { defaultAgentStatus } = await import('../../state/agentStatus')
+ return {
+ useSession: () => ({ source: 'local', api: window.nodeTerminal }),
+ sessionForProject: () => ({ id: 'local', source: 'local', api: window.nodeTerminal }),
+ SessionProvider: ({ children }: { children: unknown }) => children,
+ agentStatusForProject: () => defaultAgentStatus,
+ useSessionRegistryVersion: () => 0,
+ useSessionStores: () => ({ agentStatus: defaultAgentStatus })
+ }
+})
+
+vi.mock('./CardModal', () => ({
+ CardModal: ({ session }: { session: { id: string } }) => {
+ useEffect(() => {
+ pushDialog('card-modal')
+ return () => popDialog('card-modal')
+ }, [])
+ return <div className="kanban-modal" data-node-id={session.id} />
+ }
+}))
+
+let root: Root
+let host: HTMLElement
+const card = (id: string): KanbanSession =>
+ ({ id, title: `Card ${id}`, color: '#fff', kind: 'sticky', text: '', spawn: {} }) as unknown as KanbanSession
+
+// Ungrouped: u1. To Do: a1 a2 a3. Done: b1.
+const board = (): ProjectKanban => ({
+ columns: [
+ { id: 'a', title: 'To Do', color: '#0a84ff' },
+ { id: 'b', title: 'Done', color: '#32d74b' }
+ ],
+ assignments: [
+ { nodeId: 'a1', columnId: 'a' },
+ { nodeId: 'a2', columnId: 'a' },
+ { nodeId: 'a3', columnId: 'a' },
+ { nodeId: 'b1', columnId: 'b' }
+ ]
+})
+const ALL = ['u1', 'a1', 'a2', 'a3', 'b1']
+
+const onChange = vi.fn<(next: ProjectKanban) => void>()
+const onDeleteNode = vi.fn<(id: string) => void>()
+const onDeleteNodes = vi.fn<(ids: string[]) => void>()
+
+const render = (over: Partial<KanbanViewProps> = {}, ids: string[] = ALL): void => {
+ const noop = (): void => {}
+ act(() =>
+ root.render(
+ <KanbanView
+ board={board()}
+ sessions={ids.map(card)}
+ onChange={onChange}
+ onOpenNode={noop}
+ onCreateNode={noop}
+ onRenameNode={noop}
+ onEditSticky={noop}
+ onDeleteNode={onDeleteNode}
+ onDeleteNodes={onDeleteNodes}
+ onModalNodeChange={noop}
+ onBrowserNav={noop}
+ onSetIcon={noop}
+ {...over}
+ />
+ )
+ )
+}
+
+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 () => {} }
+ }
+ resetDialogStack()
+ onChange.mockClear()
+ onDeleteNode.mockClear()
+ onDeleteNodes.mockClear()
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+ render()
+})
+afterEach(() => {
+ act(() => root.unmount())
+ host.remove()
+ document.body.innerHTML = ''
+ resetDialogStack()
+ vi.unstubAllGlobals()
+})
+
+const cardEl = (id: string): HTMLElement =>
+ document.querySelector<HTMLElement>(`[data-kanban-card="${id}"]`)!
+const click = (id: string, mods: { metaKey?: boolean; ctrlKey?: boolean; shiftKey?: boolean } = {}): void =>
+ act(() => {
+ cardEl(id).dispatchEvent(new MouseEvent('click', { bubbles: true, ...mods }))
+ })
+const rightClick = (id: string): void =>
+ act(() => {
+ cardEl(id).dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 10, clientY: 10 }))
+ })
+const selected = (): string[] =>
+ [...document.querySelectorAll('.kanban-card--selected')].map((el) => el.getAttribute('data-kanban-card')!)
+const bar = (): HTMLElement | null => document.querySelector('.kanban-select-bar')
+const barCount = (): string | null => bar()?.querySelector('.kanban-select-bar__count')?.textContent ?? null
+const modalCard = (): string | null =>
+ document.querySelector('.kanban-modal')?.getAttribute('data-node-id') ?? null
+const press = (el: Element, label: string): void => {
+ const target = [...el.querySelectorAll('button')].find((b) => b.textContent?.trim() === label)
+ if (!target) throw new Error(`no button "${label}" in ${[...el.querySelectorAll('button')].map((b) => b.textContent).join(' | ')}`)
+ act(() => target.click())
+}
+const menu = (): HTMLElement => document.querySelector<HTMLElement>('.ctx-menu')!
+const menuLabels = (): string[] =>
+ [...document.querySelectorAll('.ctx-menu .ctx-item')].map((el) => el.textContent?.trim() ?? '')
+const escape = (target: EventTarget = window): void =>
+ act(() => {
+ target.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
+ })
+const drag = (type: string, el: Element): void =>
+ act(() => {
+ const ev = new Event(type, { bubbles: true, cancelable: true })
+ Object.assign(ev, { dataTransfer: {}, clientY: 0 })
+ el.dispatchEvent(ev)
+ })
+const column = (title: string): HTMLElement =>
+ [...document.querySelectorAll<HTMLElement>('.kanban-col')].find(
+ (el) => el.querySelector('.kanban-col__title')?.textContent === title
+ )!
+
+describe('KanbanView — multi-select', () => {
+ it('a plain click with nothing selected still opens the card, and shows no bar', () => {
+ click('a1')
+ expect(modalCard()).toBe('a1')
+ expect(selected()).toEqual([])
+ expect(bar()).toBeNull()
+ })
+
+ it('⌘-click (or Ctrl-click) selects instead of opening, and the bar counts the selection', () => {
+ click('a1', { metaKey: true })
+ expect(modalCard()).toBeNull()
+ expect(selected()).toEqual(['a1'])
+ expect(barCount()).toBe('1 card selected')
+ click('b1', { ctrlKey: true })
+ expect(selected()).toEqual(['a1', 'b1'])
+ expect(barCount()).toBe('2 cards selected')
+ click('a1', { metaKey: true })
+ expect(selected()).toEqual(['b1'])
+ })
+
+ it('while cards are selected a plain click keeps picking — it does not open a modal over them', () => {
+ click('a1', { metaKey: true })
+ click('a3')
+ expect(modalCard()).toBeNull()
+ expect(selected()).toEqual(['a1', 'a3'])
+ click('a3')
+ click('a1')
+ // Back to nothing selected: the next plain click opens again.
+ expect(bar()).toBeNull()
+ click('a2')
+ expect(modalCard()).toBe('a2')
+ })
+
+ it('Shift-click selects the whole span from the last picked card, across columns', () => {
+ click('a1', { metaKey: true })
+ click('b1', { shiftKey: true })
+ expect(selected()).toEqual(['a1', 'a2', 'a3', 'b1'])
+ expect(barCount()).toBe('4 cards selected')
+ })
+
+ it('Escape and the bar’s ✕ clear the selection', () => {
+ click('a1', { metaKey: true })
+ escape()
+ expect(selected()).toEqual([])
+ click('a1', { metaKey: true })
+ act(() => bar()!.querySelector<HTMLElement>('.kanban-select-bar__clear')!.click())
+ expect(selected()).toEqual([])
+ })
+
+ it('Escape is not the board’s while a dialog is up, or from inside a text field', () => {
+ click('a1', { metaKey: true })
+ pushDialog('some-dialog')
+ escape()
+ expect(selected()).toEqual(['a1'])
+ popDialog('some-dialog')
+ const input = document.createElement('input')
+ document.body.appendChild(input)
+ escape(input)
+ expect(selected()).toEqual(['a1'])
+ })
+
+ it('the bar’s Delete asks the canvas ONCE, for every selected card in board order', () => {
+ click('b1', { metaKey: true })
+ click('a2')
+ click('u1')
+ press(bar()!, 'Delete')
+ expect(onDeleteNodes).toHaveBeenCalledTimes(1)
+ expect(onDeleteNodes).toHaveBeenCalledWith(['u1', 'a2', 'b1'])
+ expect(onDeleteNode).not.toHaveBeenCalled()
+ })
+
+ it('a board with no bulk delete behind it still selects and moves, but offers no Delete', () => {
+ render({ onDeleteNodes: undefined })
+ click('a1', { metaKey: true })
+ click('a2')
+ expect(bar()!.textContent).not.toContain('Delete')
+ rightClick('a1')
+ expect(menuLabels().some((l) => l.startsWith('Delete'))).toBe(false)
+ })
+
+ it('the bar’s Move to… files the whole selection in the column, together and in board order', () => {
+ click('a3', { metaKey: true })
+ click('a1')
+ press(bar()!, 'Move to…')
+ // Ungrouped and Done; not "To Do", where every selected card already is.
+ expect(menuLabels()).toEqual(['Ungrouped', 'Done'])
+ press(menu(), 'Done')
+ expect(onChange).toHaveBeenCalledTimes(1)
+ const next = onChange.mock.calls[0][0]
+ expect(assignedTo(next, 'b')).toEqual(['a1', 'a3', 'b1'])
+ expect(assignedTo(next, 'a')).toEqual(['a2'])
+ })
+
+ it('right-click on a card INSIDE a multi-card selection acts on all of them', () => {
+ click('a1', { metaKey: true })
+ click('a2')
+ rightClick('a2')
+ expect(menu().querySelector('.ctx-label')?.textContent).toBe('2 cards selected')
+ expect(menuLabels()).toEqual(['Move to', 'Clear selection', 'Delete 2 cards'])
+ press(menu(), 'Delete 2 cards')
+ expect(onDeleteNodes).toHaveBeenCalledWith(['a1', 'a2'])
+ })
+
+ it('right-click on a card OUTSIDE the selection is that card’s own menu, and keeps the selection', () => {
+ click('a1', { metaKey: true })
+ click('a2')
+ rightClick('b1')
+ expect(menuLabels()).toContain('Select')
+ expect(menuLabels()).toContain('Delete')
+ press(menu(), 'Delete')
+ expect(onDeleteNode).toHaveBeenCalledWith('b1')
+ expect(onDeleteNodes).not.toHaveBeenCalled()
+ expect(selected()).toEqual(['a1', 'a2'])
+ })
+
+ it('the card menu’s Select row starts a selection without knowing the modifier-click', () => {
+ rightClick('a2')
+ press(menu(), 'Select')
+ expect(selected()).toEqual(['a2'])
+ rightClick('a2')
+ expect(menuLabels()).toContain('Deselect')
+ })
+
+ it('dragging a selected card onto a column carries the whole selection', () => {
+ click('a1', { metaKey: true })
+ click('u1')
+ drag('dragstart', cardEl('a1'))
+ drag('drop', column('Done'))
+ const next = onChange.mock.calls.at(-1)![0]
+ expect(assignedTo(next, 'b')).toEqual(['b1', 'u1', 'a1'])
+ })
+
+ it('dragging an UNSELECTED card moves only that card', () => {
+ click('a1', { metaKey: true })
+ click('a2')
+ drag('dragstart', cardEl('a3'))
+ drag('drop', column('Done'))
+ const next = onChange.mock.calls.at(-1)![0]
+ expect(assignedTo(next, 'b')).toEqual(['b1', 'a3'])
+ expect(assignedTo(next, 'a')).toEqual(['a1', 'a2'])
+ })
+
+ it('a selected card that leaves the board (deleted) leaves the selection', () => {
+ click('a1', { metaKey: true })
+ click('a2')
+ render({}, ['u1', 'a2', 'a3', 'b1'])
+ expect(selected()).toEqual(['a2'])
+ expect(barCount()).toBe('1 card selected')
+ render({}, ['u1', 'a3', 'b1'])
+ expect(bar()).toBeNull()
+ })
+
+ it('a card that left the board does not come back selected (no ghost selection)', () => {
+ click('a1', { metaKey: true })
+ click('a2')
+ render({}, ['u1', 'a2', 'a3', 'b1'])
+ render()
+ expect(selected()).toEqual(['a2'])
+ })
+})
diff --git a/src/renderer/components/kanban/KanbanView.tsx b/src/renderer/components/kanban/KanbanView.tsx
index 0ea3675aa..2a3b31be7 100644
--- a/src/renderer/components/kanban/KanbanView.tsx
+++ b/src/renderer/components/kanban/KanbanView.tsx
@@ -19,7 +19,7 @@ import { useSettings } from '../../state/settings'
import { useBoardWallpaperStyle } from '../../state/wallpaper'
import { AerialWallpaper } from '../AerialWallpaper'
import {
- AT_COLUMN_END, addColumn, assignNode, assignedTo, boardLabels, cardAssignees, cardMatchesLabelFilter, cardMeta, columnForNode,
+ AT_COLUMN_END, addColumn, assignNodes, assignedTo, boardLabels, cardAssignees, cardMatchesLabelFilter, cardMeta, columnForNode,
deleteColumn, labelsForCard, moveColumn,
nextColumnColor, pruneAssignments, recolorColumn, renameColumn, setColumnCategory, unassigned
} from '../../lib/kanban'
@@ -37,7 +37,10 @@ import { GitHubPullCard } from './GitHubPullCard'
import { kanbanSource, sourceVisible } from '../../lib/kanbanSources'
import type { ModalSpawn } from './ModalTerminal'
import { ContextMenu, type MenuItem } from '../ContextMenu'
-import { buildCardMenuItems } from './cardMenu'
+import { buildBulkCardMenuItems, buildCardMenuItems, bulkMoveTargets } from './cardMenu'
+import { CardSelectionBar } from './CardSelectionBar'
+import { useCardSelection } from './useCardSelection'
+import { dragGroup, inBoardOrder } from '../../lib/cardSelection'
import { IconAgent, IconBranch, IconExternal, IconNote, IconTerminal, IconWeb } from '../icons'
import { issueWorktreeMenuRow, type IssueWorktreeMenuAnswer } from '../../lib/issueWorktree'
import type { GitHubCloseReason, GitHubIssueCardView } from '@shared/github-issues'
@@ -131,6 +134,10 @@ export interface KanbanViewProps {
onEditSticky: (nodeId: string, text: string) => void
/** Permanently delete a node (ends its session) — routed through the canvas confirm. */
onDeleteNode: (nodeId: string) => void
+ /** Permanently delete SEVERAL nodes at once (the multi-select bar / menu) — one canvas confirm
+ * for all of them. Optional: a board without it selects and moves cards but offers no bulk
+ * Delete. */
+ onDeleteNodes?: (nodeIds: string[]) => void
/** Reports which node's card modal is open (null = none) so the canvas can target it — e.g.
* the dictation shortcut dictates into the open card's session, not a canvas selection. */
onModalNodeChange: (nodeId: string | null) => void
@@ -254,12 +261,15 @@ function useCanvasCovered(): void {
export const KanbanView = memo(function KanbanView({
board, sessions, onChange, onOpenNode, onCreateNode, onRenameNode, onEditSticky, onDeleteNode,
- onModalNodeChange, onBrowserNav, onSetIcon, nodeActionItems, sessionActionItems, onAiName, onSetColor, onRunQueued, onAutoMoveFromPulls, issueAgentMenu,
+ onDeleteNodes, onModalNodeChange, onBrowserNav, onSetIcon, nodeActionItems, sessionActionItems, onAiName, onSetColor, onRunQueued, onAutoMoveFromPulls, issueAgentMenu,
issueWorktreeMenu, teams, onIssueMoved
}: KanbanViewProps) {
useCanvasCovered()
const { api } = useSession()
const dragRef = useRef<Drag>(null)
+ // The multi-selection as the drop handlers need it (they are declared before the board order
+ // the selection hook is built from): the selected ids and the order to move them in.
+ const selectedRef = useRef<{ ids: readonly string[]; order: readonly string[] }>({ ids: [], order: [] })
// One card modal at a time; a deleted node closes it via the byId.has render guard.
const [modalNodeId, setModalNodeId] = useState<string | null>(null)
// The card the menu's "Open card in chat / markdown view" opened. Paired with the open card so
@@ -655,7 +665,11 @@ export const KanbanView = memo(function KanbanView({
if (columnId !== null) commit(moveColumn(board, drag.id, columnId))
// a column dropped on Ungrouped is a no-op — Ungrouped is always first
} else if (isProviderDrag(drag)) requestGitHubMove(drag.issue, columnId)
- else commit(assignNode(board, drag.id, columnId, AT_COLUMN_END))
+ else {
+ // Dragging one of several selected cards carries the whole selection (lib/cardSelection).
+ const moving = dragGroup(selectedRef.current.order, selectedRef.current.ids, drag.id)
+ commit(assignNodes(board, moving, columnId, AT_COLUMN_END))
+ }
},
[board, commit, requestGitHubMove]
)
@@ -679,7 +693,10 @@ export const KanbanView = memo(function KanbanView({
const i = ids.indexOf(targetNodeId)
beforeId = i >= 0 && i + 1 < ids.length ? ids[i + 1] : AT_COLUMN_END
}
- commit(assignNode(board, drag.id, columnId, beforeId))
+ // A selection drag lands the whole group at the drop line (an anchor that is itself moving
+ // resolves to the next card that stays — `assignNodes`).
+ const moving = dragGroup(selectedRef.current.order, selectedRef.current.ids, drag.id)
+ commit(assignNodes(board, moving, columnId, beforeId))
},
[board, commit, requestGitHubMove, sessionIds]
)
@@ -825,6 +842,16 @@ export const KanbanView = memo(function KanbanView({
...shownColumns.map((col) => (columnCards.byColumn.get(col.id) ?? NO_CARDS).map((c) => c.id))
]
}, [columnCards, shownColumns, ungroupedShown, source])
+ // Multi-select over the same order the keys walk: ⌘/Ctrl-click, Shift-click, then one bar for
+ // the lot. GitHub cards are not in it — their column is the provider's, and deleting one is not
+ // a board action.
+ const boardOrder = useMemo(() => navColumns.flat(), [navColumns])
+ const selection = useCardSelection(boardOrder)
+ const selectedInOrder = useMemo(() => inBoardOrder(boardOrder, selection.ids), [boardOrder, selection.ids])
+ selectedRef.current = { ids: selection.ids, order: boardOrder }
+ const clearSelection = selection.clear
+ // Another project's board is another set of cards: never carry a selection across the switch.
+ useEffect(() => clearSelection(), [projectId, clearSelection])
const boardKeyRef = useRef<(action: BoardKeyAction) => boolean>(() => false)
boardKeyRef.current = (action) => {
const active = document.activeElement
@@ -960,6 +987,8 @@ export const KanbanView = memo(function KanbanView({
meta={metaOf(s.id)}
labels={labelsOf(s.id)}
onOpen={setModalNodeId}
+ selected={selection.set.has(s.id)}
+ onSelectClick={selection.onSelectClick}
onOpenIssue={handleOpenIssueRef}
onContext={handleCardContext}
onDragStart={handleCardDragStart}
@@ -1050,6 +1079,17 @@ export const KanbanView = memo(function KanbanView({
const cardMenuItems = (nodeId: string): MenuItem[] => {
const card = byId.get(nodeId)
if (!card) return []
+ // A card that is part of a multi-card selection speaks for all of them. A card OUTSIDE the
+ // selection keeps its own menu (and the selection): its rows name that one card.
+ if (selectedInOrder.length > 1 && selection.set.has(nodeId)) {
+ return buildBulkCardMenuItems({
+ ids: selectedInOrder,
+ board,
+ commit,
+ clear: selection.clear,
+ remove: onDeleteNodes
+ })
+ }
return buildCardMenuItems({
card,
board,
@@ -1060,7 +1100,8 @@ export const KanbanView = memo(function KanbanView({
rename: onRenameNode,
aiName: onAiName,
nodeActions: nodeActionItems,
- remove: onDeleteNode
+ remove: onDeleteNode,
+ select: { selected: selection.set.has(nodeId), toggle: selection.toggle }
})
}
@@ -1256,6 +1297,14 @@ export const KanbanView = memo(function KanbanView({
</button>
</div>
</div>
+ {selectedInOrder.length > 0 && (
+ <CardSelectionBar
+ count={selectedInOrder.length}
+ moveTargets={bulkMoveTargets(board, selectedInOrder, commit)}
+ onDelete={onDeleteNodes ? () => onDeleteNodes(selectedInOrder) : undefined}
+ onClear={selection.clear}
+ />
+ )}
{cardMenu && byId.has(cardMenu.nodeId) && (
<ContextMenu
x={cardMenu.x}
diff --git a/src/renderer/components/kanban/SessionCard.tsx b/src/renderer/components/kanban/SessionCard.tsx
index 36fde8f70..5224a1dff 100644
--- a/src/renderer/components/kanban/SessionCard.tsx
+++ b/src/renderer/components/kanban/SessionCard.tsx
@@ -23,6 +23,7 @@ import type { TeamStation } from '../../lib/teamProgress'
import { cardShowsOverdue, sessionNameRepeatsTitle } from '../../lib/cardRedundancy'
import { PortsChip } from '../PortsChip'
import { QueuedLaunchChip } from './QueuedLaunchChip'
+import type { SelectMods } from '../../lib/cardSelection'
const PRIO_COLOR = Object.fromEntries(PRIORITIES.map((p) => [p.id, p.color])) as Record<KanbanPriority, string>
@@ -71,12 +72,18 @@ interface SessionCardProps {
* project's too, so the default store would show that project's state on this card. Absent =
* the default store. A stable reference per board (SessionCard is memoized). */
statusStore?: AgentStatusSession['store']
+ /** This card is part of the board's multi-selection. */
+ selected?: boolean
+ /** Every click is offered to the board's selection first (⌘/Ctrl-click, Shift-click, or any
+ * click while cards are selected). True = it was a selection gesture and the card must NOT
+ * open. One stable function for every card (`useCardSelection`). Absent = no multi-select. */
+ onSelectClick?: (nodeId: string, mods: SelectMods) => boolean
}
export const SessionCard = memo(function SessionCard({
session, meta, labels = [], onOpen, onDragStart, onDragEnd, onDropAt, onContext, pulls,
pullFreshness = 'fresh', onOpenIssue, team, onTravel, columnCategory, liveLinkSource, ports, onOpenPort, onRunQueued,
- statusStore
+ statusStore, selected = false, onSelectClick
}: SessionCardProps) {
// THIS card's agent status, subscribed per card rather than threaded down from the board.
// KanbanView used to hold `useAgentStatus((s) => s.byId)` and pass the map through the column:
@@ -129,7 +136,7 @@ export const SessionCard = memo(function SessionCard({
<div
className={`kanban-card kanban-card--session${dragging ? ' kanban-card--dragging' : ''}${
dropSide ? ` kanban-card--drop-${dropSide}` : ''
- }`}
+ }${selected ? ' kanban-card--selected' : ''}`}
draggable
// Focusable, and named for the board's keyboard (J/K/arrows walk these, Space opens one —
// KanbanView's board-key handler finds the current card through this attribute).
@@ -158,7 +165,16 @@ export const SessionCard = memo(function SessionCard({
setDropSide(null)
onDropAt(session.id, side)
}}
- onClick={() => onOpen(session.id)}
+ // A Shift-click extends the selection; without this it would also sweep a text selection
+ // across every card in between.
+ onMouseDown={(e) => {
+ if (e.shiftKey && onSelectClick) e.preventDefault()
+ }}
+ onClick={(e) => {
+ const mods = { toggle: e.metaKey || e.ctrlKey, range: e.shiftKey }
+ if (onSelectClick?.(session.id, mods)) return
+ onOpen(session.id)
+ }}
onContextMenu={(e) => {
e.preventDefault()
onContext(session.id, e.clientX, e.clientY)
diff --git a/src/renderer/components/kanban/cardMenu.tsx b/src/renderer/components/kanban/cardMenu.tsx
index e6f6a3bf9..c01e13b78 100644
--- a/src/renderer/components/kanban/cardMenu.tsx
+++ b/src/renderer/components/kanban/cardMenu.tsx
@@ -2,7 +2,7 @@
* The kanban card right-click menu, for BOTH boards (per-project and the Omni lanes) — one list,
* so the two views of a card cannot offer different things.
*
- * Board-only rows come first (open, move, rename); then the node's own rows from the shared node
+ * Board-only rows come first (open, move, select, rename); then the node's own rows from the shared node
* builder (`nodeActions`: lib/nodeActionItems, narrowed to `BOARD_NODE_ACTION_IDS` by Canvas);
* then Delete, which goes through the board's own confirm.
*
@@ -13,9 +13,9 @@
*/
import type { ProjectKanban } from '@shared/types'
import type { MenuItem } from '../ContextMenu'
-import { IconEditor, IconExternal, IconMarkdown, IconSparkle, IconSwitch, IconTrash } from '../icons'
+import { IconCheck, IconClose, IconEditor, IconExternal, IconMarkdown, IconSparkle, IconSwitch, IconTrash } from '../icons'
import { promptDialog } from '../promptDialog'
-import { assignNode, columnForNode } from '../../lib/kanban'
+import { assignNode, assignNodes, columnForNode } from '../../lib/kanban'
import { isHidden } from '../../lib/ui-visibility'
import { tidySeparators } from '../../lib/tidySeparators'
import type { KanbanSession } from './KanbanView'
@@ -37,6 +37,8 @@ export interface CardMenuArgs {
nodeActions?: (nodeId: string) => MenuItem[]
/** The board's Delete — routed through the canvas confirm. */
remove: (nodeId: string) => void
+ /** Multi-select: whether this card is selected, and the toggle. Absent = no Select row. */
+ select?: { selected: boolean; toggle: (nodeId: string) => void }
}
export function buildCardMenuItems(a: CardMenuArgs): MenuItem[] {
@@ -66,6 +68,17 @@ export function buildCardMenuItems(a: CardMenuArgs): MenuItem[] {
...(moveTargets.length
? ([{ type: 'submenu', label: 'Move to', icon: <IconSwitch />, children: moveTargets }] as MenuItem[])
: []),
+ // The way into multi-select for someone who does not know the ⌘/Ctrl-click gesture.
+ ...(a.select
+ ? [
+ {
+ label: a.select.selected ? 'Deselect' : 'Select',
+ icon: <IconCheck />,
+ hint: 'Select several cards to move or delete them together (⌘/Ctrl-click, Shift-click for a range)',
+ onClick: () => a.select!.toggle(card.id)
+ }
+ ]
+ : []),
{ type: 'separator' },
// Not on a sticky: a note's label IS its first line (the card modal does not rename it either).
...(card.kind !== 'sticky'
@@ -90,3 +103,60 @@ export function buildCardMenuItems(a: CardMenuArgs): MenuItem[] {
{ label: 'Delete', icon: <IconTrash />, danger: true, onClick: () => a.remove(card.id) }
])
}
+
+/** "card" / "cards" — the one place the bulk wording counts. */
+export const cardCount = (n: number): string => `${n} ${n === 1 ? 'card' : 'cards'}`
+
+/**
+ * Where a SELECTION can be moved: Ungrouped and every column, minus a destination that already
+ * holds every selected card (moving there would change nothing). `ids` are in board order, which
+ * is the order they keep in the destination (lib/kanban `assignNodes`; unanchored = the top).
+ */
+export function bulkMoveTargets(
+ board: ProjectKanban,
+ ids: readonly string[],
+ commit: (next: ProjectKanban) => void
+): MenuItem[] {
+ const homes = new Set(ids.map((id) => columnForNode(board, id)?.id ?? null))
+ const allIn = (columnId: string | null): boolean => homes.size === 1 && homes.has(columnId)
+ return [
+ ...(allIn(null) ? [] : [{ label: 'Ungrouped', onClick: () => commit(assignNodes(board, ids, null, null)) }]),
+ ...board.columns
+ .filter((c) => !allIn(c.id))
+ .map((c) => ({ label: c.title, onClick: () => commit(assignNodes(board, ids, c.id, null)) }))
+ ]
+}
+
+export interface BulkCardMenuArgs {
+ /** The selected cards, in board order. */
+ ids: readonly string[]
+ board: ProjectKanban
+ commit: (next: ProjectKanban) => void
+ clear: () => void
+ /** Delete every selected card — ONE confirm for all of them. Absent = no Delete row. */
+ remove?: (nodeIds: string[]) => void
+}
+
+/** The right-click menu of a card that is part of a multi-card selection: it acts on ALL of them,
+ * so it offers only what makes sense for several cards at once. */
+export function buildBulkCardMenuItems(a: BulkCardMenuArgs): MenuItem[] {
+ const targets = bulkMoveTargets(a.board, a.ids, a.commit)
+ return tidySeparators([
+ { type: 'label', label: `${cardCount(a.ids.length)} selected` },
+ ...(targets.length
+ ? ([{ type: 'submenu', label: 'Move to', icon: <IconSwitch />, children: targets }] as MenuItem[])
+ : []),
+ { label: 'Clear selection', icon: <IconClose />, onClick: a.clear },
+ { type: 'separator' },
+ ...(a.remove
+ ? [
+ {
+ label: `Delete ${cardCount(a.ids.length)}`,
+ icon: <IconTrash />,
+ danger: true,
+ onClick: () => a.remove!([...a.ids])
+ }
+ ]
+ : [])
+ ])
+}
diff --git a/src/renderer/components/kanban/useCardSelection.ts b/src/renderer/components/kanban/useCardSelection.ts
new file mode 100644
index 000000000..ce041bade
--- /dev/null
+++ b/src/renderer/components/kanban/useCardSelection.ts
@@ -0,0 +1,79 @@
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import {
+ NO_SELECTION, clickSelection, pruneSelection, type SelectMods, type SelectionState
+} from '../../lib/cardSelection'
+import { openDialogCount } from '../dialog-stack'
+
+export interface CardSelection {
+ /** Selected card ids that are on the board RIGHT NOW (pick order). Stable while unchanged. */
+ ids: readonly string[]
+ /** The same ids as a set, for a card's `selected` prop. */
+ set: ReadonlySet<string>
+ /** A card was clicked: true = the click was a selection gesture (the card must not open).
+ * Identity-stable, so the memoized cards never re-render for it. */
+ onSelectClick: (id: string, mods: SelectMods) => boolean
+ /** Select / deselect one card (the card menu's row). */
+ toggle: (id: string) => void
+ clear: () => void
+}
+
+const isTextTarget = (el: EventTarget | null): boolean => {
+ const t = el as HTMLElement | null
+ if (!t || typeof t.tagName !== 'string') return false
+ return t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.tagName === 'SELECT' || t.isContentEditable === true
+}
+
+/**
+ * Multi-select state for one board's session cards (the rules are lib/cardSelection).
+ *
+ * `order` is the board order on screen. The selection is pruned against it on every change, and
+ * what callers read is ALREADY pruned in the same render — so a bulk action can never reach a card
+ * a filter just hid, even for the one frame before the state catches up.
+ *
+ * Escape clears the selection, but only when the key is plainly the board's: not while a dialog
+ * or a context menu is up, and not from inside a text field (where Escape cancels the edit).
+ */
+export function useCardSelection(order: readonly string[]): CardSelection {
+ const [state, setState] = useState<SelectionState>(NO_SELECTION)
+ const live = useMemo(() => pruneSelection(state, order), [state, order])
+ useEffect(() => {
+ if (live !== state) setState(live)
+ }, [live, state])
+ const liveRef = useRef(live)
+ liveRef.current = live
+ const orderRef = useRef(order)
+ orderRef.current = order
+
+ const onSelectClick = useCallback((id: string, mods: SelectMods): boolean => {
+ const next = clickSelection(liveRef.current, orderRef.current, id, mods)
+ if (!next) return false
+ // Read back by a second click in the same tick, before React has re-rendered.
+ liveRef.current = next
+ setState(next)
+ return true
+ }, [])
+ const toggle = useCallback(
+ (id: string) => void onSelectClick(id, { toggle: true, range: false }),
+ [onSelectClick]
+ )
+ const clear = useCallback(() => {
+ liveRef.current = NO_SELECTION
+ setState(NO_SELECTION)
+ }, [])
+
+ const active = live.ids.length > 0
+ useEffect(() => {
+ if (!active) return
+ const onKey = (e: KeyboardEvent): void => {
+ if (e.key !== 'Escape' || e.defaultPrevented) return
+ if (openDialogCount() > 0 || document.querySelector('.ctx-backdrop')) return
+ if (isTextTarget(e.target)) return
+ clear()
+ }
+ window.addEventListener('keydown', onKey)
+ return () => window.removeEventListener('keydown', onKey)
+ }, [active, clear])
+
+ const set = useMemo(() => new Set(live.ids), [live.ids])
+ return { ids: live.ids, set, onSelectClick, toggle, clear }
+}
diff --git a/src/renderer/lib/cardSelection.test.ts b/src/renderer/lib/cardSelection.test.ts
new file mode 100644
index 000000000..eaa96e1b1
--- /dev/null
+++ b/src/renderer/lib/cardSelection.test.ts
@@ -0,0 +1,72 @@
+import { describe, expect, it } from 'vitest'
+import { NO_SELECTION, clickSelection, dragGroup, inBoardOrder, pruneSelection, type SelectionState } from './cardSelection'
+
+const order = ['u1', 'a1', 'a2', 'a3', 'b1']
+const plain = { toggle: false, range: false }
+const cmd = { toggle: true, range: false }
+const shift = { toggle: false, range: true }
+const sel = (ids: string[], anchor: string | null = ids.at(-1) ?? null): SelectionState => ({ ids, anchor })
+
+describe('clickSelection', () => {
+ it('a plain click with nothing selected is NOT a selection gesture (the card opens)', () => {
+ expect(clickSelection(NO_SELECTION, order, 'a1', plain)).toBeNull()
+ })
+
+ it('⌘/Ctrl-click selects a card, and again deselects it', () => {
+ const one = clickSelection(NO_SELECTION, order, 'a1', cmd)!
+ expect(one).toEqual({ ids: ['a1'], anchor: 'a1' })
+ expect(clickSelection(one, order, 'a1', cmd)).toEqual({ ids: [], anchor: 'a1' })
+ })
+
+ it('once something is selected, a plain click keeps picking instead of opening', () => {
+ const next = clickSelection(sel(['a1']), order, 'b1', plain)!
+ expect(next.ids).toEqual(['a1', 'b1'])
+ expect(clickSelection(next, order, 'a1', plain)!.ids).toEqual(['b1'])
+ })
+
+ it('Shift-click adds the span between the anchor and the card, in either direction', () => {
+ expect(clickSelection(sel(['a1']), order, 'a3', shift)!.ids).toEqual(['a1', 'a2', 'a3'])
+ expect(clickSelection(sel(['a3']), order, 'u1', shift)!.ids).toEqual(['a3', 'u1', 'a1', 'a2'])
+ })
+
+ it('Shift-click keeps what was already selected outside the span, and keeps the anchor', () => {
+ const next = clickSelection({ ids: ['b1', 'a1'], anchor: 'a1' }, order, 'a2', shift)!
+ expect(next).toEqual({ ids: ['b1', 'a1', 'a2'], anchor: 'a1' })
+ })
+
+ it('Shift-click with no usable anchor just selects the card', () => {
+ expect(clickSelection(NO_SELECTION, order, 'a2', shift)).toEqual({ ids: ['a2'], anchor: 'a2' })
+ expect(clickSelection({ ids: ['a1'], anchor: 'gone' }, order, 'a3', shift)!.ids).toEqual(['a1', 'a3'])
+ })
+
+ it('a card that is not on the board is never selected', () => {
+ expect(clickSelection(sel(['a1']), order, 'ghost', cmd)).toBeNull()
+ })
+})
+
+describe('pruneSelection', () => {
+ it('returns the SAME state when every selected card is still on the board', () => {
+ const state = sel(['a1', 'b1'])
+ expect(pruneSelection(state, order)).toBe(state)
+ })
+
+ it('drops cards (and an anchor) that left the board — a filter, a delete', () => {
+ expect(pruneSelection({ ids: ['a1', 'b1'], anchor: 'b1' }, ['u1', 'a1'])).toEqual({ ids: ['a1'], anchor: null })
+ expect(pruneSelection(sel(['b1']), ['u1'])).toBe(NO_SELECTION)
+ })
+})
+
+describe('inBoardOrder / dragGroup', () => {
+ it('orders the selection as the board shows it, whatever order it was picked in', () => {
+ expect(inBoardOrder(order, ['b1', 'u1', 'a2'])).toEqual(['u1', 'a2', 'b1'])
+ })
+
+ it('dragging a selected card carries the whole selection, in board order', () => {
+ expect(dragGroup(order, ['b1', 'a1'], 'b1')).toEqual(['a1', 'b1'])
+ })
+
+ it('dragging an UNSELECTED card carries only that card', () => {
+ expect(dragGroup(order, ['b1', 'a1'], 'a3')).toEqual(['a3'])
+ expect(dragGroup(order, ['a1'], 'a1')).toEqual(['a1'])
+ })
+})
diff --git a/src/renderer/lib/cardSelection.ts b/src/renderer/lib/cardSelection.ts
new file mode 100644
index 000000000..d4491719c
--- /dev/null
+++ b/src/renderer/lib/cardSelection.ts
@@ -0,0 +1,80 @@
+/**
+ * Pure multi-select over the kanban board's session cards: which cards a click selects, and what
+ * survives when the board under the selection changes.
+ *
+ * `order` is always BOARD ORDER — the session cards on screen, column by column, top to bottom
+ * (the same list the board's J/K keys walk). A selection only ever names cards in it: a card a
+ * filter hid, a column the user collapsed away, or a node that was deleted is dropped, because a
+ * bulk action must never reach a card the user cannot see.
+ */
+
+/** What a click on a card asked for. */
+export interface SelectMods {
+ /** ⌘/Ctrl held: add or remove this one card. */
+ toggle: boolean
+ /** Shift held: extend from the anchor to this card. */
+ range: boolean
+}
+
+export interface SelectionState {
+ /** Selected card ids, in the order they were picked. */
+ ids: readonly string[]
+ /** The card a Shift-click extends from (the last card toggled by hand). */
+ anchor: string | null
+}
+
+export const NO_SELECTION: SelectionState = { ids: [], anchor: null }
+
+/**
+ * The selection after a click on `id`, or NULL when the click is not a selection gesture and the
+ * card should do what a click always did (open).
+ *
+ * - ⌘/Ctrl-click toggles the card and makes it the anchor;
+ * - Shift-click adds every card between the anchor and this one (board order, inclusive) — with
+ * no usable anchor it just selects this card;
+ * - a PLAIN click toggles too, but only while something is already selected: once you are picking
+ * cards, a click keeps picking instead of opening a modal over the selection.
+ */
+export function clickSelection(
+ state: SelectionState,
+ order: readonly string[],
+ id: string,
+ mods: SelectMods
+): SelectionState | null {
+ if (!order.includes(id)) return null
+ if (mods.range) {
+ const from = state.anchor === null ? -1 : order.indexOf(state.anchor)
+ if (from === -1) return { ids: state.ids.includes(id) ? state.ids : [...state.ids, id], anchor: id }
+ const to = order.indexOf(id)
+ const span = order.slice(Math.min(from, to), Math.max(from, to) + 1)
+ const have = new Set(state.ids)
+ return { ids: [...state.ids, ...span.filter((x) => !have.has(x))], anchor: state.anchor }
+ }
+ if (!mods.toggle && state.ids.length === 0) return null
+ return state.ids.includes(id)
+ ? { ids: state.ids.filter((x) => x !== id), anchor: id }
+ : { ids: [...state.ids, id], anchor: id }
+}
+
+/** Drop everything no longer on the board. Returns the SAME state when nothing was dropped. */
+export function pruneSelection(state: SelectionState, order: readonly string[]): SelectionState {
+ const live = new Set(order)
+ const ids = state.ids.filter((id) => live.has(id))
+ const anchor = state.anchor !== null && live.has(state.anchor) ? state.anchor : null
+ if (ids.length === state.ids.length && anchor === state.anchor) return state
+ return ids.length === 0 && anchor === null ? NO_SELECTION : { ids, anchor }
+}
+
+/** The selected cards in BOARD order — the order a bulk move keeps them in. */
+export function inBoardOrder(order: readonly string[], ids: readonly string[]): string[] {
+ const picked = new Set(ids)
+ return order.filter((id) => picked.has(id))
+}
+
+/**
+ * The cards a drag of `draggedId` carries: the whole selection when the dragged card is part of
+ * it, else just that card (dragging an unselected card never drags the selection along).
+ */
+export function dragGroup(order: readonly string[], ids: readonly string[], draggedId: string): string[] {
+ return ids.length > 1 && ids.includes(draggedId) ? inBoardOrder(order, ids) : [draggedId]
+}
diff --git a/src/renderer/lib/kanban.test.ts b/src/renderer/lib/kanban.test.ts
index 2c39b24c4..7f96757b0 100644
--- a/src/renderer/lib/kanban.test.ts
+++ b/src/renderer/lib/kanban.test.ts
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest'
import type { ProjectKanban } from '@shared/types'
import {
- addColumn, assignNode, assignedTo, defaultKanban, deleteColumn, moveColumn,
+ addColumn, assignNode, assignNodes, assignedTo, defaultKanban, deleteColumn, moveColumn,
cardMeta, columnForNode, nextColumnColor, pruneAssignments, recolorColumn, renameColumn,
setCardDue, setCardPriority, toggleAssignee, unassigned,
boardLabels, cardMatchesLabelFilter, createLabel, deleteLabel, labelColor, labelsForCard,
@@ -157,6 +157,51 @@ describe('assignments', () => {
expect(assignNode(board(), 'n1', 'nope', null)).toEqual(board())
expect(assignNode(board(), 'n1', 'a', 'n1')).toEqual(board())
})
+ // A multi-card move (selection drag, the bar's "Move to") lands the cards TOGETHER, in the order
+ // given, at every anchor — a loop of single moves would reverse them at the top.
+ describe('assignNodes', () => {
+ const wide = (): ProjectKanban => ({
+ columns: [
+ { id: 'a', title: 'To Do', color: '#0a84ff' },
+ { id: 'b', title: 'Doing', color: '#ffd60a' }
+ ],
+ assignments: ['a1', 'a2', 'a3', 'a4'].map((nodeId) => ({ nodeId, columnId: 'a' }))
+ .concat([{ nodeId: 'b1', columnId: 'b' }, { nodeId: 'b2', columnId: 'b' }])
+ })
+ it('unanchored: the group lands at the TOP in the order given', () => {
+ expect(assignedTo(assignNodes(wide(), ['a2', 'a4', 'u1'], 'b', null), 'b')).toEqual(['a2', 'a4', 'u1', 'b1', 'b2'])
+ })
+ it('at the column end: appended in the order given', () => {
+ const k = assignNodes(wide(), ['a1', 'a3'], 'b', AT_COLUMN_END)
+ expect(assignedTo(k, 'b')).toEqual(['b1', 'b2', 'a1', 'a3'])
+ expect(assignedTo(k, 'a')).toEqual(['a2', 'a4'])
+ })
+ it('before a card: the group sits just above it, in order', () => {
+ expect(assignedTo(assignNodes(wide(), ['a1', 'a3'], 'b', 'b2'), 'b')).toEqual(['b1', 'a1', 'a3', 'b2'])
+ })
+ it('reorders within one column', () => {
+ expect(assignedTo(assignNodes(wide(), ['a3', 'a4'], 'a', 'a1'), 'a')).toEqual(['a3', 'a4', 'a1', 'a2'])
+ })
+ it('an anchor that is itself moving resolves to the next card that stays (else the bottom)', () => {
+ expect(assignedTo(assignNodes(wide(), ['a1', 'a2'], 'a', 'a2'), 'a')).toEqual(['a1', 'a2', 'a3', 'a4'])
+ expect(assignedTo(assignNodes(wide(), ['a1', 'a4'], 'a', 'a4'), 'a')).toEqual(['a2', 'a3', 'a1', 'a4'])
+ expect(assignedTo(assignNodes(wide(), ['b1', 'a1'], 'a', 'a1'), 'a')).toEqual(['b1', 'a1', 'a2', 'a3', 'a4'])
+ })
+ it('to Ungrouped removes every assignment of the group, and only those', () => {
+ const k = assignNodes(wide(), ['a1', 'b2', 'u1'], null, null)
+ expect(k.assignments.map((a) => a.nodeId)).toEqual(['a2', 'a3', 'a4', 'b1'])
+ })
+ it('one card is assignNode; nothing to move, or an unknown column, is the SAME board', () => {
+ const k = wide()
+ expect(assignNodes(k, ['a1'], 'b', null)).toEqual(assignNode(k, 'a1', 'b', null))
+ expect(assignNodes(k, [], 'b', null)).toBe(k)
+ expect(assignNodes(k, ['a1', 'a2'], 'nope', null)).toBe(k)
+ expect(assignNodes(k, ['u1', 'u2'], null, null)).toBe(k)
+ })
+ it('a card named twice moves once', () => {
+ expect(assignedTo(assignNodes(wide(), ['a1', 'a1', 'a2'], 'b', AT_COLUMN_END), 'b')).toEqual(['b1', 'b2', 'a1', 'a2'])
+ })
+ })
it('pruneAssignments drops dead nodes, returns the same object when nothing changes', () => {
const k = pruneAssignments(board(), ['n1', 'n3'])
expect(k.assignments.map((a) => a.nodeId)).toEqual(['n1', 'n3'])
diff --git a/src/renderer/lib/kanban.ts b/src/renderer/lib/kanban.ts
index ce8465e89..42a7aa1a9 100644
--- a/src/renderer/lib/kanban.ts
+++ b/src/renderer/lib/kanban.ts
@@ -190,6 +190,41 @@ export function assignNode(
return assignments === k.assignments ? k : { ...k, assignments }
}
+/**
+ * Moves SEVERAL session cards in one go (a multi-card drag, the selection bar's "Move to"),
+ * landing them TOGETHER at the anchor and in the order given (callers pass board order).
+ *
+ * Same anchors as `assignNode`, with one addition: an anchor that is itself one of the moving
+ * cards cannot hold a place, so it resolves to the next card below it that stays (else the bottom).
+ * One card is exactly `assignNode`; nothing to move returns the SAME board.
+ */
+export function assignNodes(
+ k: ProjectKanban,
+ nodeIds: readonly string[],
+ columnId: string | null,
+ beforeNodeId: string | null | typeof AT_COLUMN_END
+): ProjectKanban {
+ const ids = [...new Set(nodeIds)]
+ if (ids.length === 0) return k
+ if (ids.length === 1) return assignNode(k, ids[0], columnId, beforeNodeId)
+ const moving = new Set(ids)
+ if (columnId === null) {
+ if (!k.assignments.some((a) => moving.has(a.nodeId))) return k
+ return { ...k, assignments: k.assignments.filter((a) => !moving.has(a.nodeId)) }
+ }
+ if (!k.columns.some((c) => c.id === columnId)) return k
+ const column = assignedTo(k, columnId)
+ let anchor = beforeNodeId
+ if (typeof anchor === 'string' && moving.has(anchor)) {
+ const at = column.indexOf(anchor)
+ anchor = at === -1 ? null : column.slice(at + 1).find((id) => !moving.has(id)) ?? AT_COLUMN_END
+ }
+ // Unanchored = the TOP, where each card lands above the one before it: place them last-first so
+ // the group reads top-down in the order given. Every other anchor stays put while cards arrive.
+ const atTop = anchor === null || (typeof anchor === 'string' && !column.includes(anchor))
+ return (atTop ? [...ids].reverse() : ids).reduce((acc, id) => assignNode(acc, id, columnId, anchor), k)
+}
+
/** Drops assignments of nodes that no longer exist. Returns the SAME object when nothing
* changed, so callers can cheaply skip a no-op persist. */
export function pruneAssignments(k: ProjectKanban, liveIds: string[]): ProjectKanban {
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 5d8de15f9..5f039a06a 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -14916,6 +14916,78 @@ button.pull-checks__name {
outline-offset: 1px;
}
+/* ── Board multi-select (⌘/Ctrl-click, Shift-click) ──
+ A selected card wears the accent; the bar that acts on the selection floats bottom-centre, in a
+ body portal above the board (25) and its controls (26), under the menus and dialogs (40+). */
+.kanban-card--selected,
+.kanban-card--selected:hover {
+ border-color: var(--accent);
+ background: color-mix(in srgb, var(--accent) 16%, rgba(var(--tint-rgb), 0.08));
+ box-shadow: 0 0 0 1px var(--accent);
+}
+:root[data-nt-glass='on'] .kanban-card--selected,
+:root[data-nt-glass='on'] .kanban-card--selected:hover {
+ border-color: var(--accent);
+ background:
+ linear-gradient(
+ color-mix(in srgb, var(--accent) 20%, transparent),
+ color-mix(in srgb, var(--accent) 20%, transparent)
+ ),
+ var(--glass-lift);
+}
+.kanban-select-bar {
+ position: fixed;
+ left: 50%;
+ bottom: 28px;
+ transform: translateX(-50%);
+ z-index: 27;
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ max-width: calc(100vw - 32px);
+ padding: 6px 6px 6px 14px;
+ background: rgba(var(--menu-rgb), 0.98);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ box-shadow: 0 12px 36px rgba(0, 0, 0, calc(0.55 * var(--shadow-k)));
+ color: var(--text-strong);
+ font-size: 12px;
+ white-space: nowrap;
+ -webkit-app-region: no-drag;
+}
+.kanban-select-bar__count {
+ font-weight: 600;
+ margin-right: 6px;
+}
+.kanban-select-bar__btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ background: rgba(var(--tint-rgb), 0.07);
+ border: 1px solid rgba(var(--tint-rgb), 0.12);
+ border-radius: 8px;
+ color: inherit;
+ font-size: 12px;
+ padding: 5px 10px;
+ cursor: pointer;
+}
+.kanban-select-bar__btn:hover {
+ background: rgba(var(--tint-rgb), 0.14);
+}
+.kanban-select-bar__btn--danger {
+ color: var(--danger);
+}
+.kanban-select-bar__btn--danger:hover {
+ background: color-mix(in srgb, var(--state-error) 15%, transparent);
+ border-color: color-mix(in srgb, var(--state-error) 40%, transparent);
+}
+.kanban-select-bar__clear {
+ padding: 5px 6px;
+ background: transparent;
+ border-color: transparent;
+ color: rgba(var(--tint-rgb), 0.7);
+}
+
/* ── Board status chips (header) — transient filters on live agent state ── */
.kanban-status-chips {
display: inline-flex;