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
fix(terminal): font size follows a reopened terminal, works on other projects' cards, and says what it did
Mina Sameh8f3f2e90d40a
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex f84574c90..f26fe578a 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -339,6 +339,7 @@ import {normalizeTerminalFontSize,patchProjectFontSize,requestTerminalFontZoom,+ fontZoomNoticeText,type TerminalFontZoomRequest} from '../terminal/terminal-font-zoom'import { isMacPlatform, isWindowsPlatform } from '@shared/platform-utils'@@ -11116,10 +11117,30 @@ export function Canvas() {const onFontZoom = (e: Event): void => {const d = (e as CustomEvent<TerminalFontZoomRequest>).detailif (!d?.nodeId) return+ const globalSize = useSettings.getState().settings.fontSizeconst node = nodesRef.current.find((n) => n.id === d.nodeId)- if (!node || node.type !== 'terminal') return+ if (!node) {+ // Not on THIS canvas: a global-board card of another project. Its size is stored content,+ // so write it through the store's own-write path (like the icon of an off-canvas node), then+ // persist. A relay tab's node belongs to the host's core and stays untouched.+ const st = useProjects.getState()+ const owner = nodeOwner(st.projects, d.nodeId)+ const stored = owner?.nodes.find((n) => n.id === d.nodeId)+ if (!owner || owner.remote || !stored || (stored.kind ?? 'terminal') !== 'terminal') return+ const storedPrev = normalizeTerminalFontSize(stored.terminalFontSize)+ const storedNext = nextTerminalFontSizeOverride(d.action, storedPrev, globalSize)+ const storedText = fontZoomNoticeText(d.action, storedPrev, storedNext, globalSize)+ if (storedText) setNotice({ kind: 'info', text: storedText })+ if (storedNext === storedPrev) return+ st.applyOwnNodeMutation(owner.id, { op: 'upsert', node: { ...stored, terminalFontSize: storedNext } })+ void persist()+ return+ }+ if (node.type !== 'terminal') returnconst prev = normalizeTerminalFontSize(node.data.terminalFontSize)- const next = nextTerminalFontSizeOverride(d.action, prev, useSettings.getState().settings.fontSize)+ const next = nextTerminalFontSizeOverride(d.action, prev, globalSize)+ const noticeText = fontZoomNoticeText(d.action, prev, next, globalSize)+ if (noticeText) setNotice({ kind: 'info', text: noticeText })if (next === prev) returnsetNodes((ns) =>ns.map((n) => (n.id === d.nodeId ? { ...n, data: { ...n.data, terminalFontSize: next } } : n))@@ -11140,7 +11161,7 @@ export function Canvas() {}window.addEventListener(TERMINAL_FONT_ZOOM_EVENT, onFontZoom)return () => window.removeEventListener(TERMINAL_FONT_ZOOM_EVENT, onFontZoom)- }, [setNodes, markDirty, nodesRef])+ }, [setNodes, markDirty, nodesRef, persist])// Apply the accent color as a CSS variable.useEffect(() => {diff --git a/src/renderer/lib/reopenNode.test.ts b/src/renderer/lib/reopenNode.test.tsindex ba545019d..1de4d8650 100644--- a/src/renderer/lib/reopenNode.test.ts+++ b/src/renderer/lib/reopenNode.test.ts@@ -156,6 +156,19 @@ describe('recreateNodeFromSnapshot', () => {expect(withIcon({ type: 'lucide', name: 'nope' })!.data.icon).toBeUndefined()})+ // ⇧⌘T used to bring a terminal back at the global size: the per-terminal override (issue #915)+ // was in the snapshot but not a cosmetic key.+ it('carries the per-terminal font size over, re-validated', () => {+ const withSize = (terminalFontSize: unknown) =>+ recreateNodeFromSnapshot(+ snap({ type: 'terminal', data: { title: 't', color: '#fff', group: null, terminalFontSize: terminalFontSize as never } }),+ baseCtx()+ )+ expect(withSize(18)!.data.terminalFontSize).toBe(18)+ expect(withSize(999)!.data.terminalFontSize).toBeUndefined()+ expect(withSize('x')!.data.terminalFontSize).toBeUndefined()+ })+it('recreates a dino node carrying its high score', () => {const node = recreateNodeFromSnapshot(snap({ type: 'dino', data: { title: 'Dino', color: '#a2a2a2', group: null, highScore: 42 } }),diff --git a/src/renderer/lib/reopenNode.ts b/src/renderer/lib/reopenNode.tsindex 6461cd4b9..83a0c977b 100644--- a/src/renderer/lib/reopenNode.ts+++ b/src/renderer/lib/reopenNode.ts@@ -22,6 +22,7 @@ import { normalizeRunConfig } from '@shared/run-config'import { normalizeSimulatorConfig } from '@shared/simulator'import { absolutePosition, type FocusableNode } from './nodeFocus'import { normalizeNodeIcon } from '@shared/node-icon'+import { normalizeTerminalFontSize } from '../terminal/terminal-font-zoom'export type RestorableNodeKind = Exclude<NodeKind, 'group' | 'subagent' | 'loop'>@@ -122,6 +123,10 @@ function withCosmetics(node: CanvasNode, data: NodeData): CanvasNode {// Without this a reopened session came back without the icon it was closed with.const icon = normalizeNodeIcon(data.icon)if (icon) cosmetics.icon = icon+ // The per-terminal font size (issue #915) is a cosmetic too, and crosses the same validator the+ // serializers use: the persisted twin comes from the hand-editable workspace.json.+ const terminalFontSize = normalizeTerminalFontSize(data.terminalFontSize)+ if (terminalFontSize !== undefined) cosmetics.terminalFontSize = terminalFontSizereturn { ...node, data: { ...node.data, ...cosmetics } }}diff --git a/src/renderer/terminal/terminal-font-zoom.test.ts b/src/renderer/terminal/terminal-font-zoom.test.tsindex 60a7d714c..2f1666ff0 100644--- a/src/renderer/terminal/terminal-font-zoom.test.ts+++ b/src/renderer/terminal/terminal-font-zoom.test.ts@@ -6,6 +6,7 @@ import {TERMINAL_FONT_SIZE_MIN,TERMINAL_FONT_ZOOM_EVENT,effectiveTerminalFontSize,+ fontZoomNoticeText,fontZoomTargetNodeId,forwardedResetMatches,leavesSharedGlyphAtlas,@@ -271,3 +272,22 @@ describe('patchProjectFontSize (the store-level patch the Omni mirror applies)',expect(patchProjectFontSize(projects, 'nope', 'a', 20)).toBe(projects)})})++describe('fontZoomNoticeText', () => {+ it('names the new size on a step', () => {+ expect(fontZoomNoticeText('increase', undefined, 14, 13)).toBe('Terminal font size 14')+ expect(fontZoomNoticeText('decrease', 14, undefined, 13)).toBe('Terminal font size 13')+ })+ it('says so when the clamp refuses a step, instead of staying silent', () => {+ expect(fontZoomNoticeText('increase', TERMINAL_FONT_SIZE_MAX, TERMINAL_FONT_SIZE_MAX, 13)).toBe(+ `Terminal font size ${TERMINAL_FONT_SIZE_MAX} (maximum)`+ )+ expect(fontZoomNoticeText('decrease', TERMINAL_FONT_SIZE_MIN, TERMINAL_FONT_SIZE_MIN, 13)).toBe(+ `Terminal font size ${TERMINAL_FONT_SIZE_MIN} (minimum)`+ )+ })+ it('reports a reset to the default, and says nothing for a reset that changes nothing', () => {+ expect(fontZoomNoticeText('reset', 20, undefined, 13)).toBe('Terminal font size reset to default (13)')+ expect(fontZoomNoticeText('reset', undefined, undefined, 13)).toBeNull()+ })+})diff --git a/src/renderer/terminal/terminal-font-zoom.ts b/src/renderer/terminal/terminal-font-zoom.tsindex 37b966ebd..69c0f3fe6 100644--- a/src/renderer/terminal/terminal-font-zoom.ts+++ b/src/renderer/terminal/terminal-font-zoom.ts@@ -139,6 +139,34 @@ export function nextTerminalFontSizeOverride(return target === global ? undefined : target}+/**+ * PURE. The one-line notice a font-size step earns, or null when there is nothing to say (a reset+ * that changes nothing). A step that the clamp refuses is the case this exists for: before it, ⌘+ at+ * the maximum did nothing at all, which read as a broken chord.+ */+export function fontZoomNoticeText(+ action: TerminalFontZoomAction,+ prev: number | undefined,+ next: number | undefined,+ global: number+): string | null {+ const now = next ?? global+ if (action === 'reset') {+ return prev === undefined ? null : `Terminal font size reset to default (${now})`+ }+ if (next === prev) {+ const before = prev ?? global+ if (action === 'increase' && before >= TERMINAL_FONT_SIZE_MAX) {+ return `Terminal font size ${before} (maximum)`+ }+ if (action === 'decrease' && before <= TERMINAL_FONT_SIZE_MIN) {+ return `Terminal font size ${before} (minimum)`+ }+ return null+ }+ return `Terminal font size ${now}`+}+/*** 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 offdiff --git a/src/renderer/terminal/terminal-font-zoom.wiring.test.ts b/src/renderer/terminal/terminal-font-zoom.wiring.test.tsindex b53332c3b..67c16d0dd 100644--- a/src/renderer/terminal/terminal-font-zoom.wiring.test.ts+++ b/src/renderer/terminal/terminal-font-zoom.wiring.test.ts@@ -168,3 +168,20 @@ describe('terminal font zoom — shortcuts panel', () => {expect(labels({ terminalFontZoomKeys: true })).toContain('Terminal font size back to the global size')})})++describe('terminal font zoom — cards of another project (Omni board) and notices', () => {+ const writer = CANVAS.slice(CANVAS.indexOf('const onFontZoom = (e: Event)'))+ const body = writer.slice(0, writer.indexOf('window.addEventListener(TERMINAL_FONT_ZOOM_EVENT'))+ it('a node that is not on the live canvas is written through the store and persisted, never dropped', () => {+ expect(body).toContain('nodeOwner(st.projects, d.nodeId)')+ expect(body).toContain('applyOwnNodeMutation(owner.id')+ expect(body).toContain('void persist()')+ })+ it('a relay tab keeps its host-owned nodes untouched', () => {+ expect(body).toContain('owner.remote')+ })+ it('both paths raise the info notice from the one pure text', () => {+ expect(body.match(/fontZoomNoticeText\(/g)).toHaveLength(2)+ expect(body).toContain("setNotice({ kind: 'info'")+ })+})