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): keep the modal's resize handles above the ⌘M view

review2678421f170e
diff --git a/CLAUDE.md b/CLAUDE.md
index 306be5fe1..2854fcc45 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -4751,13 +4751,15 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord mea
overlay z is 60, ABOVE the modal scrim; ✦ `pty.generateName` through the modal rename funnel;
and the **⌘M view** — a header toggle (`IconMarkdown`) plus the chord, which lays the SAME face
the canvas node shows over the live viewer: `ChatPanel` when `canChat(created agent)` and the
- session id is known, else `TerminalMarkdownView`. Three rules: the state is MODAL-LOCAL, keyed by
- node id (never `data.mdMode` — that would flip the canvas node under the board too); the viewer
+ session id is known, else `TerminalMarkdownView`. Three rules: the state is MODAL-LOCAL and per OPENING
+ (never `data.mdMode` — that would flip the canvas node under the board too); the viewer
stays MOUNTED underneath (covered, not swapped, so its co-attach never detaches/re-attaches) and
gets the same focus hand-off as the node (`ModalTerminal`'s `covered` → `useMdModeFocus`); and the
chord reaches the modal through `window.nodeTerminal.onMarkdownToggle` only while it is the top
- dialog, while the canvas node's own subscription refuses the chord whenever a board is up — a
- hover flag can go stale under the opaque board, so one press could otherwise flip both).
+ dialog, while the canvas node's own subscription refuses the chord whenever a board is up
+ (`lib/markdownChord.ts` `canvasOwnsMarkdownChord` — a hover flag can go stale under the opaque
+ board, so one press could otherwise flip both). The overlay sits at z 5 in the pane, BELOW the
+ sheet's resize handles (z 6/7, issue #389) — pinned in `styles.kanban.test.ts`.
**The 💬 icon means COMMENTS on both surfaces** (repurposed from the markdown view — ⌘M still
toggles markdown/chat on the canvas node, and on the card modal): on a terminal node it opens a right-side comments
flyout (`.term-node__comments`, a sibling of the overflow:hidden root, hosting BoardLogPanel
diff --git a/src/renderer/components/kanban/CardModal.test.tsx b/src/renderer/components/kanban/CardModal.test.tsx
index 7eba307de..9b640ad70 100644
--- a/src/renderer/components/kanban/CardModal.test.tsx
+++ b/src/renderer/components/kanban/CardModal.test.tsx
@@ -4,8 +4,6 @@ import { createRoot } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { ProjectKanban } from '@shared/types'
import { pushDialog, popDialog, resetDialogStack } from '../dialog-stack'
-import { readFileSync } from 'node:fs'
-import { resolve } from 'node:path'
import { useAgentStatus } from '../../state/agentStatus'
import { CardModal } from './CardModal'
import type { KanbanSession } from './KanbanView'
@@ -617,13 +615,16 @@ describe('CardModal', () => {
act(() => root.unmount())
})
- it('the view is per card: switching cards does not carry it onto the next one', () => {
+ it('the view is per opening: switching cards neither carries it over nor brings it back (A → B → A)', () => {
const root = createRoot(host)
render(root, termSession({ agentId: undefined, spawn: {} }))
act(() => toggle().click())
expect(document.body.querySelector('.md-view-mock')).toBeTruthy()
render(root, termSession({ id: 'node-md-2', agentId: undefined, spawn: {} }))
expect(document.body.querySelector('.md-view-mock')).toBeNull()
+ // …and it is per OPENING: coming back to the first card shows its live terminal again.
+ render(root, termSession({ agentId: undefined, spawn: {} }))
+ expect(document.body.querySelector('.md-view-mock')).toBeNull()
act(() => root.unmount())
})
@@ -636,16 +637,5 @@ describe('CardModal', () => {
expect(search().disabled).toBe(true)
act(() => root.unmount())
})
-
- it('the canvas node refuses the chord while a board is up (no double toggle under the modal)', () => {
- // Source pin: TerminalNode is a 6000-line component that cannot be mounted here. Its hover
- // flag can be stale under the opaque board, so the refusal must stay in its subscription.
- const src = readFileSync(resolve(__dirname, '../../nodes/TerminalNode.tsx'), 'utf8').replace(/\r\n/g, '\n')
- const at = src.indexOf('window.nodeTerminal.onMarkdownToggle(')
- expect(at).toBeGreaterThan(0)
- const body = src.slice(at, at + 400)
- expect(body).toMatch(/isGlobalKanbanOpen\(\) \|\| isKanbanOpen\(/)
- expect(body.indexOf('isGlobalKanbanOpen')).toBeLessThan(body.indexOf('updateNodeData'))
- })
})
})
diff --git a/src/renderer/components/kanban/CardModal.tsx b/src/renderer/components/kanban/CardModal.tsx
index 0c49c4887..0a2daeffc 100644
--- a/src/renderer/components/kanban/CardModal.tsx
+++ b/src/renderer/components/kanban/CardModal.tsx
@@ -111,6 +111,12 @@ export function CardModal({ session, columnTitle, board, onChangeBoard, onClose,
// a bare boolean would carry the open view onto the next card the user opens).
const [mdFor, setMdFor] = useState<string | null>(null)
const mdOpen = isTerminal && mdFor === session.id
+ // Per OPENING, not sticky per card: showing another card resets it, so A → B → A comes back to
+ // A's live terminal. (The id key above is what keeps the render between the switch and this
+ // reset from flashing the view onto the new card.)
+ useEffect(() => {
+ setMdFor(null)
+ }, [session.id])
const toggleMd = useCallback(() => {
setMdFor((cur) => (cur === session.id ? null : session.id))
setSearchOpen(false) // the FindBar searches the xterm the view now covers
diff --git a/src/renderer/lib/markdownChord.test.ts b/src/renderer/lib/markdownChord.test.ts
new file mode 100644
index 000000000..b8bae2e51
--- /dev/null
+++ b/src/renderer/lib/markdownChord.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { resolve } from 'node:path'
+import { canvasOwnsMarkdownChord } from './markdownChord'
+
+describe('canvasOwnsMarkdownChord', () => {
+ it('a hovered node takes the chord when no board is up', () => {
+ expect(canvasOwnsMarkdownChord(true, false)).toBe(true)
+ })
+
+ it('a node that is not hovered never does', () => {
+ expect(canvasOwnsMarkdownChord(false, false)).toBe(false)
+ expect(canvasOwnsMarkdownChord(false, true)).toBe(false)
+ })
+
+ it('a (possibly stale) hovered node under a board refuses — the card modal owns the chord there', () => {
+ expect(canvasOwnsMarkdownChord(true, true)).toBe(false)
+ })
+
+ it('is what the canvas node subscription asks (one-line wiring pin)', () => {
+ const src = readFileSync(resolve(__dirname, '../nodes/TerminalNode.tsx'), 'utf8').replace(/\r\n/g, '\n')
+ expect(src).toMatch(
+ /onMarkdownToggle\(\(\) => \{\s*if \(!canvasOwnsMarkdownChord\(hoveredRef\.current, isGlobalKanbanOpen\(\) \|\| isKanbanOpen\(/
+ )
+ })
+})
diff --git a/src/renderer/lib/markdownChord.ts b/src/renderer/lib/markdownChord.ts
new file mode 100644
index 000000000..9d3ac5f54
--- /dev/null
+++ b/src/renderer/lib/markdownChord.ts
@@ -0,0 +1,13 @@
+/**
+ * Whether the CANVAS terminal node owns a ⌘M (`node.toggleMarkdown`) press.
+ *
+ * Only a hovered node takes the chord — and never while a kanban board is up. The board is an
+ * opaque overlay over a still-mounted canvas, and a node's hover flag is driven by mouseenter /
+ * mouseleave: a node that was under the pointer when the board opened (⌘⇧B) gets no guaranteed
+ * mouseleave until the pointer moves, so its flag can read "hovered" under the board. The card
+ * modal owns the chord there (its own ⌘M view); without this refusal one press would flip both
+ * the hidden node and the modal.
+ */
+export function canvasOwnsMarkdownChord(hovered: boolean, boardUp: boolean): boolean {
+ return hovered && !boardUp
+}
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 2cdfc9f61..0340ec3b5 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -175,6 +175,7 @@ import { WakeInputBuffer } from '../terminal/wake-input-buffer'
import { FindBar } from '../components/FindBar'
import { TerminalMarkdownView } from './TerminalMarkdownView'
import { focusXtermUnlessCovered, useMdModeFocus } from '../terminal/useMdModeFocus'
+import { canvasOwnsMarkdownChord } from '../lib/markdownChord'
import { IconChat, IconChevronDown, IconChevronRight, IconClose, IconEye, IconEyeOff, IconGrid, IconMic, IconMoveTo, IconPlay, IconReload, IconSearch, IconSparkle } from '../components/icons'
import { NodeLabels } from '../components/kanban/NodeLabels'
import { Tooltip } from '../components/Tooltip'
@@ -5278,14 +5279,11 @@ export function TerminalNode({
}
}, [id, canReadTitleNode, status?.sessionId, data.titleAuto, updateNodeData])
- // Cmd/Ctrl+M toggles markdown view of this terminal's output (only when hovered). NOT while a
- // board covers the canvas: the kanban card modal owns the chord then (its own ⌘M view), and a
- // hover flag can be stale under the opaque board — the pointer never "left" a node that was
- // covered while hovered, so one press would flip the hidden node AND the modal.
+ // Cmd/Ctrl+M toggles markdown view of this terminal's output — only when hovered, and never while
+ // a board is up (the card modal owns the chord there; see `canvasOwnsMarkdownChord`).
useEffect(() => {
return window.nodeTerminal.onMarkdownToggle(() => {
- if (!hoveredRef.current) return
- if (isGlobalKanbanOpen() || isKanbanOpen(useProjects.getState().activeProjectId ?? '')) return
+ if (!canvasOwnsMarkdownChord(hoveredRef.current, isGlobalKanbanOpen() || isKanbanOpen(useProjects.getState().activeProjectId ?? ''))) return
updateNodeData(id, (n) => ({ mdMode: !n.data.mdMode }))
})
}, [id, updateNodeData])
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 15201c9e0..e748866fd 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -2990,16 +2990,20 @@ body,
cursor: default;
}
-/* "Capturing…" / "Nothing captured…" / a failed capture — a sentence, not rendered output. */
+/* "Capturing…" / "Nothing captured…" / a failed capture or render — a sentence, not rendered output. */
.term-md__content--placeholder {
color: var(--muted);
}
-/* The kanban card modal lays the same ⌘M face over its live viewer (the pane anchors it). Above
- the viewer's own floating bits (FindBar, copy pill, upload note), which share that pane. */
+/* The kanban card modal lays the same ⌘M face over its live viewer (the pane anchors it). z 5, NOT
+ higher: the pane is flush with the sheet's edges and shares its stacking context with the resize
+ handles (`.kanban-modal__resize`, z 6 edge strips / z 7 corners, issue #389) — anything above 6
+ covers them and resize dies while the view is open. 5 still covers the viewer's floating bits:
+ the copy pill (z 5) loses to this later DOM sibling, the upload note is z 4, and the FindBar is
+ closed while the view covers the terminal. */
.kanban-modal__pane > .term-md,
.kanban-modal__pane > .term-chat {
- z-index: 20;
+ z-index: 5;
}
.term-md__content {
diff --git a/src/renderer/styles.kanban.test.ts b/src/renderer/styles.kanban.test.ts
index 4f0db3948..0b00c9232 100644
--- a/src/renderer/styles.kanban.test.ts
+++ b/src/renderer/styles.kanban.test.ts
@@ -19,3 +19,33 @@ describe('Kanban column row layout', () => {
)
})
})
+
+describe('Card modal ⌘M view stacking (issue #389 resize handles)', () => {
+ // Comments stripped first: the rule's own comment names the numbers it pins.
+ const bare = CSS.replace(/\/\*[\s\S]*?\*\//g, '')
+ const zOf = (re: RegExp): number => {
+ const m = bare.match(re)
+ expect(m, `rule not found: ${re}`).toBeTruthy()
+ return Number(m![1])
+ }
+
+ it('lays the ⌘M face BELOW the sheet\'s resize handles, so resize keeps working while it is open', () => {
+ const overlay = zOf(
+ /\.kanban-modal__pane > \.term-md,\s*\.kanban-modal__pane > \.term-chat\s*{[^}]*z-index:\s*(\d+)/
+ )
+ const edges = zOf(/\.kanban-modal__resize\s*{[^}]*z-index:\s*(\d+)/)
+ const corners = zOf(/\.kanban-modal__resize--sw\s*{[^}]*z-index:\s*(\d+)/)
+ expect(overlay).toBeLessThan(edges)
+ expect(overlay).toBeLessThan(corners)
+ })
+
+ it('still covers the viewer\'s copy pill and upload note (it is the later sibling, so equal z wins)', () => {
+ const overlay = zOf(
+ /\.kanban-modal__pane > \.term-md,\s*\.kanban-modal__pane > \.term-chat\s*{[^}]*z-index:\s*(\d+)/
+ )
+ const pill = zOf(/\.term-copy-pill\s*{[^}]*z-index:\s*(\d+)/)
+ const upload = zOf(/\.kanban-modal__upload\s*{[^}]*z-index:\s*(\d+)/)
+ expect(overlay).toBeGreaterThanOrEqual(pill)
+ expect(overlay).toBeGreaterThanOrEqual(upload)
+ })
+})