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.

Merge origin/main into feat/915-terminal-font-zoom

reviewab545ff6db0d
diff --cc src/renderer/components/ShortcutsPanel.tsx
index 003ee0d58,30a929747..64e0b5090
--- a/src/renderer/components/ShortcutsPanel.tsx
+++ b/src/renderer/components/ShortcutsPanel.tsx
@@@ -81,10 -83,11 +83,13 @@@ export interface ShortcutSectionsOption
doubleClickFocus: boolean
/** `settings.wheelZoom` — a plain wheel zooms too. */
wheelZoom: boolean
+ /** `settings.terminalFocusFollowsPointer` (issue #757). Off = click to focus: no hover dwell
+ * ever takes the keyboard, so the dwell row would advertise a gesture that does nothing. */
+ focusFollowsPointer: boolean
/** Canonical effective binding strings for a command; `[]` when unbound or disabled. */
bindingsFor: (id: CommandId) => readonly string[]
+ /** `settings.terminalFontZoomKeys` (issue #915). Optional: absent = off, the shipped default. */
+ terminalFontZoomKeys?: boolean
}
/** The section order IS the registry's group order (first appearance), so a new `CommandGroup`
@@@ -224,7 -223,9 +234,10 @@@ export function ShortcutsPanel({ onClos
const dragMode = useSettings((s) => s.settings.canvasDragMode)
const doubleClickFocus = useSettings((s) => s.settings.doubleClickFocus)
const wheelZoom = useSettings((s) => s.settings.wheelZoom)
+ const terminalFontZoomKeys = useSettings((s) => s.settings.terminalFontZoomKeys)
+ const focusFollowsPointer = resolveFocusFollowsPointer(
+ useSettings((s) => s.settings.terminalFocusFollowsPointer)
+ )
const isMac = isMacPlatform()
const sections = buildShortcutSections({
isMac,
@@@ -233,7 -234,7 +246,8 @@@
dragMode: dragMode === 'pan' ? 'pan' : 'select',
doubleClickFocus,
wheelZoom,
+ terminalFontZoomKeys,
+ focusFollowsPointer,
bindingsFor: effectiveBindings
})
diff --cc src/renderer/terminal/terminal-font-zoom.wiring.test.ts
index 456a90a2a,000000000..b53332c3b
mode 100644,000000..100644
--- a/src/renderer/terminal/terminal-font-zoom.wiring.test.ts
+++ b/src/renderer/terminal/terminal-font-zoom.wiring.test.ts
@@@ -1,169 -1,0 +1,170 @@@
+import fs from 'fs'
+import path from 'path'
+import { describe, expect, it } from 'vitest'
+import { flowToNodeStates, nodeStatesToFlow, type CanvasNode } from '../state/workspace'
+import { toKanbanSessionState } from '../canvas/toKanbanSessionState'
+import { toKanbanSession } from '../canvas/toKanbanSession'
+import { DEFAULT_SETTINGS, type CanvasNodeState } from '@shared/types'
+import { buildShortcutSections, type ShortcutSectionsOptions } from '../components/ShortcutsPanel'
+
+// Issue #915 — per-terminal font size on ⌘+ / ⌘− / ⌘0. The pure decisions are pinned in
+// `terminal-font-zoom.test.ts`; this file pins that each surface actually ASKS them, and that the
+// override survives persistence. Source pins for the component wiring (the house style for
+// TerminalNode / Canvas, which cannot be mounted in a unit test).
+
+const read = (rel: string): string =>
+ fs.readFileSync(path.join(__dirname, rel), 'utf8').replace(/\r\n/g, '\n')
+const TERMINAL_NODE = read('../nodes/TerminalNode.tsx')
+const MODAL = read('../components/kanban/ModalTerminal.tsx')
+const PREVIEW = read('../components/settings/TerminalPreview.tsx')
+const HOOK = read('./useXtermVisualSettings.ts')
+const CANVAS = read('../canvas/Canvas.tsx')
+const TERMINAL_SECTION = read('../components/settings/sections/TerminalSection.tsx')
+
+const term = (data: Record<string, unknown> = {}): CanvasNode =>
+ ({
+ id: 't1',
+ type: 'terminal',
+ position: { x: 0, y: 0 },
+ width: 320,
+ height: 240,
+ style: { width: 320, height: 240 },
+ data: { title: 't1', color: '#fff', group: null, ...data }
+ }) as unknown as CanvasNode
+
+describe('terminal font zoom — settings', () => {
+ it('ships OFF, so ⌘+/⌘−/⌘0 keep today’s behaviour until the user opts in', () => {
+ expect(DEFAULT_SETTINGS.terminalFontZoomKeys).toBe(false)
+ })
+ it('is a Switch in Settings → Terminal, and the size field uses the shared bounds', () => {
+ expect(TERMINAL_SECTION).toContain('terminalFontZoomKeys')
+ expect(TERMINAL_SECTION).toContain('min={TERMINAL_FONT_SIZE_MIN}')
+ expect(TERMINAL_SECTION).toContain('max={TERMINAL_FONT_SIZE_MAX}')
+ })
+})
+
+describe('terminal font zoom — persistence', () => {
+ it('survives the flow → state → flow round trip', () => {
+ const states = flowToNodeStates([term({ terminalFontSize: 17 })])
+ expect(states[0].terminalFontSize).toBe(17)
+ expect(nodeStatesToFlow(states)[0].data.terminalFontSize).toBe(17)
+ })
+ it('drops a garbage hand-edited value on the way in and on the way out', () => {
+ const inState = { ...flowToNodeStates([term()])[0], terminalFontSize: 400 } as CanvasNodeState
+ expect(nodeStatesToFlow([inState])[0].data.terminalFontSize).toBeUndefined()
+ expect(flowToNodeStates([term({ terminalFontSize: 'big' })])[0].terminalFontSize).toBeUndefined()
+ })
+ it('an unset override stays absent (no key churn in project.json)', () => {
+ expect(flowToNodeStates([term()])[0].terminalFontSize).toBeUndefined()
+ })
+})
+
+describe('terminal font zoom — the card modal follows the node', () => {
+ it('carries the override in the modal spawn from live nodes and from persisted state', () => {
+ expect(toKanbanSession(term({ terminalFontSize: 15 }))?.spawn.terminalFontSize).toBe(15)
+ const state = flowToNodeStates([term({ terminalFontSize: 15 })])[0]
+ expect(toKanbanSessionState(state)?.spawn.terminalFontSize).toBe(15)
+ })
+})
+
+describe('terminal font zoom — one options path', () => {
+ it('the visual-settings hook layers the override through withTerminalFontSize', () => {
+ expect(HOOK).toContain('withTerminalFontSize(')
+ expect(HOOK).toMatch(/useXtermVisualSettings\(\s*projectId\?: string,\s*fontSizeOverride\?: unknown/)
+ })
+ it('the canvas node and the modal pass the node override; the settings preview does not', () => {
+ expect(TERMINAL_NODE).toContain('useXtermVisualSettings(owningProjectId(), data.terminalFontSize)')
+ expect(MODAL).toContain('useXtermVisualSettings(owningProjectId(), spawn.terminalFontSize)')
+ expect(PREVIEW).toContain('useXtermVisualSettings()')
+ })
+})
+
+describe('terminal font zoom — every new xterm is built from the EFFECTIVE visual (review round 2)', () => {
+ // A refresh (respawnNonce) or an offscreen-release revive recreates the xterm inside the same
+ // mount, where the [visual, glass] live-options effect does NOT re-run — so the instance must be
+ // born with the node's override (and the project's theme/font), never the bare global settings.
+ for (const [name, src] of [
+ ['TerminalNode', TERMINAL_NODE],
+ ['ModalTerminal', MODAL]
+ ] as const) {
+ it(`${name}: new Terminal(...) reads visualRef.current, mirrored every render`, () => {
+ const ctor = src.slice(src.indexOf('new Terminal(xtermOptionsFromSettings('))
+ expect(ctor.slice(0, ctor.indexOf('\n'))).toContain('xtermOptionsFromSettings(visualRef.current,')
+ expect(src).toContain('visualRef.current = visual')
+ })
+ }
+})
+
+describe('terminal font zoom — key wiring', () => {
+ for (const [name, src] of [
+ ['TerminalNode', TERMINAL_NODE],
+ ['ModalTerminal', MODAL]
+ ] as const) {
+ it(`${name}: its xterm key handler asks the decision and hands the step to Canvas`, () => {
+ const start = src.indexOf('term.attachCustomKeyEventHandler(')
+ const handler = src.slice(start, src.indexOf('\n })', start))
+ expect(handler).toContain('terminalFontZoomAction(e,')
+ expect(handler).toContain('requestTerminalFontZoom(')
+ // Swallowed: xterm must not also write ^_ for Ctrl+− off-mac.
+ expect(handler).toMatch(/requestTerminalFontZoom\([^)]*\)[\s\S]{0,80}return false/)
+ })
+ it(`${name}: stamps the xterm host with the node id for the desktop ⌘0 route`, () => {
+ expect(src).toContain('[FONT_ZOOM_NODE_ATTR]:')
+ })
+ }
+
+ it('Canvas is the single writer: event → nextTerminalFontSizeOverride → markDirty', () => {
+ const start = CANVAS.indexOf('TERMINAL_FONT_ZOOM_EVENT, onFontZoom')
+ expect(start).toBeGreaterThan(-1)
+ const body = CANVAS.slice(CANVAS.lastIndexOf('useEffect(', start), start)
+ expect(body).toContain('nextTerminalFontSizeOverride(')
+ expect(body).toContain('markDirty()')
+ })
+
+ it('mirrors the step into the projects store so the Omni board (which reads it) updates live', () => {
+ const start = CANVAS.indexOf('TERMINAL_FONT_ZOOM_EVENT, onFontZoom')
+ const body = CANVAS.slice(CANVAS.lastIndexOf('useEffect(', start), start)
+ expect(body).toContain('patchProjectFontSize(')
+ // Same epoch guard commitActiveToStore uses: never patch another project's stored nodes.
+ expect(body).toContain('canCommitCanvas(nodesProjectIdRef.current,')
+ })
+
+ it('the forwarded desktop ⌘0 resets a focused terminal BEFORE falling back to canvas zoom', () => {
+ const start = CANVAS.indexOf('window.nodeTerminal.onZoomActualSize(')
+ const body = CANVAS.slice(start, CANVAS.indexOf('})', start))
+ const reset = body.indexOf("requestTerminalFontZoom(target, 'reset')")
+ expect(reset).toBeGreaterThan(-1)
+ expect(reset).toBeLessThan(body.indexOf('zoomTo100()'))
+ expect(body).toContain('fontZoomTargetNodeId(')
+ // Review of #915: the reset asks the platform predicate over the FORWARDED modifiers, so a mac
+ // Ctrl+0 keeps its old meaning (canvas zoom when allowed) instead of clearing the override.
+ expect(body).toContain('forwardedResetMatches(mods,')
+ })
+
+ it('a node whose font leaves the shared glyph atlas paints its own pixels (glyphOff)', () => {
+ const line = TERMINAL_NODE.slice(TERMINAL_NODE.indexOf('const glyphOff ='))
+ const decl = line.slice(0, line.indexOf('\n'))
+ expect(decl).toContain('fontLeavesAtlas')
+ expect(TERMINAL_NODE).toMatch(/const fontLeavesAtlas = leavesSharedGlyphAtlas\(visual\.fontSize,/)
+ })
+})
+
+describe('terminal font zoom — shortcuts panel', () => {
+ const BASE: ShortcutSectionsOptions = {
+ isMac: true,
+ browser: false,
+ panHoverDelay: 500,
+ dragMode: 'select',
+ doubleClickFocus: false,
++ focusFollowsPointer: true,
+ wheelZoom: false,
+ bindingsFor: () => []
+ }
+ const labels = (o: Partial<ShortcutSectionsOptions>): string[] =>
+ buildShortcutSections({ ...BASE, ...o }).flatMap((s) => s.rows.map((r) => r.label))
+ it('advertises the terminal font rows only when the setting is on', () => {
+ expect(labels({})).not.toContain('Terminal font size bigger / smaller')
+ expect(labels({ terminalFontZoomKeys: true })).toContain('Terminal font size bigger / smaller')
+ expect(labels({ terminalFontZoomKeys: true })).toContain('Terminal font size back to the global size')
+ })
+})
diff --cc src/shared/types.ts
index 557d3e264,0cb022934..289dc948b
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@@ -1886,13 -1881,17 +1893,24 @@@ export interface Settings
* terminal. Logic: `renderer/terminal/copy-on-select.ts`.
*/
copyOnSelect: boolean
+ /** ⌘+ / ⌘− / ⌘0 (Ctrl off-mac) change the FOCUSED terminal's own font size instead of doing
+ * nothing / zooming the canvas (issue #915). The size is stored per node
+ * (`CanvasNodeState.terminalFontSize`); ⌘0 clears it back to `fontSize`. OFF by default: off-mac
+ * the chord is Ctrl+−, which a focused terminal passes to the shell today (readline undo). With
+ * it off, and whenever no terminal has focus, the keys behave exactly as before. See
+ * renderer/terminal/terminal-font-zoom.ts. */
+ terminalFontZoomKeys: boolean
+ /**
+ * Windows SSH projects: after a key is unlocked with its passphrase, also load it into the
+ * Windows OpenSSH agent service, so later connections (and the user's own `ssh`) do not prompt
+ * again. OFF by default because that agent STORES the key — DPAPI-encrypted in
+ * `HKCU\Software\OpenSSH\Agent\Keys`, surviving service restarts — until it is removed
+ * (`ssh-add -d` / `-D`), and it refuses a lifetime constraint (measured on windows-latest,
+ * OpenSSH_for_Windows_9.5p2), so there is no "for this session only". A host whose own
+ * `~/.ssh/config` says `AddKeysToAgent yes` gets the add without this switch: that user already
+ * asked OpenSSH for exactly this. Logic: `core/remote-ssh/native/agent-add.ts`.
+ */
+ windowsSshAgentAddKeys: boolean
/** Plain mouse wheel zooms the canvas (no Cmd/Ctrl needed). On macOS a two-finger trackpad
* scroll keeps panning independently (see canvas/wheel-gesture.ts), so mouse and trackpad
* coexist; elsewhere this still trades away scroll-to-pan, so it stays opt-in. */
@@@ -2264,7 -2264,7 +2283,8 @@@ export const DEFAULT_SETTINGS: Setting
openMarkdownPreviewMigrated: true,
terminalMiddleClickPaste: false,
copyOnSelect: false,
+ terminalFontZoomKeys: false,
+ windowsSshAgentAddKeys: false,
wheelZoom: false,
wheelZoomSpeed: 1,
trackpadPan: true,