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.

fix: reconcile per-terminal font zoom with the shared glyph renderer and mac Ctrl+0 (#915)

Erik Zwep6f3ece360fef
diff --git a/CLAUDE.md b/CLAUDE.md
index 057e4391b..e69cc671b 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -6500,6 +6500,11 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord mea
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).
+ Two review fixes: main forwards ⌘0 WITH `{meta, control}` and the renderer resets only on the
+ platform chord (`forwardedResetMatches` — a mac Ctrl+0 keeps its old meaning); and under
+ `terminalGpuRendering: 'shared'` a node whose size differs from the global one is held OFF the
+ shared glyph canvas (`leavesSharedGlyphAtlas` → `glyphOff`) and paints its own pixels, because the
+ shared atlas is rasterized for the global font and a grid's cell is fixed at `register`.
- **"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/main/keydown-intercept.test.ts b/src/main/keydown-intercept.test.ts
index 8b964252b..253e8c926 100644
--- a/src/main/keydown-intercept.test.ts
+++ b/src/main/keydown-intercept.test.ts
@@ -691,3 +691,36 @@ describe('the close leg stands down inside a terminal, off-mac only (#383)', ()
expect(menuSync).toContain('MENU_ITEM_ID_CLOSE')
})
})
+
+// Issue #915 review: the forwarded ⌘0 carries its modifiers, so the renderer can apply the SAME
+// per-platform predicate the terminal font reset uses (⌘ on mac, Ctrl elsewhere) — without them a
+// mac Ctrl+0 cleared a terminal's font override while the browser path would not.
+describe('zoom-actual-size forwards the chord modifiers (#915)', () => {
+ const capture = (over: Partial<KeydownInterceptInput>): unknown[][] => {
+ const calls: unknown[][] = []
+ let handler: ((e: { preventDefault(): void }, i: KeydownInterceptInput) => void) | null = null
+ const win: KeydownInterceptTarget = {
+ webContents: {
+ on: (_event, listener) => {
+ handler = listener
+ },
+ send: (channel, ...args) => {
+ calls.push([channel, ...args])
+ }
+ }
+ }
+ installKeydownIntercepts(win, () => ({ closeNode: [], toggleMarkdown: [] }), true, () => false, () => false)
+ ;(handler as unknown as (e: { preventDefault(): void }, i: KeydownInterceptInput) => void)(
+ { preventDefault: () => undefined },
+ input({ code: 'Digit0', key: '0', ...over })
+ )
+ return calls
+ }
+ it('sends { meta, control } with the zoom-actual-size signal', () => {
+ expect(capture({ meta: true })).toEqual([[IPC.appZoomActualSize, { meta: true, control: false }]])
+ expect(capture({ control: true })).toEqual([[IPC.appZoomActualSize, { meta: false, control: true }]])
+ expect(capture({ meta: true, control: true })).toEqual([
+ [IPC.appZoomActualSize, { meta: true, control: true }]
+ ])
+ })
+})
diff --git a/src/main/keydown-intercept.ts b/src/main/keydown-intercept.ts
index 910f9d538..47202d9c5 100644
--- a/src/main/keydown-intercept.ts
+++ b/src/main/keydown-intercept.ts
@@ -425,6 +425,18 @@ export function installKeydownIntercepts(
// it either.
if (decision.action === 'close-node' && isCloseSuspended()) return
event.preventDefault()
- if (decision.action) win.webContents.send(keydownInterceptChannel(decision.action))
+ if (!decision.action) return
+ // ⌘0 carries its modifiers (issue #915 review): the renderer reads them to decide whether the
+ // chord is the platform's terminal-font reset (⌘ on mac, Ctrl elsewhere — never both) before
+ // falling back to canvas zoom-to-100%. The decision above accepts `meta || control`, so without
+ // them a mac Ctrl+0 was indistinguishable from ⌘0 there.
+ if (decision.action === 'zoom-actual-size') {
+ win.webContents.send(keydownInterceptChannel(decision.action), {
+ meta: input.meta,
+ control: input.control
+ })
+ return
+ }
+ win.webContents.send(keydownInterceptChannel(decision.action))
})
}
diff --git a/src/preload/index.ts b/src/preload/index.ts
index b0eddc084..51e2991b1 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -20,7 +20,8 @@ import type {
UpdateProgress,
Workspace,
WorkspaceSaveOptions,
- WorkspaceMigrationKind
+ WorkspaceMigrationKind,
+ ZoomActualSizeModifiers
} from '../shared/types'
import type { ClientId, PeerDiff, PeerIdentity, PeerState } from '../shared/presence'
import type { ProjectConsentRequest, ProjectSetupEvent } from '../shared/project-settings'
@@ -784,7 +785,7 @@ const api: NodeTerminalApi = {
},
onMarkdownToggle: subscribe(IPC.appToggleMarkdown),
onCloseNode: subscribe(IPC.appCloseNode),
- onZoomActualSize: subscribe(IPC.appZoomActualSize),
+ onZoomActualSize: subscribe<[ZoomActualSizeModifiers?]>(IPC.appZoomActualSize),
// Native View menu → renderer.
onToggleAutoAlign: subscribe(IPC.appToggleAutoAlign),
onFitView: subscribe(IPC.appFitView),
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index f8c0adba7..e6ec6e2dc 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -257,11 +257,13 @@ import {
import {
TERMINAL_FONT_ZOOM_EVENT,
fontZoomTargetNodeId,
+ forwardedResetMatches,
nextTerminalFontSizeOverride,
normalizeTerminalFontSize,
requestTerminalFontZoom,
type TerminalFontZoomRequest
} from '../terminal/terminal-font-zoom'
+import { isMacPlatform } from '@shared/platform-utils'
import {
dispatchGlobalKeydown,
type GlobalKeyEvent,
@@ -9584,10 +9586,13 @@ export function Canvas() {
// 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
+ return window.nodeTerminal.onZoomActualSize((mods) => {
+ // Only the platform's reset chord (⌘0 on mac, Ctrl+0 elsewhere — main forwards either, and
+ // both together): any other forwarded ⌘/Ctrl+0 keeps exactly its pre-#915 meaning.
+ const target =
+ useSettings.getState().settings.terminalFontZoomKeys && forwardedResetMatches(mods, isMacPlatform())
+ ? fontZoomTargetNodeId(typeof document === 'undefined' ? null : document.activeElement)
+ : null
if (target) {
requestTerminalFontZoom(target, 'reset')
return
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index cae895c4c..fe550e4f0 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -103,6 +103,7 @@ import {
import { useXtermVisualSettings } from '../terminal/useXtermVisualSettings'
import {
FONT_ZOOM_NODE_ATTR,
+ leavesSharedGlyphAtlas,
requestTerminalFontZoom,
terminalFontZoomAction
} from '../terminal/terminal-font-zoom'
@@ -1357,6 +1358,8 @@ export function TerminalNode({
// `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)
+ // The GLOBAL size the shared glyph atlas is rasterized for (see `fontLeavesAtlas`).
+ const globalFontSize = useSettings((s) => s.settings.fontSize)
// 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)
@@ -1700,7 +1703,13 @@ export function TerminalNode({
// React Flow viewport, so the shared layer's glyphs — positioned from on-canvas geometry —
// would paint somewhere the node no longer is. Routes through the same setup/teardown the
// collapse/⌘M/stacking/drag reasons always used; v1 deliberately forces the DOM/WebGL path.
- const glyphOff = collapsed || mdMode || glyphOpaque || dragging || focused
+ // `fontLeavesAtlas` is a MUST-BE-OPAQUE reason too (issue #915 review): the shared atlas is
+ // rasterized for the GLOBAL font with a cell fixed at `register`, so a node rendering at its own
+ // ⌘+/⌘− size would keep painting old-size glyphs over a pty that was resized to the new cell.
+ // Holding it off the shared canvas makes it paint its own pixels; clearing the override rejoins.
+ // `visual` is declared above, so this reads the same effective size xterm is re-optioned with.
+ const fontLeavesAtlas = leavesSharedGlyphAtlas(visual.fontSize, globalFontSize)
+ const glyphOff = collapsed || mdMode || glyphOpaque || dragging || focused || fontLeavesAtlas
const glyphOffRef = useRef(glyphOff)
glyphOffRef.current = glyphOff
// The NOT-ON-SCREEN half on its own. `setupGlyph`'s gate needs to tell the two reasons apart:
diff --git a/src/renderer/terminal/terminal-font-zoom.test.ts b/src/renderer/terminal/terminal-font-zoom.test.ts
index 552e7128a..66b1bc74d 100644
--- a/src/renderer/terminal/terminal-font-zoom.test.ts
+++ b/src/renderer/terminal/terminal-font-zoom.test.ts
@@ -7,6 +7,8 @@ import {
TERMINAL_FONT_ZOOM_EVENT,
effectiveTerminalFontSize,
fontZoomTargetNodeId,
+ forwardedResetMatches,
+ leavesSharedGlyphAtlas,
nextTerminalFontSizeOverride,
normalizeTerminalFontSize,
requestTerminalFontZoom,
@@ -198,3 +200,25 @@ describe('requestTerminalFontZoom', () => {
expect(seen).toHaveBeenCalledWith({ nodeId: 'n1', action: 'decrease' })
})
})
+
+describe('forwardedResetMatches (review of #915: desktop ⌘0 arrives without an event)', () => {
+ it('accepts exactly the platform primary', () => {
+ expect(forwardedResetMatches({ meta: true, control: false }, true)).toBe(true)
+ expect(forwardedResetMatches({ meta: false, control: true }, false)).toBe(true)
+ })
+ it('refuses mac Ctrl+0, off-mac ⌘0, both held, and a signal with no modifiers', () => {
+ expect(forwardedResetMatches({ meta: false, control: true }, true)).toBe(false)
+ expect(forwardedResetMatches({ meta: true, control: false }, false)).toBe(false)
+ expect(forwardedResetMatches({ meta: true, control: true }, true)).toBe(false)
+ expect(forwardedResetMatches({ meta: true, control: true }, false)).toBe(false)
+ expect(forwardedResetMatches(undefined, true)).toBe(false)
+ })
+})
+
+describe('leavesSharedGlyphAtlas (review of #915: the shared atlas is one global font)', () => {
+ it('is true only while the effective size differs from the global one', () => {
+ expect(leavesSharedGlyphAtlas(13, 13)).toBe(false)
+ expect(leavesSharedGlyphAtlas(15, 13)).toBe(true)
+ expect(leavesSharedGlyphAtlas(12, 13)).toBe(true)
+ })
+})
diff --git a/src/renderer/terminal/terminal-font-zoom.ts b/src/renderer/terminal/terminal-font-zoom.ts
index 1cdc13e6d..3d79ad392 100644
--- a/src/renderer/terminal/terminal-font-zoom.ts
+++ b/src/renderer/terminal/terminal-font-zoom.ts
@@ -145,6 +145,34 @@ export function withTerminalFontSize<T extends { fontSize: number }>(visual: T,
return size === visual.fontSize ? visual : { ...visual, fontSize: size }
}
+/**
+ * PURE. Is a FORWARDED desktop ⌘/Ctrl+0 the terminal-font reset chord? Main claims `Digit0` with
+ * `meta || control` (either, or both) for canvas zoom-to-100%, so it forwards the modifiers and this
+ * applies `terminalFontZoomChord`'s own primary rule to them — exactly ⌘ on macOS, exactly Ctrl
+ * elsewhere. Without it a mac Ctrl+0 cleared the override on the desktop while the browser path
+ * (`terminalFontZoomChord`) refused it. Absent modifiers are "not a reset": the caller falls back
+ * to the pre-#915 behaviour.
+ */
+export function forwardedResetMatches(
+ mods: { meta: boolean; control: boolean } | undefined,
+ isMac: boolean
+): boolean {
+ if (!mods) return false
+ return isMac ? mods.meta && !mods.control : mods.control && !mods.meta
+}
+
+/**
+ * PURE. Does this terminal's effective font size leave the SHARED glyph atlas? The shared renderer
+ * (`terminalGpuRendering: 'shared'`, canvas/SharedGlyphLayer.tsx) rasterizes ONE atlas for the
+ * GLOBAL font and fixes its cell geometry for the context's lifetime; a grid cannot change its cell
+ * after `register`. A node rendering at its own size therefore cannot draw there at all — it is
+ * held off the shared canvas and paints its own pixels (the same "must be opaque" path a stacked or
+ * dragged node takes), and rejoins once the override is cleared.
+ */
+export function leavesSharedGlyphAtlas(effectiveFontSize: number, globalFontSize: number): boolean {
+ return effectiveFontSize !== globalFontSize
+}
+
/** 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'
diff --git a/src/renderer/terminal/terminal-font-zoom.wiring.test.ts b/src/renderer/terminal/terminal-font-zoom.wiring.test.ts
index 279174e85..2da26a24e 100644
--- a/src/renderer/terminal/terminal-font-zoom.wiring.test.ts
+++ b/src/renderer/terminal/terminal-font-zoom.wiring.test.ts
@@ -112,6 +112,16 @@ describe('terminal font zoom — key wiring', () => {
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,/)
})
})
diff --git a/src/shared/types.ts b/src/shared/types.ts
index fd549ae77..557d3e264 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1703,6 +1703,14 @@ export interface SpeechSettings {
export type TerminalCursorStyle = 'block' | 'bar' | 'underline'
export type TerminalCursorInactiveStyle = TerminalCursorStyle | 'outline' | 'none'
+/** The primary modifiers of a forwarded desktop ⌘/Ctrl+0 (issue #915): the renderer applies the
+ * per-platform terminal-font-reset predicate to them. Optional on the listener because the Server
+ * Edition stub never fires and an absent value must read as "not a font reset". */
+export interface ZoomActualSizeModifiers {
+ meta: boolean
+ control: boolean
+}
+
/** User-configurable application settings (settings.json). */
export interface Settings {
fontSize: number
@@ -4171,7 +4179,7 @@ export interface NodeTerminalApi {
/** Fires when the user presses Cmd/Ctrl+0 (zoom the canvas back to 100%). Desktop only: the
* key is intercepted in main because Electron's default View menu owns the accelerator. In the
* Server Edition the renderer's own keydown handler sees the key and this is a no-op stub. */
- onZoomActualSize(listener: () => void): () => void
+ onZoomActualSize(listener: (mods?: ZoomActualSizeModifiers) => void): () => void
/** Native View menu → Snap to Grid toggle. Returns unsubscribe. */
onToggleAutoAlign(listener: () => void): () => void
/** Native View menu → Fit View. Returns unsubscribe. */