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(keybindings): commands for the zone thirds and quarters (#1219)
eneskirca363ab8e4821b
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex facb19a53..724d00702 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -414,7 +414,13 @@ import {import { NODE_MAXIMIZE_MARGIN_PX, maximizeTargetRect } from '../lib/nodeMaximize'import { measurePinnedInsets, type ScreenInsets } from '../lib/pinnedInsets'import { measureMaximizeInsets, MAXIMIZE_CHROME_SELECTOR } from '../lib/maximizeInsets'-import { ZONE_GUTTER_PX, zoneTargetRect, type ZoneId } from '../lib/nodeZones'+import {+ ZONES,+ ZONE_COMMANDS,+ ZONE_GUTTER_PX,+ zoneTargetRect,+ type ZoneId+} from '../lib/nodeZones'import {recordBreadcrumb,stepBreadcrumb,@@ -10185,10 +10191,10 @@ export function Canvas() {'node.focusUp': () => moveNodeFocus('up'),'node.focusDown': () => moveNodeFocus('down'),'node.maximize': toggleMaximizeCommand,- 'node.zoneLeft': () => snapNodeToZone('left-half'),- 'node.zoneRight': () => snapNodeToZone('right-half'),- 'node.zoneUp': () => snapNodeToZone('top-half'),- 'node.zoneDown': () => snapNodeToZone('bottom-half')+ // Every zone, halves through quarters, from the one table (issue #1169).+ ...Object.fromEntries(+ ZONES.map((z) => [ZONE_COMMANDS[z.id], () => snapNodeToZone(z.id)])+ )// node.close / node.toggleMarkdown: main-process intercepted on desktop; deliberately// no renderer handler here. The browser owns ⌘W in the Server Edition (see// bridge/stubs.ts); ⌘/Ctrl+M there is matched by the bridge's OWN window listenerdiff --git a/src/renderer/components/ShortcutsPanel.test.tsx b/src/renderer/components/ShortcutsPanel.test.tsxindex 8abdac1c8..4c81ccc7c 100644--- a/src/renderer/components/ShortcutsPanel.test.tsx+++ b/src/renderer/components/ShortcutsPanel.test.tsx@@ -56,7 +56,8 @@ function bindEverything(isMac: boolean): (id: CommandId) => readonly string[] {...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''),...'0123456789'.split(''),...Array.from({ length: 12 }, (_, i) => `F${i + 1}`),- 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageUp', 'PageDown'+ 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageUp', 'PageDown',+ 'Comma', 'Slash', 'Period', 'Home', 'End', 'Insert', 'Delete', 'Backspace', 'Tab']expect(pool.length).toBeGreaterThanOrEqual(COMMAND_DEFINITIONS.length)const map = new Map<CommandId, string[]>()diff --git a/src/renderer/lib/nodeZones.test.ts b/src/renderer/lib/nodeZones.test.tsindex dfeeef037..232bcffe5 100644--- a/src/renderer/lib/nodeZones.test.ts+++ b/src/renderer/lib/nodeZones.test.ts@@ -1,5 +1,6 @@import { describe, it, expect } from 'vitest'-import { ZONES, ZONE_GUTTER_PX, zoneTargetRect } from './nodeZones'+import { ZONES, ZONE_COMMANDS, ZONE_GUTTER_PX, zoneTargetRect } from './nodeZones'+import { COMMAND_DEFINITIONS, isCommandId } from '@shared/keybindings'import { NODE_MAXIMIZE_MARGIN_PX, maximizeTargetRect } from './nodeMaximize'import type { ScreenInsets } from './pinnedInsets'@@ -112,3 +113,26 @@ describe('zoneTargetRect', () => {expect(right.x + right.width).toBeCloseTo(max.x + max.width)})})++describe('ZONE_COMMANDS (issue #1169)', () => {+ it('gives every zone in the menu exactly one registry command', () => {+ for (const z of ZONES) {+ const id = ZONE_COMMANDS[z.id]+ expect(isCommandId(id), z.id).toBe(true)+ const def = COMMAND_DEFINITIONS.find((d) => d.id === id)+ expect(def?.scope, z.id).toBe('canvas')+ expect(def?.allowInTerminal, z.id).toBe(true)+ }+ expect(new Set(Object.values(ZONE_COMMANDS)).size).toBe(ZONES.length)+ })++ it('keeps the halves bound on mac and ships thirds and quarters unbound everywhere', () => {+ const halves = new Set(['left-half', 'right-half', 'top-half', 'bottom-half'])+ for (const z of ZONES) {+ const def = COMMAND_DEFINITIONS.find((d) => d.id === ZONE_COMMANDS[z.id])!+ if (halves.has(z.id)) continue+ expect(def.defaultBindings.darwin, z.id).toEqual([])+ expect(def.defaultBindings.other, z.id).toEqual([])+ }+ })+})diff --git a/src/renderer/lib/nodeZones.ts b/src/renderer/lib/nodeZones.tsindex 0619a7eaa..1abb47cb2 100644--- a/src/renderer/lib/nodeZones.ts+++ b/src/renderer/lib/nodeZones.ts@@ -9,6 +9,7 @@// where it was put.import type { Viewport } from '@xyflow/system'+import type { CommandId } from '@shared/keybindings'import { NODE_MAXIMIZE_MARGIN_PX, type FlowRect } from './nodeMaximize'import { NO_INSETS, type ScreenInsets } from './pinnedInsets'@@ -50,6 +51,24 @@ export const ZONES: readonly { id: ZoneId; label: string; frac: ZoneFraction }[]{ id: 'right-third', label: 'Right third', frac: { x0: 2 / 3, y0: 0, x1: 1, y1: 1 } }]+/**+ * The keyboard command for each zone (issue #1169). Total over `ZoneId`, so a new zone is a+ * compile error until it has a command; Canvas dispatches from this table, never a hand list.+ */+export const ZONE_COMMANDS: Readonly<Record<ZoneId, CommandId>> = {+ 'left-half': 'node.zoneLeft',+ 'right-half': 'node.zoneRight',+ 'top-half': 'node.zoneUp',+ 'bottom-half': 'node.zoneDown',+ 'top-left': 'node.zoneTopLeft',+ 'top-right': 'node.zoneTopRight',+ 'bottom-left': 'node.zoneBottomLeft',+ 'bottom-right': 'node.zoneBottomRight',+ 'left-third': 'node.zoneLeftThird',+ 'center-third': 'node.zoneCenterThird',+ 'right-third': 'node.zoneRightThird'+}+const ZONES_BY_ID: ReadonlyMap<ZoneId, ZoneFraction> = new Map(ZONES.map((z) => [z.id, z.frac]))/**diff --git a/src/shared/keybindings.test.ts b/src/shared/keybindings.test.tsindex b78d9994b..075ddbcaa 100644--- a/src/shared/keybindings.test.ts+++ b/src/shared/keybindings.test.ts@@ -159,6 +159,20 @@ describe('registry invariants', () => {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.zoneLeftThird', title: 'Snap node to left third', group: 'Nodes',+ scope: 'canvas', darwin: [], other: [], allowInTerminal: true },+ { id: 'node.zoneCenterThird', title: 'Snap node to center third', group: 'Nodes',+ scope: 'canvas', darwin: [], other: [], allowInTerminal: true },+ { id: 'node.zoneRightThird', title: 'Snap node to right third', group: 'Nodes',+ scope: 'canvas', darwin: [], other: [], allowInTerminal: true },+ { id: 'node.zoneTopLeft', title: 'Snap node to top left quarter', group: 'Nodes',+ scope: 'canvas', darwin: [], other: [], allowInTerminal: true },+ { id: 'node.zoneTopRight', title: 'Snap node to top right quarter', group: 'Nodes',+ scope: 'canvas', darwin: [], other: [], allowInTerminal: true },+ { id: 'node.zoneBottomLeft', title: 'Snap node to bottom left quarter', group: 'Nodes',+ scope: 'canvas', darwin: [], other: [], allowInTerminal: true },+ { id: 'node.zoneBottomRight', title: 'Snap node to bottom right quarter', group: 'Nodes',+ scope: 'canvas', darwin: [], 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 77289afb1..94f030a5e 100644--- a/src/shared/keybindings.ts+++ b/src/shared/keybindings.ts@@ -94,6 +94,13 @@ export type CommandId =| 'node.zoneRight'| 'node.zoneUp'| 'node.zoneDown'+ | 'node.zoneLeftThird'+ | 'node.zoneCenterThird'+ | 'node.zoneRightThird'+ | 'node.zoneTopLeft'+ | 'node.zoneTopRight'+ | 'node.zoneBottomLeft'+ | 'node.zoneBottomRight'| 'node.close'| 'node.toggleMarkdown'| 'board.openCard'@@ -246,7 +253,6 @@ export const COMMAND_DEFINITIONS: readonly CommandDefinition[] = [// 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',@@ -255,6 +261,24 @@ export const COMMAND_DEFINITIONS: readonly CommandDefinition[] = [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 },+ // Thirds and quarters (issue #1169): the rest of the zone list, same rules as the halves, but+ // shipped UNBOUND on every platform. There is no free chord family left for seven more zones+ // (Ctrl+Alt+Arrow is the halves', Ctrl+Shift+Arrow and Cmd+Arrow are focus), and a default here+ // would steal a key from somebody's shell via allowInTerminal. The user binds the ones they use.+ { id: 'node.zoneLeftThird', title: 'Snap node to left third', group: 'Nodes', scope: 'canvas',+ defaultBindings: both(), allowInTerminal: true },+ { id: 'node.zoneCenterThird', title: 'Snap node to center third', group: 'Nodes', scope: 'canvas',+ defaultBindings: both(), allowInTerminal: true },+ { id: 'node.zoneRightThird', title: 'Snap node to right third', group: 'Nodes', scope: 'canvas',+ defaultBindings: both(), allowInTerminal: true },+ { id: 'node.zoneTopLeft', title: 'Snap node to top left quarter', group: 'Nodes', scope: 'canvas',+ defaultBindings: both(), allowInTerminal: true },+ { id: 'node.zoneTopRight', title: 'Snap node to top right quarter', group: 'Nodes', scope: 'canvas',+ defaultBindings: both(), allowInTerminal: true },+ { id: 'node.zoneBottomLeft', title: 'Snap node to bottom left quarter', group: 'Nodes', scope: 'canvas',+ defaultBindings: both(), allowInTerminal: true },+ { id: 'node.zoneBottomRight', title: 'Snap node to bottom right quarter', group: 'Nodes', scope: 'canvas',+ defaultBindings: both(), 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 },