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): color and delete in the card modal header

Mina Sameh1e4f2b8c9d0c
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 61a7c5181..123f13fd0 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -10394,6 +10394,15 @@ export function Canvas() {
buildNodeActionItems([nodeId], undefined, nodeActionCtxFor(projectId), { allow: BOARD_NODE_ACTION_IDS }),
[nodeActionCtxFor]
)
+ // A card's color (the card modal's Color button), through the card's project's write router.
+ const setCardColor = useCallback(
+ (projectId: string, nodeId: string, color: string) => nodeWritesFor(projectId).setColor([nodeId], color),
+ [nodeWritesFor]
+ )
+ const setActiveCardColor = useCallback(
+ (nodeId: string, color: string) => setCardColor(activeProjectId, nodeId, color),
+ [setCardColor, activeProjectId]
+ )
// Stable identity for the memoized per-project board, which only ever shows the active project.
const activeBoardNodeActionItems = useCallback(
(nodeId: string): MenuItem[] => boardNodeActionItems(nodeId, activeProjectId),
@@ -18478,6 +18487,7 @@ export function Canvas() {
onModalNodeChange={setKanbanModalNode}
nodeActionItems={boardNodeActionItems}
onAiName={aiNameFromKanban}
+ onSetColor={setCardColor}
/>
) : perProjectKanbanOpen && (
<KanbanView
@@ -18494,6 +18504,7 @@ export function Canvas() {
onSetIcon={setNodeIcon}
nodeActionItems={activeBoardNodeActionItems}
onAiName={aiNameFromActiveKanban}
+ onSetColor={setActiveCardColor}
onAutoMoveFromPulls={autoMoveCardFromPulls}
issueAgentMenu={issueAgentMenu}
issueWorktreeMenu={issueWorktreeMenu}
diff --git a/src/renderer/components/kanban/CardModal.actions.test.tsx b/src/renderer/components/kanban/CardModal.actions.test.tsx
new file mode 100644
index 000000000..bbaff1b37
--- /dev/null
+++ b/src/renderer/components/kanban/CardModal.actions.test.tsx
@@ -0,0 +1,101 @@
+// @vitest-environment jsdom
+//
+// Card modal parity with the canvas node: open on the ⌘M view when the card menu asked for it,
+// set the node's color, and delete through the board's confirm — closing the modal first.
+import { act } from 'react'
+import { createRoot, type Root } from 'react-dom/client'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import type { ProjectKanban } from '@shared/types'
+import { resetDialogStack } from '../dialog-stack'
+import { CardModal } from './CardModal'
+import type { KanbanSession } from './KanbanView'
+
+vi.mock('../../session/session', () => ({
+ useSession: () => ({ api: { pty: { generateName: vi.fn() }, shell: { openExternal: vi.fn() } } })
+}))
+vi.mock('./BoardLogPanel', () => ({ BoardLogPanel: () => null }))
+vi.mock('./CardMetaBar', () => ({ CardMetaBar: () => null }))
+vi.mock('../ContextMeter', () => ({ ContextMeter: () => null }))
+vi.mock('./ModalTerminal', () => ({ ModalTerminal: () => <div className="kanban-modal__term" /> }))
+vi.mock('../../nodes/TerminalMarkdownView', () => ({
+ TerminalMarkdownView: () => <div className="md-view-mock" />
+}))
+vi.mock('../../nodes/ChatPanel', () => ({ ChatPanel: () => <div className="chat-panel-mock" /> }))
+
+const board: ProjectKanban = { columns: [{ id: 'c1', title: 'To Do', color: '#fff' }], assignments: [] }
+const session: KanbanSession = { id: 'n1', title: 'Shell', color: '#fff', kind: 'terminal', spawn: { cwd: '/p' } }
+
+let root: Root
+let host: HTMLDivElement
+beforeEach(() => {
+ resetDialogStack()
+ ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+ vi.stubGlobal('ResizeObserver', class { observe(): void {} unobserve(): void {} disconnect(): void {} })
+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = { onMarkdownToggle: () => () => {} }
+ host = document.createElement('div')
+ document.body.append(host)
+ root = createRoot(host)
+})
+afterEach(() => {
+ act(() => root.unmount())
+ resetDialogStack()
+ document.body.innerHTML = ''
+ vi.unstubAllGlobals()
+})
+
+function render(extra: Partial<Parameters<typeof CardModal>[0]> = {}): void {
+ act(() =>
+ root.render(
+ <CardModal
+ projectId="p1"
+ session={session}
+ columnTitle="To Do"
+ board={board}
+ onChangeBoard={vi.fn()}
+ onClose={vi.fn()}
+ onOpenCanvas={vi.fn()}
+ onRename={vi.fn()}
+ onEditSticky={vi.fn()}
+ onSetIcon={vi.fn()}
+ onBrowserNav={vi.fn()}
+ {...extra}
+ />
+ )
+ )
+}
+const button = (label: string): HTMLButtonElement | null =>
+ document.body.querySelector<HTMLButtonElement>(`button[aria-label="${label}"]`)
+
+describe('CardModal — node actions in the header', () => {
+ it('opens on the live terminal by default', () => {
+ render()
+ expect(document.querySelector('.md-view-mock')).toBeNull()
+ })
+
+ it('opens on the ⌘M view when the card menu asked for it', () => {
+ render({ initialView: 'md' })
+ expect(document.querySelector('.md-view-mock')).not.toBeNull()
+ expect(button('Markdown view')?.getAttribute('aria-pressed')).toBe('true')
+ })
+
+ it('Color opens the swatches and writes the picked color', () => {
+ const onSetColor = vi.fn()
+ render({ onSetColor })
+ act(() => button('Color')!.click())
+ act(() => document.body.querySelector<HTMLButtonElement>('button[aria-label="Blue"]')!.click())
+ expect(onSetColor).toHaveBeenCalledWith('#0a84ff')
+ })
+
+ it('Delete closes the modal first, then asks the board (whose Delete confirms)', () => {
+ const order: string[] = []
+ render({ onClose: () => order.push('close'), onDelete: () => order.push('delete') })
+ act(() => button('Delete')!.click())
+ expect(order).toEqual(['close', 'delete'])
+ })
+
+ it('no Color or Delete button without a handler', () => {
+ render()
+ expect(button('Color')).toBeNull()
+ expect(button('Delete')).toBeNull()
+ })
+})
diff --git a/src/renderer/components/kanban/CardModal.tsx b/src/renderer/components/kanban/CardModal.tsx
index 59fdeb262..09834b7f0 100644
--- a/src/renderer/components/kanban/CardModal.tsx
+++ b/src/renderer/components/kanban/CardModal.tsx
@@ -5,14 +5,17 @@ import {
IconBroadcast,
IconChat,
IconClose,
+ IconColor,
IconExternal,
IconMarkdown,
IconMaximize,
IconMic,
IconRestoreSize,
IconSearch,
- IconSmiley
+ IconSmiley,
+ IconTrash
} from '../icons'
+import { ContextMenu } from '../ContextMenu'
import { NodeIconView } from '../NodeIcon'
import { nodeIconDialog } from '../NodeIconPicker'
import { applyIconChoice } from '../../lib/nodeIconChoice'
@@ -121,13 +124,18 @@ interface CardModalProps {
initialView?: 'md'
/** A station was picked from the ring's list: close the modal and go to that node. */
onTravel?: (nodeId: string) => void
+ /** The node's color — the canvas node menu's Colors, as a header action. Absent = no button. */
+ onSetColor?: (color: string) => void
+ /** Delete the node through the board's own confirm-first Delete. The modal closes FIRST, so the
+ * confirm is never drawn over a live view of the session it is about to end. Absent = no button. */
+ onDelete?: () => void
}
/** Trello-style card popup over the board. Scrim click / Esc close it; the board (and the
* canvas under it) stay mounted. Terminal cards carry the node header's actions too:
* search / dictate / AI-name / the ⌘M view — ChatPanel or the output markdown, the same face the
* canvas node shows (the node itself is hidden under the board). */
-export function CardModal({ session, projectId, projectName, projectColor, columnTitle, board, onChangeBoard, onClose, portsProjectId, onOpenCanvas, onRename, onEditSticky, onBrowserNav, onSetIcon, onOpenIssue, mentionables, team, onTravel, initialView }: CardModalProps) {
+export function CardModal({ session, projectId, projectName, projectColor, columnTitle, board, onChangeBoard, onClose, portsProjectId, onOpenCanvas, onRename, onEditSticky, onBrowserNav, onSetIcon, onOpenIssue, mentionables, team, onTravel, initialView, onSetColor, onDelete }: CardModalProps) {
const { api } = useSession()
// The header slot decides "icon or smiley" on the NORMALIZED value, the answer NodeIconView
// itself gives — on the raw one, an invalid stored icon drew an empty, un-muted slot.
@@ -169,6 +177,8 @@ export function CardModal({ session, projectId, projectName, projectColor, colum
const portsRemote = useProjects((s) => !!(portsProjectId && s.getProject(portsProjectId)?.ssh))
const accountChip = useAccountChip(session.spawn.accountId, observedAccount)
const [naming, setNaming] = useState(false)
+ // The header Color button's swatch menu, anchored under the button.
+ const [colorMenu, setColorMenu] = useState<{ x: number; y: number } | null>(null)
// Comments & activity panel: OPEN by default in the modal; the header 💬 collapses it. The
// choice is remembered (localStorage) — once collapsed, later cards open collapsed too.
const panelOpen = useCardPanel((s) => s.open)
@@ -575,6 +585,19 @@ export function CardModal({ session, projectId, projectName, projectColor, colum
</button>
</>
)}
+ {onSetColor && (
+ <button
+ className="kanban-modal__action"
+ title="Color"
+ aria-label="Color"
+ onClick={(e) => {
+ const r = e.currentTarget.getBoundingClientRect()
+ setColorMenu({ x: r.left, y: r.bottom })
+ }}
+ >
+ <IconColor />
+ </button>
+ )}
<button
className="kanban-modal__action"
title={panelOpen ? 'Hide comments & activity' : 'Show comments & activity'}
@@ -594,10 +617,32 @@ export function CardModal({ session, projectId, projectName, projectColor, colum
<button className="kanban-modal__action" title="Open on canvas" onClick={onOpenCanvas}>
<IconExternal />
</button>
+ {onDelete && (
+ <button
+ className="kanban-modal__action"
+ title="Delete this session"
+ aria-label="Delete"
+ onClick={() => {
+ onClose()
+ onDelete()
+ }}
+ >
+ <IconTrash />
+ </button>
+ )}
<button className="kanban-modal__action" title="Close" onClick={onClose}>
<IconClose />
</button>
</div>
+ {colorMenu && onSetColor && (
+ <ContextMenu
+ x={colorMenu.x}
+ y={colorMenu.y}
+ zIndex={65}
+ items={[{ type: 'colors', onPick: onSetColor }]}
+ onClose={() => setColorMenu(null)}
+ />
+ )}
<CardMetaBar nodeId={session.id} board={board} onChange={onChangeBoard} />
<CardPullRequests session={session} board={board} onChangeBoard={onChangeBoard} />
<div className="kanban-modal__body">
diff --git a/src/renderer/components/kanban/GlobalKanbanView.tsx b/src/renderer/components/kanban/GlobalKanbanView.tsx
index fd94c7987..91cbe81e4 100644
--- a/src/renderer/components/kanban/GlobalKanbanView.tsx
+++ b/src/renderer/components/kanban/GlobalKanbanView.tsx
@@ -90,10 +90,12 @@ interface SwimlaneProps {
nodeActionItems?: (nodeId: string, projectId: string) => MenuItem[]
/** "Name with AI" on a card of this lane. */
onAiName?: (projectId: string, nodeId: string) => void
+ /** Set a card's node color (the card modal's Color button), routed by the lane's project. */
+ onSetColor?: (projectId: string, nodeId: string, color: string) => void
}
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, onAiName
+ projectId, projectName, projectIndex, projectColor, board, sessions, ropes, nodes, onChangeBoard, onOpenNode, onCreateNode, onDeleteNode, onRenameNode, onEditSticky, onBrowserNav, onSetIcon, modalNodeId, modalView, onModalChange, liveTeams, highlight, nodeActionItems, onAiName, onSetColor
}: SwimlaneProps) {
const dragRef = useRef<{ kind: 'column'; id: string } | { kind: 'card'; id: string } | null>(null)
const setModalNodeId = useCallback(
@@ -336,6 +338,8 @@ const Swimlane = memo(function Swimlane({
onEditSticky={(t) => onEditSticky(projectId, modalNodeId, t)}
onBrowserNav={(patch) => onBrowserNav(projectId, modalNodeId, patch)}
onSetIcon={(icon) => onSetIcon(projectId, modalNodeId, icon)}
+ onSetColor={onSetColor ? (color) => onSetColor(projectId, modalNodeId, color) : undefined}
+ onDelete={() => onDeleteNode(projectId, modalNodeId)}
team={teams.get(modalNodeId) ?? NO_STATIONS}
onTravel={(nodeId) => { setModalNodeId(null); travel(nodeId) }}
/>
@@ -364,13 +368,15 @@ export interface GlobalKanbanViewProps {
nodeActionItems?: (nodeId: string, projectId: string) => MenuItem[]
/** Canvas's "Name with AI" for a card of any lane (`aiNameFromKanban`). Optional. */
onAiName?: (projectId: string, nodeId: string) => void
+ /** Canvas's color write for a card of any lane (`setCardColor`, routed per project). Optional. */
+ onSetColor?: (projectId: string, nodeId: string, color: string) => void
/** 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, nodeActionItems, onAiName }: GlobalKanbanViewProps) {
+export const GlobalKanbanView = memo(function GlobalKanbanView({ live = null, onModalNodeChange, nodeActionItems, onAiName, onSetColor }: GlobalKanbanViewProps) {
// Same rule as the per-project board: the canvas is covered but mounted underneath.
useEffect(() => markCanvasCovered(document.documentElement), [])
const boardStyle = useBoardWallpaperStyle()
@@ -525,6 +531,7 @@ export const GlobalKanbanView = memo(function GlobalKanbanView({ live = null, on
highlight={highlightId === p.id}
nodeActionItems={nodeActionItems}
onAiName={onAiName}
+ onSetColor={onSetColor}
/>
)
})}
diff --git a/src/renderer/components/kanban/KanbanView.accountMenu.test.tsx b/src/renderer/components/kanban/KanbanView.accountMenu.test.tsx
index 0261cd7fd..498ac38ba 100644
--- a/src/renderer/components/kanban/KanbanView.accountMenu.test.tsx
+++ b/src/renderer/components/kanban/KanbanView.accountMenu.test.tsx
@@ -15,8 +15,11 @@ vi.mock('../../session/session', () => ({
useSession: () => ({ source: 'local', api: window.nodeTerminal })
}))
vi.mock('./CardModal', () => ({
- CardModal: (p: { session: { id: string }; initialView?: string }) => (
- <div className="card-modal-mock" data-node={p.session.id} data-view={p.initialView ?? ''} />
+ CardModal: (p: { session: { id: string }; initialView?: string; onDelete?: () => void; onSetColor?: (c: string) => void }) => (
+ <div className="card-modal-mock" data-node={p.session.id} data-view={p.initialView ?? ''}>
+ <button className="modal-delete" onClick={p.onDelete} />
+ <button className="modal-color" onClick={() => p.onSetColor?.('#0a84ff')} />
+ </div>
)
}))
@@ -54,7 +57,11 @@ afterEach(() => {
vi.unstubAllGlobals()
})
-function render(nodeActionItems?: (id: string) => MenuItem[], onAiName?: (id: string) => void): void {
+function render(
+ nodeActionItems?: (id: string) => MenuItem[],
+ onAiName?: (id: string) => void,
+ more: { onDeleteNode?: (id: string) => void; onSetColor?: (id: string, c: string) => void } = {}
+): void {
host = document.createElement('div')
document.body.appendChild(host)
root = createRoot(host)
@@ -69,7 +76,8 @@ function render(nodeActionItems?: (id: string) => MenuItem[], onAiName?: (id: st
onCreateNode={noop}
onRenameNode={noop}
onEditSticky={noop}
- onDeleteNode={noop}
+ onDeleteNode={more.onDeleteNode ?? noop}
+ onSetColor={more.onSetColor}
onModalNodeChange={noop}
onBrowserNav={noop}
onSetIcon={noop}
@@ -136,4 +144,16 @@ describe('KanbanView — card menu node rows', () => {
clickRow('Name with AI')
expect(ai).toHaveBeenCalledWith('n1')
})
+
+ it("the card modal's Delete and Color reach the board handlers for THAT card", () => {
+ const del = vi.fn()
+ const color = vi.fn()
+ render(undefined, undefined, { onDeleteNode: del, onSetColor: color })
+ openCardMenu()
+ clickRow('Open card')
+ act(() => document.querySelector<HTMLButtonElement>('.modal-color')!.click())
+ act(() => document.querySelector<HTMLButtonElement>('.modal-delete')!.click())
+ expect(color).toHaveBeenCalledWith('n1', '#0a84ff')
+ expect(del).toHaveBeenCalledWith('n1')
+ })
})
diff --git a/src/renderer/components/kanban/KanbanView.tsx b/src/renderer/components/kanban/KanbanView.tsx
index 672ae86e2..aaa8841d9 100644
--- a/src/renderer/components/kanban/KanbanView.tsx
+++ b/src/renderer/components/kanban/KanbanView.tsx
@@ -140,6 +140,8 @@ export interface KanbanViewProps {
nodeActionItems?: (nodeId: string) => MenuItem[]
/** "Name with AI" on a card (Canvas `aiNameSession`, the sessions sidebar's funnel). Optional. */
onAiName?: (nodeId: string) => void
+ /** Set a card's node color — the card modal's Color button. Optional: no button without it. */
+ onSetColor?: (nodeId: string, color: string) => void
/** The board moving a session card itself because its linked pull requests merged (Canvas owns
* the compare-and-set + board-log line). Optional: without it nothing ever auto-moves. */
onAutoMoveFromPulls?: (
@@ -239,7 +241,7 @@ function useCanvasCovered(): void {
export const KanbanView = memo(function KanbanView({
board, sessions, onChange, onOpenNode, onCreateNode, onRenameNode, onEditSticky, onDeleteNode,
- onModalNodeChange, onBrowserNav, onSetIcon, nodeActionItems, onAiName, onAutoMoveFromPulls, issueAgentMenu,
+ onModalNodeChange, onBrowserNav, onSetIcon, nodeActionItems, onAiName, onSetColor, onAutoMoveFromPulls, issueAgentMenu,
issueWorktreeMenu, teams, onIssueMoved
}: KanbanViewProps) {
useCanvasCovered()
@@ -1269,6 +1271,8 @@ export const KanbanView = memo(function KanbanView({
onEditSticky={(t) => onEditSticky(modalNodeId, t)}
onBrowserNav={(patch) => onBrowserNav(modalNodeId, patch)}
onSetIcon={(icon) => onSetIcon(modalNodeId, icon)}
+ onSetColor={onSetColor ? (color) => onSetColor(modalNodeId, color) : undefined}
+ onDelete={() => onDeleteNode(modalNodeId)}
onOpenIssue={(ref) => {
// The issue summary is its own modal: close the card, then ask for the issue (the same
// request the session card's `#N` makes — summary if the lane has it, else GitHub).