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(chat): keep the ⌘M view open across a project switch and a reload

Daniel Acevedo57bf90d077c6
diff --git a/CLAUDE.md b/CLAUDE.md
index 8a2e37222..d8c90ca83 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1791,7 +1791,9 @@ number: change the table in that one module, never in one emulator.
of a text field elsewhere; a lazy-loading or disabled composer takes it when it mounts/enables,
and an exit cancels the request); leaving it restores focus
only if the terminal had it on entry AND focus is now nowhere or still inside this node
- (`terminal/useMdModeFocus.ts`). While the view is open, every "take the keyboard" path (hover
+ (`terminal/useMdModeFocus.ts`). The open view is PERSISTED (`CanvasNodeState.mdMode`, written only
+ when open), so a project switch or a reload brings the node back on the view it was left on.
+ While the view is open, every "take the keyboard" path (hover
dwell, click, sidebar/notification jump) goes through `focusXtermUnlessCovered` and leaves the
hidden xterm unfocused — the overlay sits inside the node body, so a dwell over it used to route
keystrokes into a pane nobody could see. The body's file DROP / file PASTE handlers (which focus
diff --git a/src/renderer/state/workspace.md-mode.test.ts b/src/renderer/state/workspace.md-mode.test.ts
new file mode 100644
index 000000000..5c22c64c6
--- /dev/null
+++ b/src/renderer/state/workspace.md-mode.test.ts
@@ -0,0 +1,27 @@
+import { describe, it, expect } from 'vitest'
+import { flowToNodeStates, nodeStatesToFlow } from './workspace'
+import type { CanvasNodeState } from '@shared/types'
+
+// The ⌘M view used to live only in React Flow's node data: a project switch reloads the canvas
+// from the saved nodes, so every open chat view came back as the raw terminal.
+const base: CanvasNodeState = {
+ id: 'term-a-1',
+ kind: 'terminal',
+ position: { x: 0, y: 0 },
+ size: { width: 400, height: 300 },
+ title: 'W1',
+ color: '#888',
+ group: null
+}
+
+describe('the ⌘M view survives a save/load round trip (a project switch, a reload)', () => {
+ it('an open view stays open', () => {
+ const saved = flowToNodeStates(nodeStatesToFlow([{ ...base, mdMode: true }]))
+ expect(saved[0].mdMode).toBe(true)
+ expect(nodeStatesToFlow(saved)[0].data.mdMode).toBe(true)
+ })
+
+ it('a closed view is not written at all, so other nodes save exactly as before', () => {
+ expect(flowToNodeStates(nodeStatesToFlow([base]))[0].mdMode).toBeUndefined()
+ })
+})
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index 341524444..870cb9f97 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -135,6 +135,8 @@ export interface NodeData {
collapsed?: boolean
/** Agent nodes only: when true, this node's subagent/loop fan-out cards are hidden. */
hideFanout?: boolean
+ /** Terminal nodes: the ⌘M view is open — see CanvasNodeState.mdMode. */
+ mdMode?: boolean
/** Terminal nodes: own font size (issue #915) — see CanvasNodeState.terminalFontSize. */
terminalFontSize?: number
/** Expanded height to restore when un-collapsing (kept out of the persisted size). */
@@ -2666,6 +2668,7 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {
tags: n.tags,
collapsed,
hideFanout: n.hideFanout,
+ mdMode: n.mdMode,
// Validated at the same seam as the icon below: project.json is hand-editable and shared,
// and xterm must never be handed a font size outside the Settings range (issue #915).
terminalFontSize: normalizeTerminalFontSize(n.terminalFontSize),
@@ -2764,6 +2767,8 @@ export function flowToNodeStates(nodes: CanvasNode[], retainInitialCommand = tru
tags: n.data.tags,
collapsed: n.data.collapsed,
hideFanout: n.data.hideFanout,
+ // Closed is written as absent, so every node that never opened the view saves as before.
+ mdMode: n.data.mdMode || undefined,
// Re-validated on the way OUT, same reasoning as the icon below (issue #915).
terminalFontSize: normalizeTerminalFontSize(n.data.terminalFontSize),
// React Flow's node `data` is `Record<string, unknown>`, so the icon comes back out
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 582f0e0f2..6a610a2d6 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -533,6 +533,10 @@ export interface CanvasNodeState {
collapsed?: boolean
/** Agent nodes only: when true, this node's subagent/loop fan-out cards are hidden. */
hideFanout?: boolean
+ /** Terminal nodes: the ⌘M view (chat / markdown) is open. Persisted, so leaving a project and
+ * coming back (or a reload) reopens the node the way the user left it instead of on the raw
+ * terminal. Absent = closed. */
+ mdMode?: boolean
/**
* A user-chosen icon shown wherever this node is listed (canvas header, kanban card, sessions
* sidebar): one emoji/character, or an image file. Absent = the node draws exactly as it did