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(settings): per-kind default node sizes
Brandon Bridges5037df248323
diff --git a/CLAUDE.md b/CLAUDE.mdindex 17c8262ec..baf802325 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -8781,8 +8781,13 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord meashould gain the three categories. All three are the iOS follow-up, not desktop work.- **Omni Kanban (global swimlanes)** (`components/kanban/GlobalKanbanView.tsx`; one swimlane per open project; `state/viewMode.ts` `globalKanban` (localStorage `nodeterm.globalKanban`, machine-local, like `viewByProject`) + `settings.omniKanbanEnabled` (feature gate, default OFF, `settings.json`) / `omniKanbanAsDefault` (when true, `view.kanbanToggle` — Cmd+Shift+B — opens Omni; otherwise per-project; `view.globalKanbanToggle` registry command — unbound, remappable — always opens Omni when enabled); **Omni is a SCOPE of the kanban side, not a third view**: the view toggle (tab icon, ⌘⇧B, the menu) flips canvas ⇄ board, and a board header's `KanbanScopeSwitch` ("This project" / "All projects", rendered only while the feature is on) moves between the two scopes — so leaving Omni through the switch lands on the project's board, and the view toggle from Omni lands on the canvas (it used to fall through to whatever the project's view happened to be, so "Canvas view" from Omni could land on a board). The decisions live once in `state/viewMode.ts` (`toggleBoardView` / `toggleAllProjectsBoard` / `showProjectBoard` / `showCanvas`), called by TabBar, the menu IPC and both registry commands; Omni has no close button. `globalKanban` deliberately stays independent of the active project, so a project switch made from a lane does not drop the user out of Omni. `isGlobalKanbanOpen()` is the single gate (fail-closed, static import of `useSettings` — the earlier `require` failed open in the packaged renderer). Non-active lanes are derived from serialized `p.nodes` via `toKanbanSessionState` (the persisted-state counterpart to `toKanbanSession`); the ACTIVE project's lane is fed LIVE by Canvas (`GlobalKanbanLive`: the same `kanbanSessionsFrom(nodes)` cards + live `teamStations` the per-project board uses), because its edits reach the store only at the next ~800 ms autosave — a store-fed lane reverted the card modal's controlled sticky textarea on every keystroke and pruned the assignment of a card created a moment earlier. The open card modal is ONE overview-level fact reported to Canvas's `setKanbanModalNode` (watched for Eco, wake-on-open, dictation target), never per-lane state; each lane's board write resolves ITS project's session (`sessionForProject`) for the hosted read-only refusal and the board-log api; `pendingLaunch` never becomes `initialCommand` in the modal (the DAG launch must fire only when dependencies report done, and the canvas `TerminalNode` already delivers `initialCommand` via `writeWhenShellReady` after the `nodeterm:create-node` project switch). Active-project edits (rename / sticky / browser nav) route through Canvas live nodes (`setNodes` + `markDirty`), non-active through the store + `writeDisk`; delete uses `ConfirmDialog` (not `confirm`) and then `deleteNodes` (active project) or `closeStoredNodes` (any other) — the existing cross-project teardown funnel, never a hand-rolled copy. The top bar's project pills and Cmd/Ctrl+1..9 (`nodeterm:swimlane-jump`) jump to the lane; header hint shows the correct mod (`Cmd` on Mac, `Ctrl` elsewhere). Server Edition works as-is, Mobile N/A.- **Settings** (`SettingsPage.tsx`, ⚙ / ⌘,): font/cursor (live to xterm + Monaco), default- shell, grid + snap, **default node size** (`defaultNodeWidth`/`defaultNodeHeight` — new- terminal/agent nodes only, clamped in `terminalNodeSize()` in `state/workspace.ts`),+ shell, grid + snap, **default node size** (one row with a kind picker: terminal/agent is the+ `defaultNodeWidth`/`defaultNodeHeight` pair, clamped in `terminalNodeSize()`; every other kind+ the add menus create is an optional entry in `defaultNodeSizes`, resolved by `defaultNodeSize(kind)`+ in `state/workspace.ts` through `@shared/default-node-size`, which clamps hand edits to the kind's+ `NODE_MIN_SIZES` and 2400×1600 — new factories must place through `placeSized`, not a literal+ `*_SIZE`, or the setting silently stops applying to that kind; the agent `settings` verb exposes+ only the terminal pair),pan-hover delay, double-click focus, accent, tmux on/scrollback, commit agent,`seenShortcuts`. **Every section is MOUNTED whenever Settings is open** — an inactive onereturns null from `SettingsSection`, but its hooks and the whole render body above that returndiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 3a8beda69..6e636157b 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -1195,6 +1195,11 @@ the kind union, so a new kind is a **compile error** until you route it. The kan`addMenuSpec.surfaces.test.ts` pins that split so "make them all consistent" stays a decisionrather than a reflex.+**A new node kind also gets a default size the user can change.** Add it to `SizableNodeKind` /+`SIZABLE_NODE_KINDS` (`shared/default-node-size.ts`) and `BUILTIN_NODE_SIZES`, and place it with+`placeSized(kind, …)` in its factory. A literal `*_SIZE` passed to `placeNode` compiles fine and+quietly ignores Settings → Behavior → Default node size for that kind.+**A setting read at mount reads the DEFAULT, not the user's.** `useSettings` starts on`DEFAULT_SETTINGS` and hydrates from disk asynchronously, while `<Canvas />` is mounted before thatlands. A `useState(() => settings.foo ? ...)` initializer therefore reads the shipped default anddiff --git a/src/renderer/components/settings/sections/BehaviorSection.tsx b/src/renderer/components/settings/sections/BehaviorSection.tsxindex fc4fd2fe3..1e6cd3b83 100644--- a/src/renderer/components/settings/sections/BehaviorSection.tsx+++ b/src/renderer/components/settings/sections/BehaviorSection.tsx@@ -1,3 +1,4 @@+import { useState } from 'react'import { useSettings } from '../../../state/settings'import { SettingsSection } from '../SettingsSection'import { SearchableRow } from '../SearchableRow'@@ -14,6 +15,16 @@ import { backgroundCloseDescription, backgroundCloseRowVisible } from '@rendererimport type { BackgroundOnCloseSetting } from '@shared/types'import { clampWheelZoomSpeed } from '@renderer/canvas/wheel-zoom'import { DEFAULT_WORKTREE_PATH_TEMPLATE } from '@shared/worktree'+import { Button } from '@renderer/ui/Button'+import type { NodeSize } from '@shared/default-node-size'+import {+ NODE_SIZE_CHOICES,+ NODE_SIZE_CHOICE_LABELS,+ nodeSizeField,+ nodeSizePatch,+ nodeSizeResetPatch,+ type NodeSizeChoice+} from '@renderer/lib/defaultNodeSizeSetting'const ROWS = {defaultView: {@@ -31,7 +42,10 @@ const ROWS = {gridSize: { title: 'Grid size', keywords: ['grid', 'size', 'snap'] },nodeSize: {title: 'Default node size',- keywords: ['node', 'size', 'width', 'height', 'terminal', 'default']+ keywords: [+ 'node', 'size', 'width', 'height', 'terminal', 'default', 'sticky', 'note', 'browser', 'web',+ 'editor', 'diff', 'file', 'manager', 'video', 'simulator', 'trigger', 'dino'+ ]},snap: { title: 'Snap to grid', keywords: ['snap', 'grid', 'align'] },autoAlign: {@@ -177,29 +191,7 @@ export function BehaviorSection({ isActive }: { isActive: boolean }): React.JSX./></SearchableRow><SearchableRow {...ROWS.nodeSize}>- <FieldRow- label="Default node size (px)"- description="Size new terminal and agent nodes open at. Existing nodes keep their size."- control={- <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>- <NumberField- value={settings.defaultNodeWidth}- min={280}- max={2400}- step={20}- onChange={(v) => update({ defaultNodeWidth: v || 640 })}- />- <span style={{ opacity: 0.6 }}>×</span>- <NumberField- value={settings.defaultNodeHeight}- min={160}- max={1600}- step={20}- onChange={(v) => update({ defaultNodeHeight: v || 440 })}- />- </div>- }- />+ <DefaultNodeSizeRow /></SearchableRow><SearchableRow {...ROWS.snap}><FieldRow@@ -526,3 +518,61 @@ export function BehaviorSection({ isActive }: { isActive: boolean }): React.JSX.</SettingsSection>)}++/**+ * One width × height pair for whichever kind the picker names. New nodes of that kind open at it;+ * existing nodes keep their size. The model (and why terminal is special) is in+ * lib/defaultNodeSizeSetting.ts.+ */+function DefaultNodeSizeRow(): React.JSX.Element {+ const settings = useSettings((s) => s.settings)+ const update = useSettings((s) => s.update)+ const [choice, setChoice] = useState<NodeSizeChoice>('terminal')+ const field = nodeSizeField(settings, choice)+ const set = (size: NodeSize): void => {+ update(nodeSizePatch(settings, choice, size))+ }+ return (+ <FieldRow+ label="Default node size (px)"+ description="Size new nodes of the chosen kind open at. Existing nodes keep their size."+ control={+ <div style={{ display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' }}>+ <Select+ aria-label="Node kind"+ value={choice}+ onChange={(e) => setChoice(e.target.value as NodeSizeChoice)}+ >+ {NODE_SIZE_CHOICES.map((c) => (+ <option key={c} value={c}>+ {NODE_SIZE_CHOICE_LABELS[c]}+ </option>+ ))}+ </Select>+ <NumberField+ ariaLabel={`${NODE_SIZE_CHOICE_LABELS[choice]} default width`}+ value={field.size.width}+ min={field.min.width}+ max={field.max.width}+ step={20}+ onChange={(v) => set({ width: v || field.size.width, height: field.size.height })}+ />+ <span style={{ opacity: 0.6 }}>×</span>+ <NumberField+ ariaLabel={`${NODE_SIZE_CHOICE_LABELS[choice]} default height`}+ value={field.size.height}+ min={field.min.height}+ max={field.max.height}+ step={20}+ onChange={(v) => set({ width: field.size.width, height: v || field.size.height })}+ />+ {field.isCustom && (+ <Button variant="ghost" onClick={() => update(nodeSizeResetPatch(settings, choice))}>+ Reset+ </Button>+ )}+ </div>+ }+ />+ )+}diff --git a/src/renderer/lib/defaultNodeSizeSetting.test.ts b/src/renderer/lib/defaultNodeSizeSetting.test.tsnew file mode 100644index 000000000..647587887--- /dev/null+++ b/src/renderer/lib/defaultNodeSizeSetting.test.ts@@ -0,0 +1,82 @@+import { afterEach, describe, expect, it } from 'vitest'+import { DEFAULT_SETTINGS, type Settings } from '@shared/types'+import { SIZABLE_NODE_KINDS } from '@shared/default-node-size'+import { useSettings } from '../state/settings'+import {+ NODE_SIZE_CHOICES,+ NODE_SIZE_CHOICE_LABELS,+ nodeSizeField,+ nodeSizePatch,+ nodeSizeResetPatch+} from './defaultNodeSizeSetting'++function settings(over: Partial<Settings> = {}): Settings {+ const s = { ...DEFAULT_SETTINGS, ...over }+ useSettings.setState({ settings: s })+ return s+}++afterEach(() => settings())++describe('Default node size setting model', () => {+ it('offers terminal first, then every sizable kind, each with a label', () => {+ expect(NODE_SIZE_CHOICES).toEqual(['terminal', ...SIZABLE_NODE_KINDS])+ for (const c of NODE_SIZE_CHOICES) expect(NODE_SIZE_CHOICE_LABELS[c]).toBeTruthy()+ })++ it('keeps terminal on the existing width/height pair', () => {+ const s = settings({ defaultNodeWidth: 700, defaultNodeHeight: 480 })+ expect(nodeSizeField(s, 'terminal')).toMatchObject({ size: { width: 700, height: 480 }, isCustom: true })+ expect(nodeSizeField(settings(), 'terminal').isCustom).toBe(false)+ expect(nodeSizePatch(s, 'terminal', { width: 720, height: 500 })).toEqual({+ defaultNodeWidth: 720,+ defaultNodeHeight: 500+ })+ })++ it('shows the built-in size for a kind the user never set, marked not isCustom', () => {+ const s = settings()+ expect(nodeSizeField(s, 'sticky')).toMatchObject({ size: { width: 240, height: 200 }, isCustom: false })+ })++ it('writes one kind without disturbing the others', () => {+ const s = settings({ defaultNodeSizes: { files: { width: 400, height: 600 } } })+ expect(nodeSizePatch(s, 'sticky', { width: 300, height: 260 })).toEqual({+ defaultNodeSizes: { files: { width: 400, height: 600 }, sticky: { width: 300, height: 260 } }+ })+ })++ it('resets one kind back to built-in by removing only its entry', () => {+ const s = settings({+ defaultNodeSizes: { files: { width: 400, height: 600 }, sticky: { width: 300, height: 260 } }+ })+ expect(nodeSizeResetPatch(s, 'sticky')).toEqual({ defaultNodeSizes: { files: { width: 400, height: 600 } } })+ expect(s.defaultNodeSizes.sticky).toEqual({ width: 300, height: 260 }) // input not mutated+ })++ it('resets terminal to the shipped default pair', () => {+ const s = settings({ defaultNodeWidth: 900, defaultNodeHeight: 700 })+ expect(nodeSizeResetPatch(s, 'terminal')).toEqual({+ defaultNodeWidth: DEFAULT_SETTINGS.defaultNodeWidth,+ defaultNodeHeight: DEFAULT_SETTINGS.defaultNodeHeight+ })+ })++ it('shows the stored numbers unclamped, so typing 300 digit by digit is not snapped to the minimum', () => {+ const s = settings({ defaultNodeSizes: { sticky: { width: 3, height: 200 } } })+ expect(nodeSizeField(s, 'sticky').size).toEqual({ width: 3, height: 200 })+ const t = settings({ defaultNodeWidth: 3 })+ expect(nodeSizeField(t, 'terminal').size.width).toBe(3)+ })++ it('never spreads a hand-edited non-object defaultNodeSizes into index keys', () => {+ for (const junk of ['abc', ['x'], 7, null]) {+ const s = settings({ defaultNodeSizes: junk as unknown as Settings['defaultNodeSizes'] })+ expect(nodeSizePatch(s, 'sticky', { width: 300, height: 260 })).toEqual({+ defaultNodeSizes: { sticky: { width: 300, height: 260 } }+ })+ expect(nodeSizeResetPatch(s, 'sticky')).toEqual({ defaultNodeSizes: {} })+ expect(nodeSizeField(s, 'sticky').size).toEqual({ width: 240, height: 200 })+ }+ })+})diff --git a/src/renderer/lib/defaultNodeSizeSetting.ts b/src/renderer/lib/defaultNodeSizeSetting.tsnew file mode 100644index 000000000..05e2225ab--- /dev/null+++ b/src/renderer/lib/defaultNodeSizeSetting.ts@@ -0,0 +1,92 @@+import { DEFAULT_SETTINGS, type Settings } from '@shared/types'+import {+ NODE_SIZE_MAX,+ SIZABLE_NODE_KINDS,+ TERMINAL_NODE_SIZE_MIN,+ defaultNodeSizesRecord,+ storedDefaultNodeSize,+ type NodeSize,+ type SizableNodeKind+} from '@shared/default-node-size'+import { BUILTIN_NODE_SIZES } from '../state/workspace'+import { NODE_MIN_SIZES } from './nodeSizing'++/**+ * The model behind Settings → Behavior → Default node size: one width × height pair, with a+ * picker choosing which kind it edits. `terminal` stands for terminal AND agent nodes and is+ * backed by the long-standing `defaultNodeWidth`/`defaultNodeHeight` pair, so nothing a user set+ * before per-kind sizes existed moves; every other kind lives in `defaultNodeSizes`.+ */+export type NodeSizeChoice = 'terminal' | SizableNodeKind++export const NODE_SIZE_CHOICES: readonly NodeSizeChoice[] = ['terminal', ...SIZABLE_NODE_KINDS]++export const NODE_SIZE_CHOICE_LABELS: Record<NodeSizeChoice, string> = {+ terminal: 'Terminal & agent',+ sticky: 'Sticky note',+ browser: 'Browser',+ web: 'Web view',+ editor: 'Editor',+ diff: 'Diff',+ files: 'File manager',+ video: 'Video',+ simulator: 'Simulator',+ trigger: 'Trigger',+ dino: 'Dino game'+}++export interface NodeSizeField {+ size: NodeSize+ min: NodeSize+ max: NodeSize+ /** Whether this kind differs from its shipped default (drives the per-kind reset). Terminal's+ * pair is a plain setting with a default, so it counts as custom when it moved off it. */+ isCustom: boolean+}++/**+ * What the two number fields show for `choice`: the STORED numbers, not the clamped size a node+ * would open at. `NumberField` writes on every keystroke, so showing the clamped value would snap+ * the "3" of "300" to the minimum before the rest is typed. Creation clamps (`terminalNodeSize`,+ * `defaultNodeSize`), which is where a hand-edited 0 or 99999 is made safe.+ */+export function nodeSizeField(settings: Settings, choice: NodeSizeChoice): NodeSizeField {+ if (choice === 'terminal') {+ const isCustom =+ settings.defaultNodeWidth !== DEFAULT_SETTINGS.defaultNodeWidth ||+ settings.defaultNodeHeight !== DEFAULT_SETTINGS.defaultNodeHeight+ const size = storedDefaultNodeSize(+ { width: settings.defaultNodeWidth, height: settings.defaultNodeHeight },+ { width: DEFAULT_SETTINGS.defaultNodeWidth, height: DEFAULT_SETTINGS.defaultNodeHeight }+ )+ return { size, min: TERMINAL_NODE_SIZE_MIN, max: NODE_SIZE_MAX, isCustom }+ }+ const stored = defaultNodeSizesRecord(settings.defaultNodeSizes)[choice]+ return {+ size: storedDefaultNodeSize(stored, BUILTIN_NODE_SIZES[choice]),+ min: NODE_MIN_SIZES[choice],+ max: NODE_SIZE_MAX,+ isCustom: stored !== undefined+ }+}++/** The settings patch that makes `choice` open at `size`. */+export function nodeSizePatch(settings: Settings, choice: NodeSizeChoice, size: NodeSize): Partial<Settings> {+ if (choice === 'terminal') return { defaultNodeWidth: size.width, defaultNodeHeight: size.height }+ return {+ defaultNodeSizes: {+ ...defaultNodeSizesRecord(settings.defaultNodeSizes),+ [choice]: { width: size.width, height: size.height }+ }+ }+}++/** The settings patch that puts `choice` back to its built-in size. */+export function nodeSizeResetPatch(settings: Settings, choice: NodeSizeChoice): Partial<Settings> {+ if (choice === 'terminal') {+ return { defaultNodeWidth: DEFAULT_SETTINGS.defaultNodeWidth, defaultNodeHeight: DEFAULT_SETTINGS.defaultNodeHeight }+ }+ const next = { ...defaultNodeSizesRecord(settings.defaultNodeSizes) }+ delete next[choice]+ return { defaultNodeSizes: next }+}diff --git a/src/renderer/lib/nodeSizing.ts b/src/renderer/lib/nodeSizing.tsindex a66c4390f..5ede83db0 100644--- a/src/renderer/lib/nodeSizing.ts+++ b/src/renderer/lib/nodeSizing.ts@@ -1,4 +1,5 @@import type { NodeKind } from '@shared/types'+import { STICKY_NODE_MIN_SIZE } from '@shared/default-node-size'/*** Minimum width/height for each node kind. These are the single source of truth@@ -12,7 +13,7 @@ import type { NodeKind } from '@shared/types'*/export const NODE_MIN_SIZES: Record<NodeKind, { width: number; height: number }> = {terminal: { width: 260, height: 160 },- sticky: { width: 160, height: 120 },+ sticky: STICKY_NODE_MIN_SIZE,group: { width: 200, height: 140 },editor: { width: 320, height: 200 },diff: { width: 420, height: 220 },diff --git a/src/renderer/state/workspace.default-sizes.test.ts b/src/renderer/state/workspace.default-sizes.test.tsnew file mode 100644index 000000000..b4e822dab--- /dev/null+++ b/src/renderer/state/workspace.default-sizes.test.ts@@ -0,0 +1,69 @@+import { afterEach, describe, expect, it } from 'vitest'+import { DEFAULT_SETTINGS } from '@shared/types'+import { useSettings } from './settings'+import {+ createBrowserNode,+ createFilesNode,+ createStickyNode,+ createTerminalNode,+ createTriggerNode,+ defaultNodeSize+} from './workspace'++function settings(over: Partial<typeof DEFAULT_SETTINGS>): void {+ useSettings.setState({ settings: { ...DEFAULT_SETTINGS, ...over } })+}++afterEach(() => settings({}))++const size = (n: { width?: number; height?: number }): [number | undefined, number | undefined] => [+ n.width,+ n.height+]++describe('per-kind default node sizes (Settings → Behavior → Default node size)', () => {+ it('leaves every kind at its built-in size when nothing is set', () => {+ expect(size(createStickyNode(0))).toEqual([240, 200])+ expect(size(createFilesNode(0, '/tmp'))).toEqual([340, 460])+ })++ it('opens a new node at the size the user set for its kind', () => {+ settings({ defaultNodeSizes: { sticky: { width: 400, height: 320 } } })+ expect(size(createStickyNode(0))).toEqual([400, 320])+ })++ it('only changes the kind that was set', () => {+ settings({ defaultNodeSizes: { sticky: { width: 400, height: 320 } } })+ expect(size(createFilesNode(0, '/tmp'))).toEqual([340, 460])+ expect(size(createBrowserNode(0, 'https://example.com'))).toEqual([800, 560])+ })++ it('covers the trigger node, which places itself without placeNode', () => {+ settings({ defaultNodeSizes: { trigger: { width: 360, height: 220 } } })+ const t = createTriggerNode(0)+ expect(size(t)).toEqual([360, 220])+ expect(t.style).toMatchObject({ width: 360, height: 220 })+ })++ it('keeps terminals on their own long-standing setting', () => {+ settings({ defaultNodeWidth: 700, defaultNodeHeight: 500, defaultNodeSizes: {} })+ expect(size(createTerminalNode(0))).toEqual([700, 500])+ })++ it('never opens a node below what its resizer allows, whatever settings.json says', () => {+ settings({ defaultNodeSizes: { sticky: { width: 10, height: 10 } } })+ expect(size(createStickyNode(0))).toEqual([160, 120])+ })++ it('snaps a configured size onto the grid like any other new node', () => {+ settings({ snapToGrid: true, gridSize: 20, defaultNodeSizes: { sticky: { width: 413, height: 307 } } })+ const n = createStickyNode(0, { x: 517, y: 293 })+ expect([(n.width as number) % 20, (n.height as number) % 20]).toEqual([0, 0])+ })++ it('exposes the resolved size for a kind, for surfaces that size before creating', () => {+ settings({ defaultNodeSizes: { files: { width: 420, height: 600 } } })+ expect(defaultNodeSize('files')).toEqual({ width: 420, height: 600 })+ expect(defaultNodeSize('sticky')).toEqual({ width: 240, height: 200 })+ })+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex 870cb9f97..cac3de2b7 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -53,13 +53,21 @@ export { accountNodeColor, agentAccountColor } from '@shared/agents/account-coloimport { mutationTrustsLaunch, sanitizeInboundNode } from '@shared/node-exec'import { SYSTEM_NODE_COLORS } from '@shared/node-colors'import { groupsFirstBy } from '@shared/node-order'+import {+ NODE_SIZE_MAX,+ STICKY_NODE_SIZE,+ TERMINAL_NODE_SIZE_MIN,+ resolveDefaultNodeSize,+ type NodeSize,+ type SizableNodeKind+} from '@shared/default-node-size'// Preserve the renderer's long-standing import surface; validation and the palette now live in// shared so Server Edition and canvas-control accept exactly what these pickers display.export { NODE_COLORS, SYSTEM_NODE_COLORS } from '@shared/node-colors'const TERMINAL_SIZE = { width: 640, height: 440 }-const STICKY_SIZE = { width: 240, height: 200 }+const STICKY_SIZE = STICKY_NODE_SIZEconst GROUP_SIZE = { width: 520, height: 360 }/** A fresh worktree group starts empty but exists to HOLD terminals/agents, and the default* GROUP_SIZE (520×360) is smaller than a single terminal (600×400) — a dropped-in terminal would@@ -356,11 +364,44 @@ export function terminalNodeSize(): { width: number; height: number } {return Math.min(hi, Math.max(lo, n))}return {- width: clamp(s.defaultNodeWidth, 280, 2400, TERMINAL_SIZE.width),- height: clamp(s.defaultNodeHeight, 160, 1600, TERMINAL_SIZE.height)+ width: clamp(s.defaultNodeWidth, TERMINAL_NODE_SIZE_MIN.width, NODE_SIZE_MAX.width, TERMINAL_SIZE.width),+ height: clamp(s.defaultNodeHeight, TERMINAL_NODE_SIZE_MIN.height, NODE_SIZE_MAX.height, TERMINAL_SIZE.height)}}+export const BUILTIN_NODE_SIZES: Readonly<Record<SizableNodeKind, NodeSize>> = {+ sticky: STICKY_SIZE,+ editor: EDITOR_SIZE,+ diff: DIFF_SIZE,+ video: VIDEO_SIZE,+ web: WEB_SIZE,+ browser: BROWSER_SIZE,+ files: FILES_SIZE,+ dino: DINO_SIZE,+ trigger: TRIGGER_SIZE,+ simulator: SIMULATOR_SIZE+}++/**+ * Default size for NEW nodes of a non-terminal kind: the user's per-kind setting (Settings →+ * Behavior → Default node size), else the kind's built-in size, clamped between its resizer+ * minimum and the canvas maximum. Read at creation time, never at mount (settings hydrate late).+ */+export function defaultNodeSize(kind: SizableNodeKind): NodeSize {+ const stored = useSettings.getState().settings.defaultNodeSizes?.[kind]+ return resolveDefaultNodeSize(stored, BUILTIN_NODE_SIZES[kind], NODE_MIN_SIZES[kind])+}++/** `placeNode` at the kind's default size. */+function placeSized(+ kind: SizableNodeKind,+ center: { x: number; y: number } | undefined,+ index: number+): Pick<CanvasNode, 'position' | 'width' | 'height' | 'style'> {+ const { width, height } = defaultNodeSize(kind)+ return placeNode(kind, center, index, width, height)+}+/*** Creates a new terminal node. `cwd` comes from the active project's default folder. When `ssh`* (the active SSH project's binding) is given, the node runs in REMOTE tmux on that host: its@@ -452,7 +493,7 @@ export function createSimulatorNode(return {id: nextId('sim'),type: 'simulator',- ...placeNode('simulator', center, index, SIMULATOR_SIZE.width, SIMULATOR_SIZE.height),+ ...placeSized('simulator', center, index),data: {title: c.name ?? 'Simulator',color: RUN_NODE_COLOR,@@ -1109,7 +1150,7 @@ export function createEditorNode(return {id: nextId('editor'),type: 'editor',- ...placeNode('editor', center, index, EDITOR_SIZE.width, EDITOR_SIZE.height),+ ...placeSized('editor', center, index),data: {title: filePath.split('/').pop() || 'untitled',color: '#6ac4dc',@@ -1173,7 +1214,7 @@ export function createVideoNode(return {id: nextId('video'),type: 'video',- ...placeNode('video', center, index, VIDEO_SIZE.width, VIDEO_SIZE.height),+ ...placeSized('video', center, index),data: {title: filePath.split('/').pop() || 'video',color: '#bf5af2',@@ -1196,7 +1237,7 @@ export function createWebNode(return {id: nextId('web'),type: 'web',- ...placeNode('web', center, index, WEB_SIZE.width, WEB_SIZE.height),+ ...placeSized('web', center, index),data: {title,color: '#6ac4dc',@@ -1226,7 +1267,7 @@ export function createBrowserNode(return {id: nextId('browser'),type: 'browser',- ...placeNode('browser', center, index, BROWSER_SIZE.width, BROWSER_SIZE.height),+ ...placeSized('browser', center, index),data: {title,color: '#0a84ff',@@ -1259,7 +1300,7 @@ export function createFilesNode(// manager sitting off-grid beside snapped neighbours, and off-grid in SIZE too — React Flow// resizes by adding a grid multiple to the start size, so an unsnapped box can never be// dragged onto the grid afterwards.- ...placeNode('files', center, index, FILES_SIZE.width, FILES_SIZE.height),+ ...placeSized('files', center, index),data: {title: folderTitle(cwd),color: '#ffd60a',@@ -1282,7 +1323,7 @@ export function createDiffNode(return {id: nextId('diff'),type: 'diff',- ...placeNode('diff', center, index, DIFF_SIZE.width, DIFF_SIZE.height),+ ...placeSized('diff', center, index),data: {title: `${relPath.split('/').pop() || relPath} (${commitOid ? commitOid.slice(0, 7) : 'diff'})`,color: '#e0af68',@@ -1300,7 +1341,7 @@ export function createStickyNode(index: number, center?: { x: number; y: numberreturn {id: nextId('sticky'),type: 'sticky',- ...placeNode('sticky', center, index, STICKY_SIZE.width, STICKY_SIZE.height),+ ...placeSized('sticky', center, index),data: {title: 'Note',color: '#ffd60a',@@ -1316,13 +1357,14 @@ export function createStickyNode(index: number, center?: { x: number; y: number* invalid/absent spec schedules nothing and cannot be armed).*/export function createTriggerNode(index: number, center?: { x: number; y: number }): CanvasNode {+ const size = defaultNodeSize('trigger')return {id: nextId('trigger'),type: 'trigger',- position: placeAt(center, index, TRIGGER_SIZE.width, TRIGGER_SIZE.height),- width: TRIGGER_SIZE.width,- height: TRIGGER_SIZE.height,- style: { width: TRIGGER_SIZE.width, height: TRIGGER_SIZE.height },+ position: placeAt(center, index, size.width, size.height),+ width: size.width,+ height: size.height,+ style: { width: size.width, height: size.height },data: {title: 'Trigger',color: '#e6a23c',@@ -1340,7 +1382,7 @@ export function createDinoNode(return {id: nextId('dino'),type: 'dino',- ...placeNode('dino', center, index, DINO_SIZE.width, DINO_SIZE.height),+ ...placeSized('dino', center, index),data: {title: 'Dino',color: '#a2a2a2',diff --git a/src/server/headless-node-factory.test.ts b/src/server/headless-node-factory.test.tsindex a581ccc88..13578f5b1 100644--- a/src/server/headless-node-factory.test.ts+++ b/src/server/headless-node-factory.test.ts@@ -35,6 +35,7 @@ import {type HeadlessPty,type HeadlessWorkspace} from './headless-node-factory'+import { STICKY_NODE_MIN_SIZE, STICKY_NODE_SIZE } from '../shared/default-node-size'class FakePty implements HeadlessPty {readonly creates: PtyCreateOptions[] = []@@ -177,13 +178,17 @@ describe('HeadlessNodeFactory', () => {/** Stations with unfinished handed-over work (core/station-handover.ts), as the tracker answers. */let handedOver: Set<string>+ /** Per-test settings on top of the defaults; reset before each test. */+ let settingsOverride: Partial<Settings> = {}const settings = (): Settings => ({...DEFAULT_SETTINGS,// Makes command expectations independent of the local Claude version probe.- claudePermissionMode: 'manual'+ claudePermissionMode: 'manual',+ ...settingsOverride})beforeEach(async () => {+ settingsOverride = {}dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nodeterm-headless-factory-'))projectDir = path.join(dataDir, 'project')fs.mkdirSync(projectDir, { recursive: true })@@ -1576,6 +1581,20 @@ describe('HeadlessNodeFactory', () => {expect(published.filter((node) => node.id === id)).toHaveLength(2)})+ it('creates a sticky at the per-kind default size, clamped like the renderer', async () => {+ const sizeOf = async (ref: string): Promise<unknown> => {+ const reply = await factory.sticky('term-source', { node: ref, create: 'yes', text: 'x' })+ const id = (reply.result as { id: string }).id+ const workspace = await store.load({ sideline: false })+ return workspace.projects[0].nodes.find((node) => node.id === id)?.size+ }+ expect(await sizeOf('Built-in')).toEqual(STICKY_NODE_SIZE)+ settingsOverride = { defaultNodeSizes: { sticky: { width: 400, height: 320 } } }+ expect(await sizeOf('Configured')).toEqual({ width: 400, height: 320 })+ settingsOverride = { defaultNodeSizes: { sticky: { width: 1, height: 99999 } } }+ expect(await sizeOf('Clamped')).toEqual({ width: STICKY_NODE_MIN_SIZE.width, height: 1600 })+ })+it('refuses a non-v1 agent before a node or PTY is created', async () => {const reply = await factory.openAgent('term-source', { agent: 'grok' }, true)expect(reply).toMatchObject({ ok: false, error: expect.stringContaining('claude|codex|gemini') })diff --git a/src/server/headless-node-factory.ts b/src/server/headless-node-factory.tsindex 99f1eb222..098f338e0 100644--- a/src/server/headless-node-factory.ts+++ b/src/server/headless-node-factory.ts@@ -68,6 +68,7 @@ import type {Settings,Workspace} from '../shared/types'+import { STICKY_NODE_MIN_SIZE, STICKY_NODE_SIZE, resolveDefaultNodeSize } from '../shared/default-node-size'export interface ServerControlReply {ok: boolean@@ -234,7 +235,6 @@ const AGENT_LIMIT = 5const TERMINAL_COLS = 120const TERMINAL_ROWS = 36const TERMINAL_SIZE = { width: 640, height: 440 }-const STICKY_SIZE = { width: 240, height: 200 }const H_GAP = 80const V_GAP = 36const GROUP_PAD = 28@@ -1802,11 +1802,16 @@ export class HeadlessNodeFactory {if ('id' in resolved) node = source.project.nodes.find((candidate) => candidate.id === resolved.id)else if (parsed.create) {created = true+ const stickySize = resolveDefaultNodeSize(+ this.deps.settings().defaultNodeSizes?.sticky,+ STICKY_NODE_SIZE,+ STICKY_NODE_MIN_SIZE+ )node = {id: nextId('sticky'),kind: 'sticky',- position: placeRight(source.project, source.node, STICKY_SIZE),- size: { ...STICKY_SIZE },+ position: placeRight(source.project, source.node, stickySize),+ size: stickySize,title: oneLine(parsed.ref) || 'Note',color: '#ffd60a',group: null,diff --git a/src/shared/default-node-size.test.ts b/src/shared/default-node-size.test.tsnew file mode 100644index 000000000..647002da2--- /dev/null+++ b/src/shared/default-node-size.test.ts@@ -0,0 +1,58 @@+import { describe, expect, it } from 'vitest'+import {+ NODE_SIZE_MAX,+ SIZABLE_NODE_KINDS,+ resolveDefaultNodeSize,+ type SizableNodeKind+} from './default-node-size'++const BUILTIN = { width: 240, height: 200 }+const MIN = { width: 160, height: 120 }++describe('resolveDefaultNodeSize', () => {+ it('answers the built-in size when the user never set one', () => {+ expect(resolveDefaultNodeSize(undefined, BUILTIN, MIN)).toEqual(BUILTIN)+ expect(resolveDefaultNodeSize({}, BUILTIN, MIN)).toEqual(BUILTIN)+ })++ it('answers the stored size, rounded', () => {+ expect(resolveDefaultNodeSize({ width: 401.4, height: 299.6 }, BUILTIN, MIN)).toEqual({+ width: 401,+ height: 300+ })+ })++ it('clamps to the kind minimum, so a hand-edited 0×0 never makes an ungrabbable node', () => {+ expect(resolveDefaultNodeSize({ width: 0, height: -5 }, BUILTIN, MIN)).toEqual(MIN)+ })++ it('clamps to the canvas maximum', () => {+ expect(resolveDefaultNodeSize({ width: 99999, height: 99999 }, BUILTIN, MIN)).toEqual(NODE_SIZE_MAX)+ })++ it('falls back per axis on garbage, keeping the half that is valid', () => {+ expect(resolveDefaultNodeSize({ width: 'wide', height: 300 }, BUILTIN, MIN)).toEqual({+ width: BUILTIN.width,+ height: 300+ })+ expect(resolveDefaultNodeSize({ width: 500, height: Number.NaN }, BUILTIN, MIN)).toEqual({+ width: 500,+ height: BUILTIN.height+ })+ expect(resolveDefaultNodeSize('600x400', BUILTIN, MIN)).toEqual(BUILTIN)+ expect(resolveDefaultNodeSize(null, BUILTIN, MIN)).toEqual(BUILTIN)+ })+})++describe('SIZABLE_NODE_KINDS', () => {+ it('excludes the kinds whose size is not a user default', () => {+ // terminal/agent keep their own long-standing defaultNodeWidth/Height pair; group frames are+ // sized to what they hold; subagent/loop cards are ephemeral and laid out by the canvas.+ const excluded = ['terminal', 'group', 'subagent', 'loop']+ for (const k of excluded) expect(SIZABLE_NODE_KINDS).not.toContain(k as SizableNodeKind)+ })++ it('lists each kind once', () => {+ expect(new Set(SIZABLE_NODE_KINDS).size).toBe(SIZABLE_NODE_KINDS.length)+ })+})diff --git a/src/shared/default-node-size.ts b/src/shared/default-node-size.tsnew file mode 100644index 000000000..62ed95d44--- /dev/null+++ b/src/shared/default-node-size.ts@@ -0,0 +1,85 @@+// Per-kind default sizes for NEW canvas nodes (Settings → Behavior → Default node size).+//+// Terminal and agent nodes keep their own long-standing `defaultNodeWidth`/`defaultNodeHeight`+// pair; this covers every other kind the add menus create. Group frames are sized to what they+// hold, and subagent/loop cards are ephemeral and laid out by the canvas, so none of those has a+// user default. Existing nodes always keep the size they were saved with.+//+// Machine-local and hand-editable, so every reader goes through `resolveDefaultNodeSize`.++import type { NodeKind } from './types'++export type SizableNodeKind = Extract<+ NodeKind,+ 'sticky' | 'editor' | 'diff' | 'video' | 'web' | 'browser' | 'files' | 'dino' | 'trigger' | 'simulator'+>++/** In the order the Settings picker lists them. */+export const SIZABLE_NODE_KINDS: readonly SizableNodeKind[] = [+ 'sticky',+ 'browser',+ 'web',+ 'editor',+ 'diff',+ 'files',+ 'video',+ 'simulator',+ 'trigger',+ 'dino'+]++export interface NodeSize {+ width: number+ height: number+}++/** The same ceiling as the terminal setting (`terminalNodeSize`): bigger than any display, small+ * enough that a typo can't make a node you have to zoom out to find. */+export const NODE_SIZE_MAX: NodeSize = { width: 2400, height: 1600 }++/** The floor of the terminal/agent pair (`defaultNodeWidth`/`defaultNodeHeight`): what+ * `terminalNodeSize` clamps to, and the bounds the Settings field and the settings verb offer. */+export const TERMINAL_NODE_SIZE_MIN: NodeSize = { width: 280, height: 160 }++/** A sticky note's built-in size and resizer minimum. Shared because the Server Edition creates+ * stickies too (`headless-node-factory`), and two copies would drift. */+export const STICKY_NODE_SIZE: NodeSize = { width: 240, height: 200 }+export const STICKY_NODE_MIN_SIZE: NodeSize = { width: 160, height: 120 }++/**+ * The stored entry for a kind as the Settings field should SHOW it: the user's own numbers, per+ * axis, unclamped (clamping while typing would turn the "3" of "300" into the minimum before the+ * rest arrives); the built-in value for an axis that is absent or not a finite number. Nodes are+ * still created through `resolveDefaultNodeSize`, which does clamp.+ */+export function storedDefaultNodeSize(stored: unknown, builtin: NodeSize): NodeSize {+ const entry = typeof stored === 'object' && stored !== null ? (stored as Partial<Record<keyof NodeSize, unknown>>) : {}+ const axis = (v: unknown, fallback: number): number => (typeof v === 'number' && Number.isFinite(v) ? v : fallback)+ return { width: axis(entry.width, builtin.width), height: axis(entry.height, builtin.height) }+}++/** `defaultNodeSizes` as read from settings.json, or `{}` when a hand edit made it anything but a+ * plain object — so a write never spreads a string or array into index keys. */+export function defaultNodeSizesRecord(value: unknown): Partial<Record<SizableNodeKind, NodeSize>> {+ return typeof value === 'object' && value !== null && !Array.isArray(value)+ ? (value as Partial<Record<SizableNodeKind, NodeSize>>)+ : {}+}++/**+ * The size a new node of some kind opens at. `stored` is the user's entry for that kind (absent+ * when they never set one); `builtin` is the kind's shipped default; `min` is the smallest size+ * its resizer allows. Each axis is resolved on its own, so a half-valid hand edit keeps the+ * valid half; anything not a finite number falls back to the built-in value.+ */+export function resolveDefaultNodeSize(stored: unknown, builtin: NodeSize, min: NodeSize): NodeSize {+ const entry = typeof stored === 'object' && stored !== null ? (stored as Partial<Record<keyof NodeSize, unknown>>) : {}+ const axis = (v: unknown, fallback: number, lo: number, hi: number): number => {+ const n = typeof v === 'number' && Number.isFinite(v) ? Math.round(v) : fallback+ return Math.min(hi, Math.max(lo, n))+ }+ return {+ width: axis(entry.width, builtin.width, min.width, NODE_SIZE_MAX.width),+ height: axis(entry.height, builtin.height, min.height, NODE_SIZE_MAX.height)+ }+}diff --git a/src/shared/types.ts b/src/shared/types.tsindex 6a610a2d6..a5a135630 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -4,6 +4,7 @@ import type { IdentitySeedEntry } from './agent-identity-seed'import type { PrWaitHold } from './pr-wait'import type { SessionBackend } from './session-backend'import type { AgentIntegrationsSettings } from './agent-integrations'+import type { NodeSize, SizableNodeKind } from './default-node-size'// Types shared across the main, preload, and renderer processes.import { TABBAR_HEIGHT_PX } from './window-chrome-metrics'@@ -1939,6 +1940,10 @@ export interface Settings {* whatever size they were saved with; other node kinds keep their own defaults. */defaultNodeWidth: numberdefaultNodeHeight: number+ /** Default size (px) for NEW nodes of every other kind the add menus create, keyed by kind; a+ * kind with no entry opens at its built-in size. Read through `defaultNodeSize` (renderer) /+ * `resolveDefaultNodeSize` (@shared/default-node-size), which clamp hand edits. Machine-local. */+ defaultNodeSizes: Partial<Record<SizableNodeKind, NodeSize>>/** Sessions sidebar: the DEFAULT for a project row the user never toggled — on (historical)* keeps the active project expanded and collapses the others, off leaves everything expanded.* Explicit toggles live in `sidebarCollapsedItems` and always win. */@@ -2448,6 +2453,7 @@ export const DEFAULT_SETTINGS: Settings = {markdownFontSize: DEFAULT_MARKDOWN_FONT_SIZE,defaultNodeWidth: 640,defaultNodeHeight: 440,+ defaultNodeSizes: {},sidebarAutoCollapse: true,sidebarCollapsedItems: {},sidebarGrouping: 'project',