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: per-terminal font size on Cmd+/Cmd-/Cmd+0 (#915)

Erik Zwep53ce4875260e
diff --git a/CLAUDE.md b/CLAUDE.md
index 1afe0b497..057e4391b 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -6484,6 +6484,22 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord mea
`main/index.ts` intercepts it in `before-input-event` and forwards `app:zoom-actual-size`, which
re-asks the same refusals. Server Edition needs no intercept (no menu; Chrome/Firefox hand ⌘0 to
the page) and stubs the subscription.
+- **Per-terminal font size** (`renderer/terminal/terminal-font-zoom.ts`, issue #915). Opt-in
+ `settings.terminalFontZoomKeys` (Settings → Terminal, default OFF). On, with a terminal focused:
+ ⌘+ / ⌘− (Ctrl off-mac — exactly one primary, since Ctrl+− on mac is readline undo) step THAT
+ node's `data.terminalFontSize` by 1 within the global field's 8–28 range; ⌘0 clears it back to the
+ global `fontSize`. + and − match on `e.key` (German `+` key), 0 on `e.code` like the canvas chord.
+ Before #915 ⌘+ / ⌘− did NOTHING (no menu zoom roles, React Flow's key zoom is off; only
+ webview guests zoom on them) and ⌘0 in a terminal was claimed by main and then refused. Off, or
+ with no terminal focused, every key behaves as before. The override is persisted per node
+ (`normalizeTerminalFontSize` on both sides of `nodeStatesToFlow`/`flowToNodeStates`) and layered
+ by `useXtermVisualSettings(projectId, fontSizeOverride)` — the SAME path for the canvas node and
+ the card modal (`ModalSpawn.terminalFontSize`); the settings preview passes none. Font size is
+ cell geometry, so `applyLiveOptions` reports `metricsChanged` and both surfaces re-fit and report
+ the new grid exactly as for a global font change. **One writer:** both xterm key handlers and the
+ forwarded desktop ⌘0 (resolved from focus via `data-font-zoom-node` on the xterm host) dispatch
+ `nodeterm:terminal-font-zoom`; Canvas applies it (`nextTerminalFontSizeOverride`, `markDirty`).
+ The toolbar / dock +/− buttons stay CANVAS zoom (they have no focused terminal to act on).
- **"Go to node" (`goToNode` → `frameNode`)** — the one camera-travel path (notification click,
sessions sidebar, ⌘K jump, presence travel, minimap double-click, double-click focus).
**It computes the viewport itself and applies it with `setViewport`. It must never go through
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 72a50b0d8..f8c0adba7 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -254,6 +254,14 @@ import {
zoomShortcutAllowed,
zoomShortcutChord
} from '../lib/zoomShortcut'
+import {
+ TERMINAL_FONT_ZOOM_EVENT,
+ fontZoomTargetNodeId,
+ nextTerminalFontSizeOverride,
+ normalizeTerminalFontSize,
+ requestTerminalFontZoom,
+ type TerminalFontZoomRequest
+} from '../terminal/terminal-font-zoom'
import {
dispatchGlobalKeydown,
type GlobalKeyEvent,
@@ -9569,12 +9577,50 @@ export function Canvas() {
// the same module rather than re-derived. Server Edition has no menu and no intercept: there the
// keydown branch above is the whole path (the browser's own ⌘0 means the same thing, so the two
// agree rather than fight, and the bridge stubs this subscription out).
+ //
+ // Issue #915: with `terminalFontZoomKeys` on and a terminal focused, the same forwarded ⌘0 means
+ // "this terminal back to the global font size" instead. Asked FIRST — `zoomShortcutAllowed`
+ // refuses in a terminal anyway (text focus), so this is the only thing ⌘0 can mean there — and
+ // resolved from focus, because the forwarded signal names no node (FONT_ZOOM_NODE_ATTR is on
+ // both the canvas node's and the card modal's xterm host).
useEffect(() => {
return window.nodeTerminal.onZoomActualSize(() => {
+ const target = useSettings.getState().settings.terminalFontZoomKeys
+ ? fontZoomTargetNodeId(typeof document === 'undefined' ? null : document.activeElement)
+ : null
+ if (target) {
+ requestTerminalFontZoom(target, 'reset')
+ return
+ }
if (zoomShortcutAllowed(liveZoomShortcutContext())) zoomTo100()
})
}, [zoomTo100])
+ // Per-terminal font size (issue #915): the ONE writer of `data.terminalFontSize`. Every entry
+ // point — the canvas terminal's and the card modal's xterm key handlers, and the forwarded ⌘0
+ // above — dispatches TERMINAL_FONT_ZOOM_EVENT, so the read-modify-write, the clamp and the
+ // persist happen here once. The node's live re-option effect (and the modal's) then sees the new
+ // size through `useXtermVisualSettings`, re-fits and reports the new grid to the pty. Read from
+ // `nodesRef` so the no-op case (already at a bound, reset with no override) costs no save. A
+ // node that is not on THIS canvas (a global-board card of another project) is left alone.
+ useEffect(() => {
+ const onFontZoom = (e: Event): void => {
+ const d = (e as CustomEvent<TerminalFontZoomRequest>).detail
+ if (!d?.nodeId) return
+ const node = nodesRef.current.find((n) => n.id === d.nodeId)
+ if (!node || node.type !== 'terminal') return
+ const prev = normalizeTerminalFontSize(node.data.terminalFontSize)
+ const next = nextTerminalFontSizeOverride(d.action, prev, useSettings.getState().settings.fontSize)
+ if (next === prev) return
+ setNodes((ns) =>
+ ns.map((n) => (n.id === d.nodeId ? { ...n, data: { ...n.data, terminalFontSize: next } } : n))
+ )
+ markDirty()
+ }
+ window.addEventListener(TERMINAL_FONT_ZOOM_EVENT, onFontZoom)
+ return () => window.removeEventListener(TERMINAL_FONT_ZOOM_EVENT, onFontZoom)
+ }, [setNodes, markDirty, nodesRef])
+
// Apply the accent color as a CSS variable.
useEffect(() => {
document.documentElement.style.setProperty('--accent', settings.accent)
diff --git a/src/renderer/canvas/toKanbanSession.ts b/src/renderer/canvas/toKanbanSession.ts
index 44bd689f8..979385815 100644
--- a/src/renderer/canvas/toKanbanSession.ts
+++ b/src/renderer/canvas/toKanbanSession.ts
@@ -59,7 +59,8 @@ export function toKanbanSession(n: CanvasNode): KanbanSession | null {
agentId: n.data.agentId as string | undefined,
accountId: n.data.accountId as string | undefined,
ssh: n.data.ssh as SshConnection | undefined,
- sshRemoteTmux: !!n.data.sshRemoteTmux
+ sshRemoteTmux: !!n.data.sshRemoteTmux,
+ terminalFontSize: n.data.terminalFontSize as number | undefined
}
}
}
diff --git a/src/renderer/canvas/toKanbanSessionState.ts b/src/renderer/canvas/toKanbanSessionState.ts
index 564321233..a7aef2d93 100644
--- a/src/renderer/canvas/toKanbanSessionState.ts
+++ b/src/renderer/canvas/toKanbanSessionState.ts
@@ -52,7 +52,8 @@ export function toKanbanSessionState(n: CanvasNodeState): KanbanSession | null {
agentId: n.agentId,
accountId: n.accountId,
ssh: n.ssh,
- sshRemoteTmux: !!n.sshRemoteTmux
+ sshRemoteTmux: !!n.sshRemoteTmux,
+ terminalFontSize: n.terminalFontSize
}
return {
id: n.id,
diff --git a/src/renderer/components/ShortcutsPanel.tsx b/src/renderer/components/ShortcutsPanel.tsx
index f3c5605b8..003ee0d58 100644
--- a/src/renderer/components/ShortcutsPanel.tsx
+++ b/src/renderer/components/ShortcutsPanel.tsx
@@ -83,6 +83,8 @@ export interface ShortcutSectionsOptions {
wheelZoom: 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`
@@ -160,7 +162,16 @@ function behaviorRows(o: ShortcutSectionsOptions): ShortcutRow[] {
row([forceSelect, 'drag'], 'Select in the emulator (apps that grab the mouse)'),
row(['⇧', 'Enter'], 'Insert a newline instead of submitting'),
row(['⌘', 'click'], 'Open a link, file or folder from the output'),
- row(['✦'], 'Name the terminal with AI')
+ row(['✦'], 'Name the terminal with AI'),
+ // Opt-in (issue #915), so only listed when on. Spelled per platform rather than with the
+ // panel's usual ⌘ glyph: this chord is deliberately ⌘ on mac and Ctrl elsewhere, never either
+ // (terminal-font-zoom.ts), and advertising ⌘ off-mac would name a key that does nothing.
+ ...(o.terminalFontZoomKeys
+ ? [
+ row([o.isMac ? '⌘' : 'Ctrl', '+ / −'], 'Terminal font size bigger / smaller'),
+ row([o.isMac ? '⌘' : 'Ctrl', '0'], 'Terminal font size back to the global size')
+ ]
+ : [])
]
}
@@ -213,6 +224,7 @@ export function ShortcutsPanel({ onClose, onCustomize }: ShortcutsPanelProps) {
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 isMac = isMacPlatform()
const sections = buildShortcutSections({
isMac,
@@ -221,6 +233,7 @@ export function ShortcutsPanel({ onClose, onCustomize }: ShortcutsPanelProps) {
dragMode: dragMode === 'pan' ? 'pan' : 'select',
doubleClickFocus,
wheelZoom,
+ terminalFontZoomKeys,
bindingsFor: effectiveBindings
})
diff --git a/src/renderer/components/kanban/ModalTerminal.tsx b/src/renderer/components/kanban/ModalTerminal.tsx
index e4d56a036..8035f96b9 100644
--- a/src/renderer/components/kanban/ModalTerminal.tsx
+++ b/src/renderer/components/kanban/ModalTerminal.tsx
@@ -21,6 +21,12 @@ import { useProjects } from '../../state/projects'
import { useSession } from '../../session/session'
import { isHostedReadOnly } from '../../state/hostedTeams'
import { useSettings } from '../../state/settings'
+import { isMacPlatform } from '@shared/platform-utils'
+import {
+ FONT_ZOOM_NODE_ATTR,
+ requestTerminalFontZoom,
+ terminalFontZoomAction
+} from '../../terminal/terminal-font-zoom'
import { useTerminalSearch } from '../../terminal/useTerminalSearch'
import { useTerminalGlass } from '../../lib/useTerminalGlass'
import { LocalTransport } from '../../terminal/local-transport'
@@ -78,6 +84,10 @@ export interface ModalSpawn {
sshRemoteTmux?: boolean
/** One-shot launch command for a fresh session (agent CLIs). */
initialCommand?: string
+ /** The node's own font size (issue #915, `data.terminalFontSize`). The modal is a second view of
+ * the SAME session, so it renders at the node's size, not the global one — and, being a
+ * co-attach subscriber, re-reports its grid when that changes like any font change. */
+ terminalFontSize?: number
}
/**
@@ -147,7 +157,8 @@ export function ModalTerminal({ nodeId, spawn, searchOpen, onCloseSearch, covere
// only ever opens over it), deliberately NOT this card's connection scope. `sshConnectionScope`
// answers a project×host attachment id for a session on a foreign host, which names no project at
// all — the per-project appearance would silently vanish for exactly those cards.
- const visual = useXtermVisualSettings(owningProjectId())
+ // …and the NODE's own font size (issue #915), so this second view matches the canvas one.
+ const visual = useXtermVisualSettings(owningProjectId(), spawn.terminalFontSize)
// Liquid Glass: the same glass as the canvas node (a second view of one session must look like
// it). The DOM renderer keeps app-painted cell backgrounds opaque (see CLAUDE.md).
const { glass, vars: glassVars } = useTerminalGlass(visual.terminalTheme)
@@ -311,6 +322,17 @@ export function ModalTerminal({ nodeId, spawn, searchOpen, onCloseSearch, covere
// digit addressing an open project, AND app-first: under terminal-first the digit belongs to
// the PTY), which `liveProjectJumpTarget` + the policy decide for both surfaces.
term.attachCustomKeyEventHandler((e) => {
+ // MIRROR TerminalNode: ⌘+ / ⌘− / ⌘0 step the NODE's own font size (issue #915) when opted
+ // in. The modal renders `spawn.terminalFontSize`, so the step lands on both views at once.
+ const fontZoom = terminalFontZoomAction(e, {
+ enabled: useSettings.getState().settings.terminalFontZoomKeys,
+ isMac: isMacPlatform()
+ })
+ if (fontZoom) {
+ e.preventDefault()
+ requestTerminalFontZoom(nodeId, fontZoom)
+ return false
+ }
const ownsProjectJump =
terminalShortcutPolicy() !== 'terminal-first' && liveProjectJumpTarget(e) !== null
// MIRROR TerminalNode's registryOwns — but with `kanbanOpen: true` ALWAYS: the modal only
@@ -614,7 +636,7 @@ export function ModalTerminal({ nodeId, spawn, searchOpen, onCloseSearch, covere
onClose={onCloseSearch}
/>
)}
- <div ref={hostRef} className="kanban-modal__term" />
+ <div ref={hostRef} className="kanban-modal__term" {...{ [FONT_ZOOM_NODE_ATTR]: nodeId }} />
{linkMenu && (
<ContextMenu
x={linkMenu.x}
diff --git a/src/renderer/components/settings/sections/TerminalSection.tsx b/src/renderer/components/settings/sections/TerminalSection.tsx
index 972ca7178..e6254e427 100644
--- a/src/renderer/components/settings/sections/TerminalSection.tsx
+++ b/src/renderer/components/settings/sections/TerminalSection.tsx
@@ -12,6 +12,11 @@ import { NumberField } from '@renderer/ui/NumberField'
import { Input } from '@renderer/ui/Input'
import { SegmentedPill } from '@renderer/ui/SegmentedPill'
import { TERMINAL_RESET_KEYS } from '@renderer/lib/settingsReset'
+import { isMacPlatform } from '@shared/platform-utils'
+import {
+ TERMINAL_FONT_SIZE_MAX,
+ TERMINAL_FONT_SIZE_MIN
+} from '@renderer/terminal/terminal-font-zoom'
import {
TERMINAL_LETTER_SPACING_MAX,
TERMINAL_LETTER_SPACING_MIN,
@@ -45,6 +50,13 @@ const ROWS = {
title: 'Size and weight',
keywords: ['font', 'size', 'text', 'zoom', 'weight', 'bold', 'thin', 'light', 'heavy']
},
+ fontZoomKeys: {
+ title: 'Font size keys',
+ keywords: [
+ 'font', 'size', 'zoom', 'bigger', 'smaller', 'cmd', 'ctrl', 'plus', 'minus', 'shortcut',
+ 'per terminal'
+ ]
+ },
spacing: {
title: 'Spacing',
keywords: [
@@ -152,6 +164,9 @@ function GroupHeading({ children }: { children: React.ReactNode }): React.JSX.El
}
/** A secondary label between two controls sharing one row ("13 · bold 700"). */
+/** The primary modifier as the user reads it in the font-size-keys description. */
+const modKey = isMacPlatform() ? '⌘' : 'Ctrl'
+
function Sub({ children }: { children: React.ReactNode }): React.JSX.Element {
return <span className="text-[13px] text-muted">{children}</span>
}
@@ -203,8 +218,8 @@ export function TerminalSection({ isActive }: { isActive: boolean }): React.JSX.
<NumberField
className="w-16"
value={settings.fontSize}
- min={8}
- max={28}
+ min={TERMINAL_FONT_SIZE_MIN}
+ max={TERMINAL_FONT_SIZE_MAX}
onChange={(v) => update({ fontSize: v || 13 })}
/>
<Select
@@ -236,6 +251,21 @@ export function TerminalSection({ isActive }: { isActive: boolean }): React.JSX.
}
/>
</SearchableRow>
+ {/* Issue #915. Behaviour, not appearance: deliberately NOT in TERMINAL_RESET_KEYS (same as
+ middle-click paste), so the section's reset button does not flip a key binding. */}
+ <SearchableRow {...ROWS.fontZoomKeys}>
+ <FieldRow
+ label="Font size keys"
+ description={`${modKey}+ / ${modKey}− change the focused terminal's own font size; ${modKey}0 puts it back on the size above. Off: those keys do what they did before (${modKey}0 zooms the canvas to 100%).`}
+ control={
+ <Switch
+ checked={settings.terminalFontZoomKeys}
+ onChange={(v) => update({ terminalFontZoomKeys: v })}
+ ariaLabel="Font size keys"
+ />
+ }
+ />
+ </SearchableRow>
<SearchableRow {...ROWS.spacing}>
<FieldRow
label="Spacing"
diff --git a/src/renderer/lib/closedHistory.ts b/src/renderer/lib/closedHistory.ts
index 7316153fd..23bd4a38b 100644
--- a/src/renderer/lib/closedHistory.ts
+++ b/src/renderer/lib/closedHistory.ts
@@ -139,6 +139,7 @@ export function stateToReopenSnapshot(entry: ClosedSessionEntry): ReopenNodeSnap
hideFanout: n.hideFanout,
// Re-validated, not copied: this entry was read from hand-editable workspace.json.
icon: normalizeNodeIcon(n.icon),
+ terminalFontSize: n.terminalFontSize,
shell: n.shell,
cwd: n.cwd,
text: n.text,
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 0d2cc9590..cae895c4c 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -101,6 +101,11 @@ import {
type SessionLife
} from '../terminal/terminal-config'
import { useXtermVisualSettings } from '../terminal/useXtermVisualSettings'
+import {
+ FONT_ZOOM_NODE_ATTR,
+ requestTerminalFontZoom,
+ terminalFontZoomAction
+} from '../terminal/terminal-font-zoom'
import { ensureProjectLaunchInfo } from '../state/projectLaunchInfo'
import { loseWebglContexts, registerWebglClient, type WebglClientHandle } from '../terminal/webgl-budget'
import { quantizeCharSize } from '../terminal/char-size-quantize'
@@ -1349,7 +1354,9 @@ export function TerminalNode({
// One shallow-compared subscription for the whole appearance slice — see useXtermVisualSettings.
// Scoped to the OWNING project so its `terminal.theme` / `terminal.fontFamily` layer over the
// global settings for this node, and for no other project's nodes.
- const visual = useXtermVisualSettings(owningProjectId())
+ // `data.terminalFontSize` is this node's own ⌘+ / ⌘− size (issue #915), layered last by the hook
+ // so the card modal (which passes the same value) re-options through the identical path.
+ const visual = useXtermVisualSettings(owningProjectId(), data.terminalFontSize)
// Glass terminals (Settings → Appearance): xterm paints no background and the node supplies a
// translucent tint of THIS node's effective theme (lib/useTerminalGlass.ts).
const { glass, tint, vars: glassVars } = useTerminalGlass(visual.terminalTheme)
@@ -3340,6 +3347,22 @@ export function TerminalNode({
// dispatcher that honors the policy for every other chord, so it owes the check itself.
// `liveProjectJumpTarget` is the same decision Canvas's handler makes.
term.attachCustomKeyEventHandler((e) => {
+ // ⌘+ / ⌘− / ⌘0 → THIS terminal's font size (issue #915), only when the user opted in
+ // (`terminalFontZoomKeys`). First, and swallowed: off-mac xterm would otherwise write ^_ for
+ // Ctrl+− to the pty, and a prevented event keeps the window dispatcher's canvas ⌘0 out of it.
+ // Canvas applies the step (the one writer — see terminal-font-zoom.ts); the live re-option
+ // effect below then re-fits and reports the new grid like any font change. The desktop ⌘0
+ // never arrives here (main's before-input-event claims it); Canvas resolves that one from
+ // focus via FONT_ZOOM_NODE_ATTR on the xterm host.
+ const fontZoom = terminalFontZoomAction(e, {
+ enabled: useSettings.getState().settings.terminalFontZoomKeys,
+ isMac
+ })
+ if (fontZoom) {
+ e.preventDefault()
+ requestTerminalFontZoom(id, fontZoom)
+ return false
+ }
const ownsProjectJump =
terminalShortcutPolicy() !== 'terminal-first' && liveProjectJumpTarget(e) !== null
const registryOwns = terminalChordBubbles(
@@ -6405,6 +6428,7 @@ export function TerminalNode({
<div
className={`term-node__xterm nodrag nowheel${co.letterbox ? ' letterboxed' : ''}`}
ref={bodyRef}
+ {...{ [FONT_ZOOM_NODE_ATTR]: id }}
/>
{uploadNote && (
<div className={`term-node__upload${uploadNote.failed ? ' failed' : ''}`}>
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index 653af044e..8674539c1 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -36,6 +36,7 @@ import { normalizeNodeIcon } from '@shared/node-icon'
import { normalizeIssueRef, type IssueRef } from '@shared/github-issue-ref'
import { isSafeNodeId } from '@shared/safe-id'
import { normalizePendingLaunch } from '@shared/pending-launch-shape'
+import { normalizeTerminalFontSize } from '../terminal/terminal-font-zoom'
import { useSettings } from './settings'
// Re-exported so Canvas (and anything else in the renderer) keeps importing it from here, while the
@@ -87,6 +88,8 @@ export interface NodeData {
collapsed?: boolean
/** Agent nodes only: when true, this node's subagent/loop fan-out cards are hidden. */
hideFanout?: boolean
+ /** Terminal nodes: own font size (issue #915) — see CanvasNodeState.terminalFontSize. */
+ terminalFontSize?: number
/** Expanded height to restore when un-collapsing (kept out of the persisted size). */
expandedHeight?: number
/**
@@ -1967,6 +1970,9 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {
tags: n.tags,
collapsed,
hideFanout: n.hideFanout,
+ // Validated at the same seam as the icon below: project.json is hand-editable and shared,
+ // and xterm must never be handed a font size outside the Settings range (issue #915).
+ terminalFontSize: normalizeTerminalFontSize(n.terminalFontSize),
// Validated HERE, at the seam where a git-shared, hand-editable project file becomes live
// node data — so every surface that renders an icon gets a value this module vouched for
// rather than each one re-deciding. An unrecognized icon becomes no icon.
@@ -2054,6 +2060,8 @@ export function flowToNodeStates(nodes: CanvasNode[], retainInitialCommand = tru
tags: n.data.tags,
collapsed: n.data.collapsed,
hideFanout: n.data.hideFanout,
+ // Re-validated on the way OUT, same reasoning as the icon below (issue #915).
+ terminalFontSize: normalizeTerminalFontSize(n.data.terminalFontSize),
// React Flow's node `data` is `Record<string, unknown>`, so the icon comes back out
// untyped. Re-validating on the way OUT (not just on the way in) also means a value a
// peer canvas mutation or a future caller put on live node data cannot be written to the
diff --git a/src/renderer/terminal/terminal-font-zoom.test.ts b/src/renderer/terminal/terminal-font-zoom.test.ts
new file mode 100644
index 000000000..552e7128a
--- /dev/null
+++ b/src/renderer/terminal/terminal-font-zoom.test.ts
@@ -0,0 +1,200 @@
+// @vitest-environment jsdom
+import { describe, expect, it, vi } from 'vitest'
+import {
+ FONT_ZOOM_NODE_ATTR,
+ TERMINAL_FONT_SIZE_MAX,
+ TERMINAL_FONT_SIZE_MIN,
+ TERMINAL_FONT_ZOOM_EVENT,
+ effectiveTerminalFontSize,
+ fontZoomTargetNodeId,
+ nextTerminalFontSizeOverride,
+ normalizeTerminalFontSize,
+ requestTerminalFontZoom,
+ terminalFontZoomAction,
+ terminalFontZoomChord,
+ withTerminalFontSize,
+ type TerminalFontZoomEvent
+} from './terminal-font-zoom'
+
+const key = (over: Partial<TerminalFontZoomEvent>): TerminalFontZoomEvent => ({
+ type: 'keydown',
+ key: '',
+ code: '',
+ metaKey: false,
+ ctrlKey: false,
+ altKey: false,
+ shiftKey: false,
+ ...over
+})
+
+describe('terminalFontZoomChord (issue #915)', () => {
+ it('maps ⌘= / ⌘+ / ⌘- / ⌘0 on macOS', () => {
+ expect(terminalFontZoomChord(key({ metaKey: true, key: '=', code: 'Equal' }), true)).toBe('increase')
+ // US layout: ⌘+ is ⌘⇧= and reports key '+'.
+ expect(
+ terminalFontZoomChord(key({ metaKey: true, shiftKey: true, key: '+', code: 'Equal' }), true)
+ ).toBe('increase')
+ expect(terminalFontZoomChord(key({ metaKey: true, key: '-', code: 'Minus' }), true)).toBe('decrease')
+ expect(terminalFontZoomChord(key({ metaKey: true, key: '0', code: 'Digit0' }), true)).toBe('reset')
+ })
+
+ it('maps the numpad keys', () => {
+ expect(terminalFontZoomChord(key({ metaKey: true, key: '+', code: 'NumpadAdd' }), true)).toBe('increase')
+ expect(terminalFontZoomChord(key({ metaKey: true, key: '-', code: 'NumpadSubtract' }), true)).toBe(
+ 'decrease'
+ )
+ expect(terminalFontZoomChord(key({ metaKey: true, key: '0', code: 'Numpad0' }), true)).toBe('reset')
+ })
+
+ it('matches + and - on the CHARACTER, so a German "+" key (BracketRight) still zooms', () => {
+ expect(terminalFontZoomChord(key({ ctrlKey: true, key: '+', code: 'BracketRight' }), false)).toBe(
+ 'increase'
+ )
+ expect(terminalFontZoomChord(key({ ctrlKey: true, key: '-', code: 'Slash' }), false)).toBe('decrease')
+ })
+
+ it('uses Ctrl off-mac', () => {
+ expect(terminalFontZoomChord(key({ ctrlKey: true, key: '=', code: 'Equal' }), false)).toBe('increase')
+ expect(terminalFontZoomChord(key({ ctrlKey: true, key: '-', code: 'Minus' }), false)).toBe('decrease')
+ expect(terminalFontZoomChord(key({ ctrlKey: true, key: '0', code: 'Digit0' }), false)).toBe('reset')
+ })
+
+ it('leaves Ctrl+-/= to the shell on macOS (readline undo), and ⌘ alone off-mac', () => {
+ expect(terminalFontZoomChord(key({ ctrlKey: true, key: '-', code: 'Minus' }), true)).toBeNull()
+ expect(terminalFontZoomChord(key({ ctrlKey: true, key: '=', code: 'Equal' }), true)).toBeNull()
+ expect(terminalFontZoomChord(key({ metaKey: true, key: '-', code: 'Minus' }), false)).toBeNull()
+ // Both primaries held is a different chord.
+ expect(
+ terminalFontZoomChord(key({ metaKey: true, ctrlKey: true, key: '-', code: 'Minus' }), true)
+ ).toBeNull()
+ })
+
+ it('refuses bare keys, Alt/AltGr chords, ⌘⇧0 and keyup', () => {
+ expect(terminalFontZoomChord(key({ key: '-', code: 'Minus' }), true)).toBeNull()
+ expect(terminalFontZoomChord(key({ key: '=', code: 'Equal' }), false)).toBeNull()
+ expect(terminalFontZoomChord(key({ metaKey: true, altKey: true, key: '-', code: 'Minus' }), true)).toBeNull()
+ // AltGr reports as ctrl+alt off-mac and must keep typing its character.
+ expect(terminalFontZoomChord(key({ ctrlKey: true, altKey: true, key: '+', code: 'Equal' }), false)).toBeNull()
+ expect(
+ terminalFontZoomChord(key({ metaKey: true, shiftKey: true, key: ')', code: 'Digit0' }), true)
+ ).toBeNull()
+ expect(terminalFontZoomChord(key({ type: 'keyup', metaKey: true, key: '-', code: 'Minus' }), true)).toBeNull()
+ })
+
+ it('accepts auto-repeat: holding ⌘+ keeps growing (no animation to stutter)', () => {
+ expect(
+ terminalFontZoomChord(key({ metaKey: true, key: '=', code: 'Equal', repeat: true }), true)
+ ).toBe('increase')
+ })
+})
+
+describe('terminalFontZoomAction', () => {
+ const plus = key({ metaKey: true, key: '=', code: 'Equal' })
+ it('is inert while the setting is off (the default — today’s behaviour)', () => {
+ expect(terminalFontZoomAction(plus, { enabled: false, isMac: true })).toBeNull()
+ })
+ it('answers the chord when the setting is on', () => {
+ expect(terminalFontZoomAction(plus, { enabled: true, isMac: true })).toBe('increase')
+ expect(terminalFontZoomAction(key({ key: 'a', code: 'KeyA' }), { enabled: true, isMac: true })).toBeNull()
+ })
+})
+
+describe('normalizeTerminalFontSize / effectiveTerminalFontSize', () => {
+ it('accepts finite in-range numbers only (project.json is hand-editable)', () => {
+ expect(normalizeTerminalFontSize(14)).toBe(14)
+ expect(normalizeTerminalFontSize(TERMINAL_FONT_SIZE_MIN)).toBe(TERMINAL_FONT_SIZE_MIN)
+ expect(normalizeTerminalFontSize(TERMINAL_FONT_SIZE_MAX)).toBe(TERMINAL_FONT_SIZE_MAX)
+ expect(normalizeTerminalFontSize(TERMINAL_FONT_SIZE_MIN - 1)).toBeUndefined()
+ expect(normalizeTerminalFontSize(TERMINAL_FONT_SIZE_MAX + 1)).toBeUndefined()
+ expect(normalizeTerminalFontSize('14')).toBeUndefined()
+ expect(normalizeTerminalFontSize(NaN)).toBeUndefined()
+ expect(normalizeTerminalFontSize(Infinity)).toBeUndefined()
+ expect(normalizeTerminalFontSize(undefined)).toBeUndefined()
+ expect(normalizeTerminalFontSize(null)).toBeUndefined()
+ })
+
+ it('is override ?? global', () => {
+ expect(effectiveTerminalFontSize(13, undefined)).toBe(13)
+ expect(effectiveTerminalFontSize(13, 16)).toBe(16)
+ expect(effectiveTerminalFontSize(13, 'garbage')).toBe(13)
+ expect(effectiveTerminalFontSize(13, 99)).toBe(13)
+ })
+})
+
+describe('nextTerminalFontSizeOverride', () => {
+ it('steps by one from the effective size', () => {
+ expect(nextTerminalFontSizeOverride('increase', undefined, 13)).toBe(14)
+ expect(nextTerminalFontSizeOverride('decrease', undefined, 13)).toBe(12)
+ expect(nextTerminalFontSizeOverride('increase', 16, 13)).toBe(17)
+ expect(nextTerminalFontSizeOverride('decrease', 16, 13)).toBe(15)
+ })
+
+ it('clears the override when stepping lands back on the global size', () => {
+ expect(nextTerminalFontSizeOverride('decrease', 14, 13)).toBeUndefined()
+ expect(nextTerminalFontSizeOverride('increase', 12, 13)).toBeUndefined()
+ })
+
+ it('reset always clears the override', () => {
+ expect(nextTerminalFontSizeOverride('reset', 20, 13)).toBeUndefined()
+ expect(nextTerminalFontSizeOverride('reset', undefined, 13)).toBeUndefined()
+ })
+
+ it('is a no-op at the Settings bounds (same 8–28 range as the global field)', () => {
+ expect(nextTerminalFontSizeOverride('increase', TERMINAL_FONT_SIZE_MAX, 13)).toBe(TERMINAL_FONT_SIZE_MAX)
+ expect(nextTerminalFontSizeOverride('decrease', TERMINAL_FONT_SIZE_MIN, 13)).toBe(TERMINAL_FONT_SIZE_MIN)
+ // Global itself at the bound, no override: nothing to store.
+ expect(nextTerminalFontSizeOverride('increase', undefined, TERMINAL_FONT_SIZE_MAX)).toBeUndefined()
+ })
+
+ it('does not shrink a hand-edited out-of-range global on ⌘+', () => {
+ expect(nextTerminalFontSizeOverride('increase', undefined, 40)).toBeUndefined()
+ expect(nextTerminalFontSizeOverride('decrease', undefined, 40)).toBe(TERMINAL_FONT_SIZE_MAX)
+ })
+
+ it('ignores a garbage stored override and steps from the global', () => {
+ expect(nextTerminalFontSizeOverride('increase', 'x', 13)).toBe(14)
+ })
+})
+
+describe('withTerminalFontSize', () => {
+ const visual = { fontSize: 13, fontFamily: 'Menlo' }
+ it('returns the SAME object when there is no effective override (memo identity)', () => {
+ expect(withTerminalFontSize(visual, undefined)).toBe(visual)
+ expect(withTerminalFontSize(visual, 13)).toBe(visual)
+ expect(withTerminalFontSize(visual, 'bad')).toBe(visual)
+ })
+ it('replaces only fontSize', () => {
+ expect(withTerminalFontSize(visual, 17)).toEqual({ fontSize: 17, fontFamily: 'Menlo' })
+ expect(visual.fontSize).toBe(13)
+ })
+})
+
+describe('fontZoomTargetNodeId', () => {
+ it('finds the terminal the focused element sits in', () => {
+ const host = document.createElement('div')
+ host.setAttribute(FONT_ZOOM_NODE_ATTR, 'node-1')
+ const ta = document.createElement('textarea')
+ host.appendChild(ta)
+ document.body.appendChild(host)
+ expect(fontZoomTargetNodeId(ta)).toBe('node-1')
+ host.remove()
+ })
+ it('is null outside a terminal and for null', () => {
+ const input = document.createElement('input')
+ document.body.appendChild(input)
+ expect(fontZoomTargetNodeId(input)).toBeNull()
+ expect(fontZoomTargetNodeId(null)).toBeNull()
+ input.remove()
+ })
+})
+
+describe('requestTerminalFontZoom', () => {
+ it('dispatches the one event Canvas applies', () => {
+ const seen = vi.fn()
+ const onEvt = (e: Event): void => seen((e as CustomEvent).detail)
+ window.addEventListener(TERMINAL_FONT_ZOOM_EVENT, onEvt)
+ requestTerminalFontZoom('n1', 'decrease')
+ window.removeEventListener(TERMINAL_FONT_ZOOM_EVENT, onEvt)
+ expect(seen).toHaveBeenCalledWith({ nodeId: 'n1', action: 'decrease' })
+ })
+})
diff --git a/src/renderer/terminal/terminal-font-zoom.ts b/src/renderer/terminal/terminal-font-zoom.ts
new file mode 100644
index 000000000..1cdc13e6d
--- /dev/null
+++ b/src/renderer/terminal/terminal-font-zoom.ts
@@ -0,0 +1,174 @@
+/**
+ * Per-terminal font size from the keyboard (issue #915): ⌘+ / ⌘− grow and shrink the FOCUSED
+ * terminal's font, ⌘0 puts it back on the global size — what every terminal emulator (iTerm2,
+ * Terminal.app, Windows Terminal, VS Code's integrated terminal) means by those keys.
+ *
+ * **Opt-in** (`settings.terminalFontZoomKeys`, Settings → Terminal, default OFF), and only ever
+ * while a terminal has keyboard focus. With it off — or outside a terminal — every key here keeps
+ * doing exactly what it did before: ⌘0 zooms the canvas to 100% (`lib/zoomShortcut.ts`), ⌘+ / ⌘−
+ * reach whatever has focus. Opt-in rather than default because off-mac the chord is Ctrl+− /
+ * Ctrl+=, and Ctrl+− is a real shell key (readline's `undo`, ^_) that a focused terminal passes to
+ * the pty today; taking it away from existing users uninvited is the #383 mistake again.
+ *
+ * **The override lives on the NODE** (`data.terminalFontSize`, persisted in project.json like any
+ * other node field) and is layered over the global size in ONE place — `useXtermVisualSettings`'s
+ * optional override, via `withTerminalFontSize` below — so the canvas TerminalNode and the kanban
+ * card modal's second view of the SAME session read one value through one options path
+ * (`applyLiveOptions`) and cannot drift. The settings preview passes no override, so it keeps
+ * showing the global size being edited.
+ *
+ * Font size is CELL GEOMETRY: a change reports `metricsChanged` from `applyLiveOptions`, and both
+ * surfaces already route that through their re-fit + pty resize, exactly like a live global
+ * font-size edit — so the pty is told the new cols/rows with no new code on that path. Canvas zoom
+ * is untouched by all of this: it is a CSS transform over the node, independent of the font.
+ *
+ * ONE WRITER. Every entry point (the canvas terminal's xterm key handler, the card modal's, and the
+ * desktop ⌘0 that main forwards without an event) asks Canvas to apply the step through
+ * `requestTerminalFontZoom`, so the read-modify-write of node data, `markDirty` and the clamp all
+ * happen in one handler instead of three.
+ */
+
+/** The same range the Settings → Terminal font-size field advertises (its min/max). */
+export const TERMINAL_FONT_SIZE_MIN = 8
+export const TERMINAL_FONT_SIZE_MAX = 28
+
+export type TerminalFontZoomAction = 'increase' | 'decrease' | 'reset'
+
+/** The subset of `KeyboardEvent` the chord is decided from (so tests need no DOM). */
+export interface TerminalFontZoomEvent {
+ type: string
+ key: string
+ code: string
+ metaKey: boolean
+ ctrlKey: boolean
+ altKey: boolean
+ shiftKey: boolean
+ repeat?: boolean
+}
+
+/**
+ * PURE, key-shape only.
+ *
+ * - **Primary modifier per platform, exactly one of them**: ⌘ on macOS, Ctrl elsewhere. Unlike the
+ * canvas zoom chord (which accepts either everywhere), this one fires while the user is TYPING in
+ * a shell, and on macOS Ctrl+− / Ctrl+= are terminal keys (^_ is readline's undo) that must keep
+ * reaching the pty.
+ * - **+ and − match on the CHARACTER** (`e.key`), with the numpad codes as a fallback: the key a
+ * user presses for "bigger" is the one labelled +, which on a German layout is its own key
+ * (`BracketRight`) and on US is ⇧= — so Shift is not constrained for these two.
+ * - **0 matches on the physical key** (`e.code`), like the canvas ⌘0 and main's intercept, so the
+ * two agree about which key is "0" on AZERTY; ⌘⇧0 is a different chord.
+ * - Alt is refused (AltGr reports as ctrl+alt off-mac and must keep typing its character).
+ * - Auto-repeat is ACCEPTED: nothing here animates, and holding ⌘+ to keep growing is expected.
+ */
+export function terminalFontZoomChord(
+ e: TerminalFontZoomEvent,
+ isMac: boolean
+): TerminalFontZoomAction | null {
+ if (e.type !== 'keydown' || e.altKey) return null
+ const primary = isMac ? e.metaKey && !e.ctrlKey : e.ctrlKey && !e.metaKey
+ if (!primary) return null
+ if (e.key === '+' || e.key === '=' || e.code === 'NumpadAdd') return 'increase'
+ if (e.key === '-' || e.code === 'NumpadSubtract') return 'decrease'
+ if (!e.shiftKey && (e.code === 'Digit0' || e.code === 'Numpad0')) return 'reset'
+ return null
+}
+
+export interface TerminalFontZoomContext {
+ /** `settings.terminalFontZoomKeys`. */
+ enabled: boolean
+ isMac: boolean
+}
+
+/** PURE. The action a keydown in a focused terminal should run, or null to leave the key alone. */
+export function terminalFontZoomAction(
+ e: TerminalFontZoomEvent,
+ ctx: TerminalFontZoomContext
+): TerminalFontZoomAction | null {
+ if (!ctx.enabled) return null
+ return terminalFontZoomChord(e, ctx.isMac)
+}
+
+/**
+ * PURE. A stored override as a usable size, or `undefined`. The value comes out of a git-shared,
+ * hand-editable project.json (and off a team-sync peer), so anything that is not a finite number
+ * inside the Settings range is treated as "no override" rather than handed to xterm.
+ */
+export function normalizeTerminalFontSize(v: unknown): number | undefined {
+ if (typeof v !== 'number' || !Number.isFinite(v)) return undefined
+ if (v < TERMINAL_FONT_SIZE_MIN || v > TERMINAL_FONT_SIZE_MAX) return undefined
+ return v
+}
+
+/** PURE. The size a terminal renders at: its own override, else the global setting. */
+export function effectiveTerminalFontSize(global: number, override: unknown): number {
+ return normalizeTerminalFontSize(override) ?? global
+}
+
+/**
+ * PURE. The node's NEW override after `action` (`undefined` = no override, follow the global).
+ *
+ * - Steps by 1 from the EFFECTIVE size.
+ * - Landing back on the global size clears the override instead of storing a copy of it, so a node
+ * the user nudged up and back down follows later global changes again.
+ * - The result is clamped to the Settings range, but the clamp may only move the size in the
+ * direction asked for: at a bound the step is a no-op (the current override comes back
+ * unchanged), and ⌘+ can never SHRINK a terminal whose global size was hand-edited above the
+ * maximum (⌘− there lands it on the maximum).
+ * - `reset` always clears.
+ */
+export function nextTerminalFontSizeOverride(
+ action: TerminalFontZoomAction,
+ override: unknown,
+ global: number
+): number | undefined {
+ const current = normalizeTerminalFontSize(override)
+ if (action === 'reset') return undefined
+ const base = current ?? global
+ const grow = action === 'increase'
+ const target = Math.min(
+ TERMINAL_FONT_SIZE_MAX,
+ Math.max(TERMINAL_FONT_SIZE_MIN, base + (grow ? 1 : -1))
+ )
+ // The clamp may only ever move the size in the direction asked for; otherwise it is a no-op.
+ if (grow ? target <= base : target >= base) return current
+ return target === global ? undefined : target
+}
+
+/**
+ * PURE. `visual` with the node's override applied — returned BY IDENTITY when there is nothing to
+ * override, because the result is the dependency the terminals' live re-option effects hang off
+ * (same rule as `mergeProjectVisuals`).
+ */
+export function withTerminalFontSize<T extends { fontSize: number }>(visual: T, override: unknown): T {
+ const size = effectiveTerminalFontSize(visual.fontSize, override)
+ return size === visual.fontSize ? visual : { ...visual, fontSize: size }
+}
+
+/** Stamped on each terminal's xterm host (canvas node and card modal) with the node id. */
+export const FONT_ZOOM_NODE_ATTR = 'data-font-zoom-node'
+
+/**
+ * PURE over the element: the node id of the terminal `active` sits in, or null. The desktop ⌘0
+ * reaches Canvas WITHOUT an event (main's `before-input-event` claims it — see
+ * `main/keydown-intercept.ts`), so "which terminal?" has to be answered from the focus.
+ */
+export function fontZoomTargetNodeId(active: Element | null): string | null {
+ if (!active) return null
+ return active.closest(`[${FONT_ZOOM_NODE_ATTR}]`)?.getAttribute(FONT_ZOOM_NODE_ATTR) ?? null
+}
+
+/** The window event Canvas applies (the single writer, see the header). */
+export const TERMINAL_FONT_ZOOM_EVENT = 'nodeterm:terminal-font-zoom'
+
+export interface TerminalFontZoomRequest {
+ nodeId: string
+ action: TerminalFontZoomAction
+}
+
+/** Ask Canvas to step `nodeId`'s font. Same no-direct-line-to-the-canvas pattern as open-file. */
+export function requestTerminalFontZoom(nodeId: string, action: TerminalFontZoomAction): void {
+ window.dispatchEvent(
+ new CustomEvent<TerminalFontZoomRequest>(TERMINAL_FONT_ZOOM_EVENT, { detail: { nodeId, action } })
+ )
+}
diff --git a/src/renderer/terminal/terminal-font-zoom.wiring.test.ts b/src/renderer/terminal/terminal-font-zoom.wiring.test.ts
new file mode 100644
index 000000000..279174e85
--- /dev/null
+++ b/src/renderer/terminal/terminal-font-zoom.wiring.test.ts
@@ -0,0 +1,135 @@
+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 — 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('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(')
+ })
+})
+
+describe('terminal font zoom — shortcuts panel', () => {
+ const BASE: ShortcutSectionsOptions = {
+ isMac: true,
+ browser: false,
+ panHoverDelay: 500,
+ dragMode: 'select',
+ doubleClickFocus: false,
+ 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 --git a/src/renderer/terminal/useXtermVisualSettings.ts b/src/renderer/terminal/useXtermVisualSettings.ts
index 834fb34a8..3165568de 100644
--- a/src/renderer/terminal/useXtermVisualSettings.ts
+++ b/src/renderer/terminal/useXtermVisualSettings.ts
@@ -3,6 +3,7 @@ import { useShallow } from 'zustand/react/shallow'
import { useSettings } from '../state/settings'
import { useProjectVisuals } from '../state/projectLaunchInfo'
import { mergeProjectVisuals, XTERM_VISUAL_KEYS, type XtermVisualSettings } from './terminal-config'
+import { withTerminalFontSize } from './terminal-font-zoom'
/**
* The appearance slice of Settings for ONE project's terminals, as two subscriptions.
@@ -28,12 +29,22 @@ import { mergeProjectVisuals, XTERM_VISUAL_KEYS, type XtermVisualSettings } from
* re-rendering when one of those moves. Shallow again, and over the two values only.
*
* SPEC DEVIATION, deliberate (Task 5): the spec said a project's appearance applies "when a terminal
- * is created", with existing terminals keeping theirs. There is no per-node appearance in this app —
+ * is created", with existing terminals keeping theirs. There is no per-node appearance in this app
+ * (the one exception, since #915, is the node's font size — below) —
* every terminal renders from the live settings and re-options itself through `applyLiveOptions` —
* so the honest implementation is live and project-scoped: changing a project's theme repaints that
* project's terminals, including ones already open, and leaves every other project's alone.
+ *
+ * `fontSizeOverride` is the NODE's own font size (issue #915, `data.terminalFontSize`), layered
+ * last — over the global size and whatever the project set — through `withTerminalFontSize`. It is
+ * a parameter HERE rather than a second merge at each call site so the canvas node and the card
+ * modal (a second view of the same session) cannot apply it differently; the settings preview
+ * passes none. Typed `unknown` because it comes straight off node data: the helper validates it.
*/
-export function useXtermVisualSettings(projectId?: string): XtermVisualSettings {
+export function useXtermVisualSettings(
+ projectId?: string,
+ fontSizeOverride?: unknown
+): XtermVisualSettings {
const base = useSettings(
useShallow((s) => {
const out = {} as Record<string, unknown>
@@ -51,5 +62,8 @@ export function useXtermVisualSettings(projectId?: string): XtermVisualSettings
)
// Identity-stable while neither half changed: this value is the dependency the terminal
// components' live re-option effects hang off.
- return useMemo(() => mergeProjectVisuals(base, overrides), [base, overrides])
+ const merged = useMemo(() => mergeProjectVisuals(base, overrides), [base, overrides])
+ // Identity-preserving too (`withTerminalFontSize` returns `merged` itself when there is no
+ // effective override), so nodes without one re-option exactly as before.
+ return useMemo(() => withTerminalFontSize(merged, fontSizeOverride), [merged, fontSizeOverride])
}
diff --git a/src/shared/types.ts b/src/shared/types.ts
index e27de074e..fd549ae77 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -499,6 +499,10 @@ export interface CanvasNodeState {
/** Parent group node id, if this node belongs to a group frame. */
parentId?: string
// terminal-only
+ /** This terminal's own font size (issue #915), set with ⌘+ / ⌘− when
+ * `settings.terminalFontZoomKeys` is on; absent = follow the global `fontSize`. Hand-editable,
+ * so every reader goes through `normalizeTerminalFontSize` (renderer/terminal/terminal-font-zoom). */
+ terminalFontSize?: number
shell?: string
cwd?: string
/** Which agent runs in this terminal node (claude/codex/gemini/custom). */
@@ -1874,6 +1878,13 @@ 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
/** 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. */
@@ -2245,6 +2256,7 @@ export const DEFAULT_SETTINGS: Settings = {
openMarkdownPreviewMigrated: true,
terminalMiddleClickPaste: false,
copyOnSelect: false,
+ terminalFontZoomKeys: false,
wheelZoom: false,
wheelZoomSpeed: 1,
trackpadPan: true,