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(keybindings): directional node focus with Cmd+Arrow

Eli Jaghab04da0717ae13
diff --git a/README.md b/README.md
index 9676e6dd3..d7d912e20 100644
--- a/README.md
+++ b/README.md
@@ -241,6 +241,7 @@ These are the defaults — every one of them is remappable in **Settings → Key
| `⌘T` / `⌘⇧C` | New terminal / New Claude Code |
| `⌘⇧B` | Toggle the kanban board |
| `⌘W` | Close the selected node |
+| `⌘←` `⌘→` `⌘↑` `⌘↓` | Focus the node left / right / above / below (`Ctrl+Shift+arrow` off macOS) |
| `⌘Z` / `⌘⇧Z` | Undo / Redo |
| `⌘M` | Toggle markdown view (terminal / editor) |
| Hold `⌘⌥` (`Ctrl+Alt`) | Dictate into the focused terminal |
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index a8d98b78c..db6b27826 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -150,6 +150,13 @@ import { modelsForAgent } from '@shared/agents/model-gateway'
import { useModelGateway } from '../state/modelGateway'
import { viewportAtZoom1 } from '../lib/zoomReset'
import { isSpaceRelease, spacePanKeydown } from '../lib/spacePan'
+import {
+ FLOW_NODE_CLASS,
+ isFocusTarget,
+ nextNodeInDirection,
+ nodeNearestPoint,
+ type FocusDirection
+} from '../lib/directionalFocus'
import { UpdateCard } from '../components/UpdateCard'
import { AnnouncementBanner } from '../components/AnnouncementBanner'
import { TmuxBanner } from '../components/TmuxBanner'
@@ -5767,6 +5774,45 @@ export function Canvas() {
return true
}, [setCopyError])
+ /**
+ * ⌘←/→/↑/↓: hand the keyboard to the node in that direction — the multiplexer gesture
+ * (Ghostty's goto_split, tmux's select-pane -L) on a canvas. The mouse is why it earns its
+ * place: the wheel over a terminal belongs to that terminal's scrollback, so roaming a busy
+ * canvas otherwise means hunting for empty space to drag from first.
+ *
+ * The origin is the node the keyboard is actually IN, read off the focused element rather than
+ * off `selected`. Hover-dwell focus hands the keyboard to a terminal without selecting it, so a
+ * selection-only origin would walk from whichever node was last clicked — often not the one
+ * being typed in. Selection is the fallback for a canvas driven with no terminal focused.
+ */
+ const moveNodeFocus = useCallback(
+ (dir: FocusDirection): boolean => {
+ const nodes = nodesRef.current
+ const from =
+ document.activeElement?.closest(`.${FLOW_NODE_CLASS}`)?.getAttribute('data-id') ??
+ nodes.find((n) => n.selected && isFocusTarget(n))?.id ??
+ null
+ // Nothing focused, nothing selected: the first press ADOPTS the node nearest the view center
+ // instead of moving from it. Walking from an origin the user never chose lands somewhere
+ // arbitrary; adopting is the "you are here" a multiplexer's first move gives you for free.
+ if (!from) {
+ const center = viewCenter()
+ const seed = center ? nodeNearestPoint(nodes, center) : null
+ if (!seed) return false
+ focusNodeRef.current(seed)
+ return true
+ }
+ const next = nextNodeInDirection(nodes, from, dir)
+ if (next) focusNodeRef.current(next)
+ // Claimed even at the edge of the canvas, where there is nothing to move to. Declining
+ // would offer ⌘→ back to the focused terminal instead, and whatever it does there it is
+ // not "nothing" — a navigation key with nowhere to go should do nothing, not something
+ // else.
+ return true
+ },
+ [viewCenter]
+ )
+
// ONE window keydown for every registry command + the legacy gestures. The deps live in a
// ref refreshed each render so the listener is registered once; handlers return whether
// they claimed the chord (an unavailable surface falls through to the platform).
@@ -5838,7 +5884,11 @@ export function Canvas() {
if (!(project?.ssh?.remoteCwd ?? project?.cwd)) return false
void newProjectFile()
return true
- }
+ },
+ 'node.focusLeft': () => moveNodeFocus('left'),
+ 'node.focusRight': () => moveNodeFocus('right'),
+ 'node.focusUp': () => moveNodeFocus('up'),
+ 'node.focusDown': () => moveNodeFocus('down')
// node.close / node.toggleMarkdown: main-process intercepted on desktop; deliberately
// no renderer handler (the browser owns ⌘W in the Server Edition — see bridge/stubs.ts).
// terminal.* / scm.commit / speech.dictation: owned by their local listeners.
diff --git a/src/renderer/components/ShortcutsPanel.tsx b/src/renderer/components/ShortcutsPanel.tsx
index 1f492e254..b96f6d120 100644
--- a/src/renderer/components/ShortcutsPanel.tsx
+++ b/src/renderer/components/ShortcutsPanel.tsx
@@ -73,6 +73,12 @@ function buildSections(dictationChord: string): { title: string; rows: Row[] }[]
...cmd('node.newAgent', 'New Claude Code'),
...cmd('node.close', 'Close selected node'),
...cmd('canvas.deleteSelection', 'Delete selection'),
+ // One row per direction rather than a single collapsed "⌘ ← → ↑ ↓": each is its own
+ // command, so a user who remapped or unbound only ⌘↑ must see exactly that.
+ ...cmd('node.focusLeft', 'Focus the node to the left'),
+ ...cmd('node.focusRight', 'Focus the node to the right'),
+ ...cmd('node.focusUp', 'Focus the node above'),
+ ...cmd('node.focusDown', 'Focus the node below'),
{ keys: ['Right-click'], label: 'Actions menu (empty space or node)' },
{ keys: ['Left-drag'], label: 'Box-select (touch to select)' },
{ keys: ['Middle / Right-drag'], label: 'Pan the canvas' },
diff --git a/src/renderer/lib/directionalFocus.test.ts b/src/renderer/lib/directionalFocus.test.ts
new file mode 100644
index 000000000..92558424b
--- /dev/null
+++ b/src/renderer/lib/directionalFocus.test.ts
@@ -0,0 +1,189 @@
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'fs'
+import {
+ FLOW_NODE_CLASS,
+ isFocusTarget,
+ nextNodeInDirection,
+ nodeNearestPoint,
+ type DirectionalNode
+} from './directionalFocus'
+
+/** A 200×100 node at (x, y) — small enough that a 300px pitch leaves real gaps between rows. */
+const node = (id: string, x: number, y: number, extra: Partial<DirectionalNode> = {}): DirectionalNode => ({
+ id,
+ position: { x, y },
+ width: 200,
+ height: 100,
+ ...extra
+})
+
+/**
+ * a b c three columns, two rows, everything aligned:
+ * d e f the plain case every other test is a deviation from.
+ */
+const grid = [
+ node('a', 0, 0), node('b', 300, 0), node('c', 600, 0),
+ node('d', 0, 300), node('e', 300, 300), node('f', 600, 300)
+]
+
+describe('nextNodeInDirection, on an aligned grid', () => {
+ it('walks the row and the column one step at a time', () => {
+ expect(nextNodeInDirection(grid, 'e', 'left')).toBe('d')
+ expect(nextNodeInDirection(grid, 'e', 'right')).toBe('f')
+ expect(nextNodeInDirection(grid, 'e', 'up')).toBe('b')
+ expect(nextNodeInDirection(grid, 'b', 'down')).toBe('e')
+ })
+
+ it('does not wrap: the edge is the end of the line', () => {
+ expect(nextNodeInDirection(grid, 'c', 'right')).toBeNull()
+ expect(nextNodeInDirection(grid, 'a', 'left')).toBeNull()
+ expect(nextNodeInDirection(grid, 'a', 'up')).toBeNull()
+ expect(nextNodeInDirection(grid, 'f', 'down')).toBeNull()
+ })
+
+ it('prefers the nearer node in the same row over a nearer one diagonally', () => {
+ // `f` is two columns away in a's row; `d` is one row down and dead below. Right must still
+ // reach `b`, and nothing about the diagonal tier may outrank an in-row neighbour.
+ expect(nextNodeInDirection(grid, 'a', 'right')).toBe('b')
+ })
+})
+
+describe('nextNodeInDirection, when nothing lines up', () => {
+ it('reaches a node no row overlap can explain', () => {
+ // `far` shares no horizontal band with `origin`, so tier 0 is empty and the diagonal tier is
+ // the only thing keeping this from being a dead end.
+ const nodes = [node('origin', 0, 0), node('far', 500, 900)]
+ expect(nextNodeInDirection(nodes, 'origin', 'right')).toBe('far')
+ })
+
+ it('the sideways penalty picks the nearly-aligned node over the closer diagonal one', () => {
+ // `steep` is closer along x (400 vs 700) but 2000px off-axis; `flat` is further right and only
+ // 150px off. PERPENDICULAR_WEIGHT is what makes `flat` the answer.
+ const nodes = [node('origin', 0, 0), node('steep', 400, 2000), node('flat', 700, 150)]
+ expect(nextNodeInDirection(nodes, 'origin', 'right')).toBe('flat')
+ })
+
+ it('a node the grid snapped into the same column is not "above" its neighbour', () => {
+ const nodes = [node('left', 0, 0), node('right', 300, 0)]
+ expect(nextNodeInDirection(nodes, 'left', 'up')).toBeNull()
+ expect(nextNodeInDirection(nodes, 'left', 'down')).toBeNull()
+ })
+})
+
+describe('nextNodeInDirection, the shapes it must not trip on', () => {
+ it('skips group frames, which contain the origin rather than sit beside it', () => {
+ const nodes = [
+ node('origin', 0, 0),
+ node('frame', 0, 0, { type: 'group', width: 2000, height: 2000 }),
+ node('sibling', 300, 0)
+ ]
+ expect(nextNodeInDirection(nodes, 'origin', 'right')).toBe('sibling')
+ })
+
+ it('an unmeasured node is a point, still reachable', () => {
+ const nodes = [
+ node('origin', 0, 0),
+ { id: 'fresh', position: { x: 400, y: 50 } } satisfies DirectionalNode
+ ]
+ expect(nextNodeInDirection(nodes, 'origin', 'right')).toBe('fresh')
+ })
+
+ it('reads measured sizes when the node was never resized by hand', () => {
+ const nodes: DirectionalNode[] = [
+ { id: 'origin', position: { x: 0, y: 0 }, measured: { width: 200, height: 100 } },
+ { id: 'inrow', position: { x: 400, y: 40 }, measured: { width: 200, height: 100 } },
+ { id: 'offrow', position: { x: 300, y: 900 }, measured: { width: 200, height: 100 } }
+ ]
+ expect(nextNodeInDirection(nodes, 'origin', 'right')).toBe('inrow')
+ })
+
+ it('one node with a broken position cannot poison the answer', () => {
+ // NaN loses no comparison, it FAILS both of them, so an unguarded NaN candidate seen first
+ // would hold `best` against every valid node behind it.
+ const nodes: DirectionalNode[] = [
+ node('origin', 0, 0),
+ { id: 'broken', position: { x: NaN, y: NaN }, width: 200, height: 100 },
+ node('real', 300, 0)
+ ]
+ expect(nextNodeInDirection(nodes, 'origin', 'right')).toBe('real')
+ })
+
+ it('an origin with a broken position moves nowhere rather than somewhere random', () => {
+ const nodes: DirectionalNode[] = [
+ { id: 'origin', position: { x: NaN, y: 0 }, width: 200, height: 100 },
+ node('real', 300, 0)
+ ]
+ expect(nextNodeInDirection(nodes, 'origin', 'right')).toBeNull()
+ })
+
+ it('an origin that is not on this canvas answers null, never a guess', () => {
+ expect(nextNodeInDirection(grid, 'gone', 'right')).toBeNull()
+ expect(nextNodeInDirection([], 'a', 'right')).toBeNull()
+ })
+
+ it('breaks a true tie on id, so one canvas always answers the same way', () => {
+ const nodes = [node('origin', 0, 0), node('zeta', 300, 0), node('alpha', 300, 0)]
+ expect(nextNodeInDirection(nodes, 'origin', 'right')).toBe('alpha')
+ })
+})
+
+describe('nextNodeInDirection, across coordinate spaces', () => {
+ // A grouped node's `position` is relative to its frame. These cases are the reason every rect
+ // goes through nodeFocus's absolutePosition instead of reading `position` directly.
+ const framed: DirectionalNode[] = [
+ node('frame', 4000, 0, { type: 'group', width: 1000, height: 500 }),
+ { id: 'inside', position: { x: 24, y: 60 }, width: 200, height: 100, parentId: 'frame' },
+ node('outside', 0, 60)
+ ]
+
+ it('a grouped node is where it really sits, not where its raw position says', () => {
+ // Read raw, `inside` is at x=24 and would be the LEFTMOST node on the canvas; absolutely it
+ // is at x=4024, far to the right of `outside`.
+ expect(nextNodeInDirection(framed, 'outside', 'right')).toBe('inside')
+ expect(nextNodeInDirection(framed, 'outside', 'left')).toBeNull()
+ })
+
+ it('and the move back out of the frame works the same way', () => {
+ expect(nextNodeInDirection(framed, 'inside', 'left')).toBe('outside')
+ expect(nextNodeInDirection(framed, 'inside', 'right')).toBeNull()
+ })
+
+ it('a parentId cycle does not hang the walk', () => {
+ const cyclic: DirectionalNode[] = [
+ { id: 'a', position: { x: 0, y: 0 }, width: 200, height: 100, parentId: 'b' },
+ { id: 'b', position: { x: 300, y: 0 }, width: 200, height: 100, parentId: 'a' }
+ ]
+ expect(() => nextNodeInDirection(cyclic, 'a', 'right')).not.toThrow()
+ })
+})
+
+describe('nodeNearestPoint', () => {
+ it('seeds from the node nearest the view center', () => {
+ expect(nodeNearestPoint(grid, { x: 700, y: 350 })).toBe('f')
+ expect(nodeNearestPoint(grid, { x: 0, y: 0 })).toBe('a')
+ })
+
+ it('never seeds onto a group frame', () => {
+ const nodes = [node('frame', 0, 0, { type: 'group' }), node('real', 5000, 5000)]
+ expect(nodeNearestPoint(nodes, { x: 0, y: 0 })).toBe('real')
+ })
+
+ it('an empty canvas has no seed', () => {
+ expect(nodeNearestPoint([], { x: 0, y: 0 })).toBeNull()
+ })
+})
+
+describe('isFocusTarget', () => {
+ it('every node kind but a group frame', () => {
+ expect(isFocusTarget(node('t', 0, 0, { type: 'terminal' }))).toBe(true)
+ expect(isFocusTarget(node('s', 0, 0, { type: 'sticky' }))).toBe(true)
+ expect(isFocusTarget(node('g', 0, 0, { type: 'group' }))).toBe(false)
+ })
+})
+
+describe('FLOW_NODE_CLASS', () => {
+ it('still exists in the installed xyflow dist', () => {
+ const dist = readFileSync('node_modules/@xyflow/react/dist/esm/index.js', 'utf8')
+ expect(dist.includes(FLOW_NODE_CLASS)).toBe(true)
+ })
+})
diff --git a/src/renderer/lib/directionalFocus.ts b/src/renderer/lib/directionalFocus.ts
new file mode 100644
index 000000000..5b404f74a
--- /dev/null
+++ b/src/renderer/lib/directionalFocus.ts
@@ -0,0 +1,178 @@
+/**
+ * "Focus the node over there" — which node a directional move (⌘←/→/↑/↓) lands on, and which
+ * node the gesture starts from when nothing is focused yet.
+ *
+ * The gesture is the one terminal multiplexers give you for free (Ghostty's `goto_split`, tmux's
+ * `select-pane -L`, i3's `focus left`), but those all navigate a TREE OF SPLITS where "the pane to
+ * the left" is a structural fact. On a canvas there is no tree: nodes are free-form rectangles the
+ * user dragged, so the answer has to be inferred from geometry.
+ *
+ * Nearest-by-distance is the obvious inference and the wrong one — the closest node in the raw
+ * Euclidean sense is very often the one diagonally up-and-left, so ⌘→ lands somewhere the user
+ * never pointed. Candidates are therefore ranked in TWO TIERS:
+ *
+ * Tier 0 — the candidate's perpendicular span OVERLAPS the origin's. These are the nodes a user
+ * would call "in the same row" (for a horizontal move) or "the same column" (vertical),
+ * and one of them is the answer whenever one exists, however far away it sits. Ordered
+ * by distance along the axis, so the immediate neighbour beats the one behind it.
+ * Tier 1 — no overlap, i.e. reachable only diagonally. Ordered by axial distance plus a
+ * {@link PERPENDICULAR_WEIGHT} penalty on the sideways offset, which is what stops a
+ * far-off-axis node beating a nearly-aligned one. This tier is why a node sitting alone
+ * on its row is not a dead end in every direction — a dead end there reads as the
+ * feature being broken, not as a deliberate boundary.
+ *
+ * Ties break on node id, so one canvas always answers the same way and the tests can state it.
+ *
+ * There is deliberately NO wrap-around: the last node in a direction is the end of the line, which
+ * is what `goto_split` does and what keeps repeated presses from cycling forever.
+ *
+ * Every rect comes from `nodeFocus`'s `nodeFitRect`/`absolutePosition`, never from `node.position`
+ * directly, and that is load-bearing rather than tidy: a GROUPED node's own `position` is relative
+ * to its frame, so comparing one against a top-level node's compares two different coordinate
+ * spaces. A terminal sitting at (24, 60) inside a frame parked at (4000, 0) would otherwise look
+ * like the leftmost node on the canvas, and ⌘← from anywhere would fly to it.
+ */
+import { absolutePosition, nodeFitRect, type FocusableNode } from './nodeFocus'
+
+export type FocusDirection = 'left' | 'right' | 'up' | 'down'
+
+/** xyflow wraps every node in an element with this class and a `data-id` holding the node id —
+ * which is how the gesture finds the node the KEYBOARD is in, not merely the selected one.
+ * Pinned against the installed dist by the test beside this file, the same way keyContext.ts
+ * pins xterm's helper-textarea class: an upgrade that renames it must fail loudly rather than
+ * quietly leave every move starting from the wrong node. Note handles carry a `data-id` too
+ * (a composite), so the class has to be matched FIRST and the attribute read off that element. */
+export const FLOW_NODE_CLASS = 'react-flow__node'
+
+/**
+ * A focus destination: everything `nodeFocus` needs to place a node in absolute space, plus the
+ * node KIND, which is the one thing that decides what may be focused at all. Structural rather
+ * than `CanvasNode` so the unit tests need no xyflow types and no DOM.
+ */
+export interface DirectionalNode extends FocusableNode {
+ /** Group FRAMES are containers, not destinations — see {@link isFocusTarget}. */
+ type?: string
+}
+
+/** Cost of a sideways offset relative to a step along the direction, for the diagonal tier. At 2,
+ * a node twice as far sideways as it is forward loses to one straight ahead. */
+const PERPENDICULAR_WEIGHT = 2
+
+/** Centers within this many world px of each other along the axis are not "beyond" each other, so
+ * two nodes the grid snapped into the same column never answer each other's ⌘→. */
+const AXIS_EPSILON = 1
+
+/**
+ * The node a move in `dir` from `fromId` should focus, or null when `fromId` is the last node that
+ * way (or is not on this canvas).
+ */
+export function nextNodeInDirection(
+ nodes: readonly DirectionalNode[],
+ fromId: string,
+ dir: FocusDirection
+): string | null {
+ const origin = nodes.find((n) => n.id === fromId)
+ if (!origin) return null
+ const o = boundsOf(origin, nodes)
+ const horizontal = dir === 'left' || dir === 'right'
+ const forward = dir === 'right' || dir === 'down' ? 1 : -1
+
+ let best: Score | null = null
+ for (const node of nodes) {
+ if (node.id === fromId || !isFocusTarget(node)) continue
+ const r = boundsOf(node, nodes)
+ // A non-finite center poisons every comparison below rather than merely losing them: NaN
+ // fails `<` in both directions, so the FIRST such candidate becomes `best` and then nothing
+ // valid can displace it. Positions arrive from a persisted workspace file, where a null
+ // coordinate is one arithmetic step from NaN, so this is cheaper than trusting the input.
+ if (!Number.isFinite(r.cx) || !Number.isFinite(r.cy)) continue
+ const advance = forward * ((horizontal ? r.cx : r.cy) - (horizontal ? o.cx : o.cy))
+ if (!(advance > AXIS_EPSILON)) continue
+ const perp = Math.abs((horizontal ? r.cy : r.cx) - (horizontal ? o.cy : o.cx))
+ const overlaps = horizontal
+ ? r.top < o.bottom && o.top < r.bottom
+ : r.left < o.right && o.left < r.right
+ const score: Score = {
+ tier: overlaps ? 0 : 1,
+ cost: overlaps ? advance : advance + PERPENDICULAR_WEIGHT * perp,
+ perp,
+ id: node.id
+ }
+ if (!best || better(score, best)) best = score
+ }
+ return best?.id ?? null
+}
+
+/**
+ * The focus target nearest `point`, by center distance — the SEED for a canvas where nothing is
+ * focused or selected yet. Without it the first ⌘→ on a freshly opened project would have no
+ * origin and do nothing, which is indistinguishable from an unbound chord.
+ */
+export function nodeNearestPoint(
+ nodes: readonly DirectionalNode[],
+ point: { x: number; y: number }
+): string | null {
+ let bestId: string | null = null
+ let bestDist = Infinity
+ for (const node of nodes) {
+ if (!isFocusTarget(node)) continue
+ const r = boundsOf(node, nodes)
+ const dist = (r.cx - point.x) ** 2 + (r.cy - point.y) ** 2
+ if (dist < bestDist || (dist === bestDist && bestId !== null && node.id < bestId)) {
+ bestDist = dist
+ bestId = node.id
+ }
+ }
+ return bestId
+}
+
+/**
+ * A group frame is the one node kind that must never be a focus destination: it is a container
+ * drawn AROUND the nodes you actually want, so its rect overlaps all of them and it would win
+ * every direction from inside itself.
+ */
+export function isFocusTarget(node: DirectionalNode): boolean {
+ return node.type !== 'group'
+}
+
+interface Bounds {
+ left: number
+ top: number
+ right: number
+ bottom: number
+ cx: number
+ cy: number
+}
+
+/** The node's absolute bounds. `nodeFitRect` answers null when neither a measurement nor a
+ * persisted size is known (a node added this tick, before layout); such a node is treated as a
+ * POINT at its absolute position, so it is still reachable but can never overlap anyone's row —
+ * the honest answer for something with no size yet. */
+function boundsOf(node: DirectionalNode, all: readonly DirectionalNode[]): Bounds {
+ const rect = nodeFitRect(node, all) ?? { ...absolutePosition(node, all), width: 0, height: 0 }
+ const { x, y, width, height } = rect
+ return {
+ left: x,
+ top: y,
+ right: x + width,
+ bottom: y + height,
+ cx: x + width / 2,
+ cy: y + height / 2
+ }
+}
+
+interface Score {
+ tier: number
+ cost: number
+ perp: number
+ id: string
+}
+
+const better = (a: Score, b: Score): boolean =>
+ a.tier !== b.tier
+ ? a.tier < b.tier
+ : a.cost !== b.cost
+ ? a.cost < b.cost
+ : a.perp !== b.perp
+ ? a.perp < b.perp
+ : a.id < b.id
diff --git a/src/shared/keybindings.test.ts b/src/shared/keybindings.test.ts
index 165d7faad..460145fa1 100644
--- a/src/shared/keybindings.test.ts
+++ b/src/shared/keybindings.test.ts
@@ -118,6 +118,14 @@ describe('registry invariants', () => {
darwin: [], other: [] },
{ id: 'node.newFile', title: 'New file…', group: 'Nodes', scope: 'canvas',
darwin: [], other: [] },
+ { id: 'node.focusLeft', title: 'Focus node to the left', group: 'Nodes', scope: 'canvas',
+ darwin: ['Cmd+ArrowLeft'], other: ['Ctrl+Shift+ArrowLeft'], allowInTerminal: true },
+ { id: 'node.focusRight', title: 'Focus node to the right', group: 'Nodes', scope: 'canvas',
+ darwin: ['Cmd+ArrowRight'], other: ['Ctrl+Shift+ArrowRight'], allowInTerminal: true },
+ { id: 'node.focusUp', title: 'Focus node above', group: 'Nodes', scope: 'canvas',
+ darwin: ['Cmd+ArrowUp'], other: ['Ctrl+Shift+ArrowUp'], allowInTerminal: true },
+ { id: 'node.focusDown', title: 'Focus node below', group: 'Nodes', scope: 'canvas',
+ darwin: ['Cmd+ArrowDown'], other: ['Ctrl+Shift+ArrowDown'], allowInTerminal: true },
{ id: 'node.close', title: 'Close node / window', group: 'Nodes', scope: 'app',
darwin: ['Cmd+W'], other: ['Cmd+W'], allowInTerminal: true, allowWhileTyping: true },
{ id: 'node.toggleMarkdown', title: 'Toggle markdown view', group: 'Nodes', scope: 'app',
diff --git a/src/shared/keybindings.ts b/src/shared/keybindings.ts
index 596a095f9..e9c9ee61c 100644
--- a/src/shared/keybindings.ts
+++ b/src/shared/keybindings.ts
@@ -68,6 +68,10 @@ export type CommandId =
| 'node.newWebView'
| 'node.newDino'
| 'node.newFile'
+ | 'node.focusLeft'
+ | 'node.focusRight'
+ | 'node.focusUp'
+ | 'node.focusDown'
| 'node.close'
| 'node.toggleMarkdown'
| 'terminal.find'
@@ -149,6 +153,30 @@ export const COMMAND_DEFINITIONS: readonly CommandDefinition[] = [
defaultBindings: both() },
{ id: 'node.newFile', title: 'New file…', group: 'Nodes', scope: 'canvas',
defaultBindings: both() },
+
+ // Directional focus, the multiplexer gesture (Ghostty goto_split, tmux select-pane -L). Two
+ // flags carry the whole point: scope 'canvas' because there is no geometry to walk on the
+ // board, and allowInTerminal because the hand that wants to move is already typing in a
+ // terminal — without it the gesture only works from the one place you don't need it.
+ //
+ // The non-mac default is NOT Ctrl+Arrow (what `both('Cmd+ArrowLeft')` would resolve to):
+ // Ctrl+Arrow is readline's word-jump, and allowInTerminal would steal it from every shell on
+ // Linux and Windows. Ctrl+Alt+Arrow is out for a different reason — the speech.dictation
+ // default is the modifier-only chord 'Cmd+Alt', which on those platforms is Ctrl+Alt held, so
+ // the hold listener would start recording on the way to an arrow. Ctrl+Shift+Arrow is what is
+ // left that no shell and no other command already owns.
+ { id: 'node.focusLeft', title: 'Focus node to the left', group: 'Nodes', scope: 'canvas',
+ defaultBindings: { darwin: ['Cmd+ArrowLeft'], other: ['Ctrl+Shift+ArrowLeft'] },
+ allowInTerminal: true },
+ { id: 'node.focusRight', title: 'Focus node to the right', group: 'Nodes', scope: 'canvas',
+ defaultBindings: { darwin: ['Cmd+ArrowRight'], other: ['Ctrl+Shift+ArrowRight'] },
+ allowInTerminal: true },
+ { id: 'node.focusUp', title: 'Focus node above', group: 'Nodes', scope: 'canvas',
+ defaultBindings: { darwin: ['Cmd+ArrowUp'], other: ['Ctrl+Shift+ArrowUp'] },
+ allowInTerminal: true },
+ { id: 'node.focusDown', title: 'Focus node below', group: 'Nodes', scope: 'canvas',
+ defaultBindings: { darwin: ['Cmd+ArrowDown'], other: ['Ctrl+Shift+ArrowDown'] },
+ allowInTerminal: true },
// Main-process intercepted today (unconditional): keep firing everywhere.
{ id: 'node.close', title: 'Close node / window', group: 'Nodes', scope: 'app',
defaultBindings: both('Cmd+W'), allowInTerminal: true, allowWhileTyping: true },