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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(canvas): snap nodes into layout zones — v1 of #394 (keyboard + menu)
enes081cfd12012a
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 77cf6bf81..a2d445034 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -235,6 +235,7 @@ import {type FocusableNode} from '../lib/nodeFocus'import { maximizeTargetRect } from '../lib/nodeMaximize'+import { ZONES, zoneTargetRect, type ZoneId } from '../lib/nodeZones'import {recordBreadcrumb,stepBreadcrumb,@@ -456,6 +457,7 @@ import {ungroupNodes,maximizeNodeToRect,restoreMaximizedNode,+ placeNodeInRect,type CanvasNode} from '../state/workspace'import { codexAccountSelectable, codexAccountSwitchStillEligible } from './codex-account-switch'@@ -6132,13 +6134,12 @@ export function Canvas() {)/**- * The header maximize toggle's chord (issue #399). Same origin rule as `moveNodeFocus`: the- * node the keyboard is actually IN (hover-dwell focuses a terminal without selecting it), else- * the single selected node — a multi-selection is ambiguous, so it declines and the chord- * falls through. Declines (false) rather than half-acts everywhere the button would not show:- * group frames, collapsed nodes, an unmeasured container.+ * The node a placement command acts on (maximize, zone snap). Same origin rule as+ * `moveNodeFocus`: the node the keyboard is actually IN (hover-dwell focuses a terminal+ * without selecting it), else the single selected node — a multi-selection is ambiguous, so+ * the caller declines and the chord falls through. Never a group frame.*/- const toggleMaximizeCommand = useCallback((): boolean => {+ const placementTargetNode = useCallback((): CanvasNode | undefined => {const nodes = nodesRef.currentconst focusedId = document.activeElement?.closest(`.${FLOW_NODE_CLASS}`)@@ -6147,7 +6148,16 @@ export function Canvas() {const target =(focusedId ? nodes.find((n) => n.id === focusedId) : undefined) ??(selected.length === 1 ? selected[0] : undefined)- if (!target || target.type === 'group') return false+ return !target || target.type === 'group' ? undefined : target+ }, [])++ /**+ * The header maximize toggle's chord (issue #399). Declines (false) rather than half-acts+ * everywhere the button would not show: group frames, collapsed nodes, an unmeasured container.+ */+ const toggleMaximizeCommand = useCallback((): boolean => {+ const target = placementTargetNode()+ if (!target) return falseif (target.data.premaxRect) {setNodes((ns) => restoreMaximizedNode(ns, target.id))markDirty()@@ -6160,7 +6170,28 @@ export function Canvas() {setNodes((ns) => maximizeNodeToRect(ns, target.id, rect))markDirty()return true- }, [setNodes, markDirty, getViewport])+ }, [placementTargetNode, setNodes, markDirty, getViewport])++ /**+ * Zone snap (issue #394 v1): place `nodeId` (or the placement target, for the keyboard chords)+ * into a zone of the visible canvas. Same declines as maximize; no toggle state — the node has+ * simply been moved, exactly as if by hand (see `placeNodeInRect`).+ */+ const snapNodeToZone = useCallback(+ (zone: ZoneId, nodeId?: string): boolean => {+ const target = nodeId+ ? nodesRef.current.find((n) => n.id === nodeId)+ : placementTargetNode()+ if (!target || target.type === 'group' || target.data.collapsed) return false+ const wrap = flowWrapRef.current?.getBoundingClientRect()+ const rect = wrap ? zoneTargetRect(getViewport(), wrap.width, wrap.height, zone) : null+ if (!rect) return false+ setNodes((ns) => placeNodeInRect(ns, target.id, rect))+ markDirty()+ return true+ },+ [placementTargetNode, setNodes, markDirty, getViewport]+ )// 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@@ -6242,7 +6273,11 @@ export function Canvas() {'node.focusRight': () => moveNodeFocus('right'),'node.focusUp': () => moveNodeFocus('up'),'node.focusDown': () => moveNodeFocus('down'),- 'node.maximize': toggleMaximizeCommand+ 'node.maximize': toggleMaximizeCommand,+ 'node.zoneLeft': () => snapNodeToZone('left-half'),+ 'node.zoneRight': () => snapNodeToZone('right-half'),+ 'node.zoneUp': () => snapNodeToZone('top-half'),+ 'node.zoneDown': () => snapNodeToZone('bottom-half')// 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.@@ -6419,6 +6454,27 @@ export function Canvas() {: ([{ label: 'Duplicate', icon: <IconDuplicate />, onClick: () => duplicateNodes(ids, at) }] as MenuItem[])),+ // Zone snap (issue #394 v1): place THIS node into a region of the visible canvas at that+ // region's size — halves/quarters/thirds. Single non-group, non-collapsed target only (the+ // same declines as the ⌃⌥arrow chords; a multi-selection stacking into one zone is noise).+ ...(ids.length === 1 &&+ !isHidden('snap-zone', hidden) &&+ (() => {+ const n = nodesRef.current.find((nd) => nd.id === ids[0])+ return !!n && n.type !== 'group' && !n.data.collapsed+ })()+ ? ([+ {+ type: 'submenu',+ label: 'Snap to zone',+ icon: <IconGrid />,+ children: ZONES.map((z) => ({+ label: z.label,+ onClick: () => snapNodeToZone(z.id, ids[0])+ }))+ }+ ] as MenuItem[])+ : []),...(ids.length === 1 && (() => {const a = agentIdOf(ids[0])return !!a && canBranch(a)diff --git a/src/renderer/lib/nodeZones.test.ts b/src/renderer/lib/nodeZones.test.tsnew file mode 100644index 000000000..f449271de--- /dev/null+++ b/src/renderer/lib/nodeZones.test.ts@@ -0,0 +1,87 @@+import { describe, it, expect } from 'vitest'+import { ZONES, ZONE_GUTTER_PX, zoneTargetRect } from './nodeZones'+import { NODE_MAXIMIZE_MARGIN_PX, maximizeTargetRect } from './nodeMaximize'++// Zone snapping (issue #394 v1): the viewport→flow subdivision the keyboard chords and the+// "Snap to zone" menu both use. All screen-px assertions run at zoom 1 / camera origin so flow+// equals screen; one case pins the zoom conversion.++const VP = { x: 0, y: 0, zoom: 1 }+const W = 1200+const H = 800+const M = NODE_MAXIMIZE_MARGIN_PX+const G = ZONE_GUTTER_PX++describe('zoneTargetRect', () => {+ it('left/right halves split the margin-inset area and share one gutter', () => {+ const left = zoneTargetRect(VP, W, H, 'left-half')!+ const right = zoneTargetRect(VP, W, H, 'right-half')!+ // Outer edges keep the maximize margin; full height.+ expect(left.x).toBe(M)+ expect(left.y).toBe(M)+ expect(left.height).toBe(H - 2 * M)+ expect(right.x + right.width).toBe(W - M)+ // The two rects tile the area with exactly one gutter between them.+ expect(right.x - (left.x + left.width)).toBeCloseTo(G)+ expect(left.width).toBeCloseTo(right.width)+ })++ it('quarters meet at gutters on both axes', () => {+ const tl = zoneTargetRect(VP, W, H, 'top-left')!+ const br = zoneTargetRect(VP, W, H, 'bottom-right')!+ expect(tl).toMatchObject({ x: M, y: M })+ expect(br.x + br.width).toBe(W - M)+ expect(br.y + br.height).toBe(H - M)+ expect(br.x - (tl.x + tl.width)).toBeCloseTo(G)+ expect(br.y - (tl.y + tl.height)).toBeCloseTo(G)+ })++ it('thirds tile the width with two gutters, center inset on both sides', () => {+ const l = zoneTargetRect(VP, W, H, 'left-third')!+ const c = zoneTargetRect(VP, W, H, 'center-third')!+ const r = zoneTargetRect(VP, W, H, 'right-third')!+ expect(c.x - (l.x + l.width)).toBeCloseTo(G)+ expect(r.x - (c.x + c.width)).toBeCloseTo(G)+ expect(l.width).toBeCloseTo(r.width)+ // The center third pays a half-gutter on BOTH sides, so it is narrower than the outer two.+ expect(c.width).toBeCloseTo(l.width - G / 2)+ })++ it('converts to flow coordinates like maximize (zoom + camera offset)', () => {+ const vp = { x: -100, y: 50, zoom: 0.5 }+ const left = zoneTargetRect(vp, W, H, 'left-half')!+ expect(left.x).toBeCloseTo((M + 100) / 0.5)+ expect(left.y).toBeCloseTo((M - 50) / 0.5)+ expect(left.width).toBeCloseTo((W - 2 * M - G) / 2 / 0.5)+ })++ it('a full-viewport zone would be maximize — the two modules agree on the frame', () => {+ // Not a real zone, but the outer edges must match: left-half + right-half spans exactly the+ // rect maximizeTargetRect answers, so the two features can never disagree about the margin.+ const max = maximizeTargetRect(VP, W, H)!+ const left = zoneTargetRect(VP, W, H, 'left-half')!+ const right = zoneTargetRect(VP, W, H, 'right-half')!+ expect(left.x).toBe(max.x)+ expect(right.x + right.width).toBeCloseTo(max.x + max.width)+ expect(left.y).toBe(max.y)+ expect(left.height).toBe(max.height)+ })++ it('refuses a zone smaller than a node header, per zone rather than per container', () => {+ expect(zoneTargetRect(VP, 0, 0, 'left-half')).toBeNull()+ // 280px wide: a HALF of the width comes out 110px < 120…+ expect(zoneTargetRect(VP, 280, 800, 'left-half')).toBeNull()+ // …but a full-width zone in the same container still fits (232 × 370).+ expect(zoneTargetRect(VP, 280, 800, 'top-half')).not.toBeNull()+ expect(zoneTargetRect(VP, 1200, 800, 'nope' as never)).toBeNull()+ })++ it('every declared zone answers on a normal container', () => {+ for (const z of ZONES) {+ const rect = zoneTargetRect(VP, W, H, z.id)+ expect(rect, z.id).not.toBeNull()+ expect(rect!.width).toBeGreaterThan(0)+ expect(rect!.height).toBeGreaterThan(0)+ }+ })+})diff --git a/src/renderer/lib/nodeZones.ts b/src/renderer/lib/nodeZones.tsnew file mode 100644index 000000000..3ef711570--- /dev/null+++ b/src/renderer/lib/nodeZones.ts@@ -0,0 +1,86 @@+// Zone snapping (issue #394, v1): place ONE node into a chosen region of the visible canvas —+// halves, quarters, thirds — at that region's position and size. The MacsyZones/FancyZones idea,+// scoped to the deliberate keyboard/menu gesture (the drag-time overlay is the follow-up).+//+// Same coordinate answer as the maximize toggle (issue #399), because it resolves the issue's own+// "viewport-relative or canvas-relative?" question the same way: the GESTURE is viewport-relative+// ("left half of what I am looking at right now"), the RESULT is plain absolute node geometry+// that persists. A zone is a placement verb, not a live constraint — pan away and the node stays+// where it was put.++import type { Viewport } from '@xyflow/system'+import { NODE_MAXIMIZE_MARGIN_PX, type FlowRect } from './nodeMaximize'++/** Screen-pixel gap between two adjacent zones, so side-by-side nodes don't touch. */+export const ZONE_GUTTER_PX = 12++export type ZoneId =+ | 'left-half'+ | 'right-half'+ | 'top-half'+ | 'bottom-half'+ | 'top-left'+ | 'top-right'+ | 'bottom-left'+ | 'bottom-right'+ | 'left-third'+ | 'center-third'+ | 'right-third'++interface ZoneFraction {+ x0: number+ y0: number+ x1: number+ y1: number+}++/** Each zone as fractions of the usable (margin-inset) viewport. The menu renders in this order. */+export const ZONES: readonly { id: ZoneId; label: string; frac: ZoneFraction }[] = [+ { id: 'left-half', label: 'Left half', frac: { x0: 0, y0: 0, x1: 0.5, y1: 1 } },+ { id: 'right-half', label: 'Right half', frac: { x0: 0.5, y0: 0, x1: 1, y1: 1 } },+ { id: 'top-half', label: 'Top half', frac: { x0: 0, y0: 0, x1: 1, y1: 0.5 } },+ { id: 'bottom-half', label: 'Bottom half', frac: { x0: 0, y0: 0.5, x1: 1, y1: 1 } },+ { id: 'top-left', label: 'Top left quarter', frac: { x0: 0, y0: 0, x1: 0.5, y1: 0.5 } },+ { id: 'top-right', label: 'Top right quarter', frac: { x0: 0.5, y0: 0, x1: 1, y1: 0.5 } },+ { id: 'bottom-left', label: 'Bottom left quarter', frac: { x0: 0, y0: 0.5, x1: 0.5, y1: 1 } },+ { id: 'bottom-right', label: 'Bottom right quarter', frac: { x0: 0.5, y0: 0.5, x1: 1, y1: 1 } },+ { id: 'left-third', label: 'Left third', frac: { x0: 0, y0: 0, x1: 1 / 3, y1: 1 } },+ { id: 'center-third', label: 'Center third', frac: { x0: 1 / 3, y0: 0, x1: 2 / 3, y1: 1 } },+ { id: 'right-third', label: 'Right third', frac: { x0: 2 / 3, y0: 0, x1: 1, y1: 1 } }+]++const ZONES_BY_ID: ReadonlyMap<ZoneId, ZoneFraction> = new Map(ZONES.map((z) => [z.id, z.frac]))++/**+ * The zone's rect in FLOW coordinates, or null when the container has no usable size — the same+ * contract as `maximizeTargetRect` (which this generalizes: the full-viewport zone IS maximize).+ * Internal zone edges are inset by half the gutter each, so two adjacent zones share one+ * `ZONE_GUTTER_PX` gap; outer edges keep the maximize margin.+ */+export function zoneTargetRect(+ viewport: Viewport,+ containerWidth: number,+ containerHeight: number,+ zone: ZoneId,+ marginPx: number = NODE_MAXIMIZE_MARGIN_PX,+ gutterPx: number = ZONE_GUTTER_PX+): FlowRect | null {+ const frac = ZONES_BY_ID.get(zone)+ if (!frac || !(viewport.zoom > 0)) return null+ const innerW = containerWidth - marginPx * 2+ const innerH = containerHeight - marginPx * 2+ // Screen-px edges inside the margin-inset area, with internal edges pulled in by gutter/2.+ const left = marginPx + frac.x0 * innerW + (frac.x0 > 0 ? gutterPx / 2 : 0)+ const right = marginPx + frac.x1 * innerW - (frac.x1 < 1 ? gutterPx / 2 : 0)+ const top = marginPx + frac.y0 * innerH + (frac.y0 > 0 ? gutterPx / 2 : 0)+ const bottom = marginPx + frac.y1 * innerH - (frac.y1 < 1 ? gutterPx / 2 : 0)+ // Same refusal floor as maximize: below this the "zone" is smaller than a node header, and a+ // node parked there is a comic strip the user then has to fish back out.+ if (!(right - left >= 120) || !(bottom - top >= 120)) return null+ return {+ x: (left - viewport.x) / viewport.zoom,+ y: (top - viewport.y) / viewport.zoom,+ width: (right - left) / viewport.zoom,+ height: (bottom - top) / viewport.zoom+ }+}diff --git a/src/renderer/lib/ui-visibility.test.ts b/src/renderer/lib/ui-visibility.test.tsindex 2e9198a2e..3ee97190d 100644--- a/src/renderer/lib/ui-visibility.test.ts+++ b/src/renderer/lib/ui-visibility.test.ts@@ -23,7 +23,7 @@ describe('isHidden', () => {describe('hideable inventories', () => {it('list the agreed ids and nothing destructive', () => {expect(HIDEABLE_MENU_ITEMS.map((r) => r.id)).toEqual([- 'group', 'remove-from-group', 'colors', 'duplicate', 'collapse',+ 'group', 'remove-from-group', 'colors', 'duplicate', 'snap-zone', 'collapse','markdown-view', 'refresh-terminal'])expect(HIDEABLE_HEADER_BUTTONS.map((r) => r.id)).toEqual([diff --git a/src/renderer/lib/ui-visibility.ts b/src/renderer/lib/ui-visibility.tsindex 0c19bb448..abd14f970 100644--- a/src/renderer/lib/ui-visibility.ts+++ b/src/renderer/lib/ui-visibility.ts@@ -23,6 +23,7 @@ export const HIDEABLE_MENU_ITEMS: readonly HideableRow[] = [{ id: 'remove-from-group', label: 'Remove from group' },{ id: 'colors', label: 'Colors' },{ id: 'duplicate', label: 'Duplicate' },+ { id: 'snap-zone', label: 'Snap to zone' },{ id: 'collapse', label: 'Collapse / Expand' },{ id: 'markdown-view', label: 'Markdown view' },{ id: 'refresh-terminal', label: 'Refresh terminal' }diff --git a/src/renderer/state/workspace.maximize.test.ts b/src/renderer/state/workspace.maximize.test.tsindex f76da3391..1acb5fe3b 100644--- a/src/renderer/state/workspace.maximize.test.ts+++ b/src/renderer/state/workspace.maximize.test.ts@@ -3,6 +3,7 @@ import {flowToNodeStates,maximizeNodeToRect,nodeStatesToFlow,+ placeNodeInRect,restoreMaximizedNode} from './workspace'import type { CanvasNode } from './workspace'@@ -162,3 +163,42 @@ describe('maximizeTargetRect', () => {expect(maximizeTargetRect({ x: 0, y: 0, zoom: 0 }, 1200, 800, 24)).toBeNull()})})++describe('placeNodeInRect (zone snap, issue #394 v1)', () => {+ it('places a top-level node at the rect without writing premaxRect', () => {+ const next = placeNodeInRect([term('a', { x: 40, y: 60 })], 'a', RECT)+ const a = next.find((n) => n.id === 'a')!+ expect(a.position).toEqual({ x: 1000, y: 2000 })+ expect(a.width).toBe(1600)+ expect(a.height).toBe(900)+ expect(a.data.premaxRect).toBeUndefined()+ })++ it('leaves an existing premaxRect alone — a maximized node snapped to a zone still restores', () => {+ const maxed = maximizeNodeToRect([term('a', { x: 40, y: 60 })], 'a', RECT)+ const zoned = placeNodeInRect(maxed, 'a', { x: 0, y: 0, width: 700, height: 900 })+ expect(zoned[0].data.premaxRect).toEqual({ x: 40, y: 60, width: 320, height: 240 })+ const restored = restoreMaximizedNode(zoned, 'a')+ expect(restored[0].position).toEqual({ x: 40, y: 60 })+ expect(restored[0].width).toBe(320)+ })++ it('re-fits the frame around a grouped node, absolute rect honoured', () => {+ const g = group('g', { x: 100, y: 100 })+ const child = term('a', { x: 50, y: 80 }, { width: 320, height: 240 }, { parentId: 'g', extent: 'parent' })+ const next = placeNodeInRect([g, child], 'a', RECT)+ const a = next.find((n) => n.id === 'a')!+ const frame = next.find((n) => n.id === 'g')!+ expect(frame.position.x + a.position.x).toBeCloseTo(RECT.x)+ expect(frame.position.y + a.position.y).toBeCloseTo(RECT.y)+ expect((frame.width as number)!).toBeGreaterThanOrEqual(RECT.width)+ })++ it('refuses group frames, collapsed nodes and unknown ids', () => {+ const collapsed = term('c', { x: 0, y: 0 })+ collapsed.data = { ...collapsed.data, collapsed: true }+ expect(placeNodeInRect([group('g', { x: 0, y: 0 })], 'g', RECT)[0].width).toBe(600)+ expect(placeNodeInRect([collapsed], 'c', RECT)[0].width).toBe(320)+ expect(placeNodeInRect([term('a', { x: 1, y: 2 })], 'nope', RECT)).toEqual([term('a', { x: 1, y: 2 })])+ })+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex aa7b0e970..406908004 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -1223,12 +1223,46 @@ export function maximizeNodeToRect(height: nodeH(node) || (node.style?.height as number) || 0}if (!(premaxRect.width > 0) || !(premaxRect.height > 0)) return nodes+ return withNodeRect(nodes, node, rect, { premaxRect })+}++/**+ * Zone snap (issue #394 v1): place `nodeId` at `rect` — a zone of the visible viewport in+ * ROOT/flow coordinates (`zoneTargetRect`). Plain placement, no toggle state: unlike maximize it+ * writes no `premaxRect` (a node sent to "left half" has simply been MOVED, exactly as if by+ * hand) and an existing `premaxRect` is left alone, so a maximized node snapped into a zone still+ * restores to its pre-maximize spot. Refusals match the maximize matrix minus already-maximized:+ * unknown id, group frame, collapsed node.+ */+export function placeNodeInRect(+ nodes: CanvasNode[],+ nodeId: string,+ rect: { x: number; y: number; width: number; height: number }+): CanvasNode[] {+ const node = nodes.find((n) => n.id === nodeId)+ if (!node || node.type === 'group' || node.data.collapsed) return nodes+ return withNodeRect(nodes, node, rect, {})+}++/**+ * The shared placement core: put `node` at the ROOT-space `rect` (converted to parent-relative),+ * patch its data, and re-fit the ancestor frames in the same transform — `extent:'parent'` would+ * otherwise clamp a child bigger than its frame into an inverted range (the snap+ * `groupSelectedNodes` documents).+ */+function withNodeRect(+ nodes: CanvasNode[],+ node: CanvasNode,+ rect: { x: number; y: number; width: number; height: number },+ dataPatch: Partial<NodeData>+): CanvasNode[] {// rect is root-space; a grouped node's position is relative to its frame, so subtract the// ancestor origins (root position minus own offset = the parent chain's origin).+ const root = rootPosition(node, nodes)const originX = root.x - node.position.xconst originY = root.y - node.position.yconst next = nodes.map((n) =>- n.id === nodeId+ n.id === node.id? {...n,position: { x: rect.x - originX, y: rect.y - originY },@@ -1238,7 +1272,7 @@ export function maximizeNodeToRect(// Drop the stale measurement in the same tick: flowToNodeStates prefers `measured` over// `width`/`height`, and a commit racing the re-measure would persist the OLD size.measured: undefined,- data: { ...n.data, premaxRect, expandedHeight: rect.height }+ data: { ...n.data, expandedHeight: rect.height, ...dataPatch }}: n)@@ -1255,23 +1289,7 @@ export function restoreMaximizedNode(nodes: CanvasNode[], nodeId: string): Canvaconst node = nodes.find((n) => n.id === nodeId)const prev = node?.data.premaxRectif (!node || !prev) return nodes- const root = rootPosition(node, nodes)- const originX = root.x - node.position.x- const originY = root.y - node.position.y- const next = nodes.map((n) =>- n.id === nodeId- ? {- ...n,- position: { x: prev.x - originX, y: prev.y - originY },- width: prev.width,- height: prev.height,- style: { ...n.style, width: prev.width, height: prev.height },- measured: undefined,- data: { ...n.data, premaxRect: undefined, expandedHeight: prev.height }- }- : n- )- return fitAncestorChain(next, node.parentId)+ return withNodeRect(nodes, node, prev, { premaxRect: undefined })}/**diff --git a/src/shared/keybindings.test.ts b/src/shared/keybindings.test.tsindex 7ce4718d0..5c51732dd 100644--- a/src/shared/keybindings.test.ts+++ b/src/shared/keybindings.test.ts@@ -143,6 +143,14 @@ describe('registry invariants', () => {darwin: ['Cmd+ArrowDown'], other: ['Ctrl+Shift+ArrowDown'], allowInTerminal: true },{ id: 'node.maximize', title: 'Maximize / restore node', group: 'Nodes', scope: 'canvas',darwin: ['Cmd+Shift+Enter'], other: ['Cmd+Shift+Enter'], allowInTerminal: true },+ { id: 'node.zoneLeft', title: 'Snap node to left half', group: 'Nodes', scope: 'canvas',+ darwin: ['Ctrl+Alt+ArrowLeft'], other: [], allowInTerminal: true },+ { id: 'node.zoneRight', title: 'Snap node to right half', group: 'Nodes', scope: 'canvas',+ darwin: ['Ctrl+Alt+ArrowRight'], other: [], allowInTerminal: true },+ { id: 'node.zoneUp', title: 'Snap node to top half', group: 'Nodes', scope: 'canvas',+ darwin: ['Ctrl+Alt+ArrowUp'], other: [], allowInTerminal: true },+ { id: 'node.zoneDown', title: 'Snap node to bottom half', group: 'Nodes', scope: 'canvas',+ darwin: ['Ctrl+Alt+ArrowDown'], other: [], 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.tsindex da2ba12de..8ce269922 100644--- a/src/shared/keybindings.ts+++ b/src/shared/keybindings.ts@@ -77,6 +77,10 @@ export type CommandId =| 'node.focusUp'| 'node.focusDown'| 'node.maximize'+ | 'node.zoneLeft'+ | 'node.zoneRight'+ | 'node.zoneUp'+ | 'node.zoneDown'| 'node.close'| 'node.toggleMarkdown'| 'terminal.find'@@ -207,6 +211,20 @@ export const COMMAND_DEFINITIONS: readonly CommandDefinition[] = [// and collides with nothing here (scm.commit's ⌘Enter is a different chord, scm scope).{ id: 'node.maximize', title: 'Maximize / restore node', group: 'Nodes', scope: 'canvas',defaultBindings: both('Cmd+Shift+Enter'), allowInTerminal: true },+ // Zone snap (issue #394 v1): send the node under the keyboard (else the single selected one)+ // into a half of the visible canvas — the Rectangle/Magnet ⌃⌥arrow idiom, which is why the mac+ // default is Ctrl+Alt (literal Control, not Cmd). Off-mac the halves ship UNBOUND: Ctrl+Alt+Arrow+ // would trip the speech.dictation hold chord there ('Cmd+Alt' resolves to Ctrl+Alt held — the+ // exact trap the node.focus* comment documents), and Ctrl+Shift+Arrow is those focus commands.+ // Quarters and thirds have no commands — the node context menu's "Snap to zone" carries them.+ { id: 'node.zoneLeft', title: 'Snap node to left half', group: 'Nodes', scope: 'canvas',+ defaultBindings: { darwin: ['Ctrl+Alt+ArrowLeft'], other: [] }, allowInTerminal: true },+ { id: 'node.zoneRight', title: 'Snap node to right half', group: 'Nodes', scope: 'canvas',+ defaultBindings: { darwin: ['Ctrl+Alt+ArrowRight'], other: [] }, allowInTerminal: true },+ { id: 'node.zoneUp', title: 'Snap node to top half', group: 'Nodes', scope: 'canvas',+ defaultBindings: { darwin: ['Ctrl+Alt+ArrowUp'], other: [] }, allowInTerminal: true },+ { id: 'node.zoneDown', title: 'Snap node to bottom half', group: 'Nodes', scope: 'canvas',+ defaultBindings: { darwin: ['Ctrl+Alt+ArrowDown'], other: [] }, 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 },