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(settings): UI scale for high-DPI displays (#299)

enesb14f38235608
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 376994077..f965a61cf 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -1,5 +1,6 @@
-import { contextBridge, ipcRenderer, webUtils } from 'electron'
+import { contextBridge, ipcRenderer, webFrame, webUtils } from 'electron'
import { IPC } from '../shared/ipc'
+import { resolveUiScale } from '../shared/ui-scale'
import type {
CanvasMutation,
CanvasState,
@@ -707,6 +708,9 @@ const api: NodeTerminalApi = {
closeWindow: () => ipcRenderer.send(IPC.appCloseWindow),
focusWindow: () => ipcRenderer.send(IPC.appFocusWindow),
setBadgeCount: (count) => ipcRenderer.send(IPC.appSetBadge, count),
+ // Page zoom for the UI-scale setting (issue #299). Re-clamped here because the value originates
+ // in hand-editable settings.json and this is the boundary; no IPC — webFrame acts on this window.
+ setUiZoomFactor: (factor) => webFrame.setZoomFactor(resolveUiScale(factor)),
// Absolute path of a dropped/picked File (File.path was removed in Electron 30+).
getPathForFile: (file: File) => webUtils.getPathForFile(file),
userDataDir: () => ipcRenderer.invoke(IPC.appUserDataDir),
diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx
index 49b91acc6..dcaf01fb7 100644
--- a/src/renderer/App.tsx
+++ b/src/renderer/App.tsx
@@ -14,6 +14,7 @@ import { useSharedGlyph } from './canvas/SharedGlyphLayer'
// between the two coordinators.
import { resolveTerminalRenderer } from '../shared/webgl'
import { resolveTerminalTheme } from './terminal/themes'
+import { resolveUiScale } from '../shared/ui-scale'
import { useAppTheme } from './state/useAppTheme'
export default function App() {
@@ -50,6 +51,17 @@ export default function App() {
document.documentElement.dataset.theme = appTheme
}, [appTheme])
+ // Apply the UI scale as page zoom (issue #299 — 4K readability; the why-page-zoom write-up
+ // lives in shared/ui-scale.ts). Gated on `hydrated` so boot doesn't flash-reset a scaled window
+ // to the 100% default before settings.json has been read — Electron restores the zoom it
+ // persisted per origin, and asserting the default over it would visibly bounce the whole UI.
+ // On the Server Edition `setUiZoomFactor` is a documented no-op (the browser owns page zoom).
+ const uiScale = useSettings((s) => s.settings.uiScale)
+ const settingsHydrated = useSettings((s) => s.hydrated)
+ useEffect(() => {
+ if (settingsHydrated) window.nodeTerminal.setUiZoomFactor(resolveUiScale(uiScale))
+ }, [uiScale, settingsHydrated])
+
// Keep the view-mode store's default in sync with the Settings choice, so projects the user
// hasn't explicitly toggled follow it (and flip live when the setting changes).
const defaultView = useSettings((s) => s.settings.defaultProjectView)
diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.ts
index 5d3b67553..0a9def0aa 100644
--- a/src/renderer/bridge/stubs.ts
+++ b/src/renderer/bridge/stubs.ts
@@ -436,6 +436,10 @@ export function buildStubApi(): Omit<
}
},
setBadgeCount: noop,
+ // UI scale is page zoom, and a browser page cannot set its own — the browser already owns the
+ // identical mechanism (Cmd/Ctrl+±, persisted per site). Intentionally inert; the Settings row
+ // is disabled with this reason on the Server Edition (AppearanceSection's browser branch).
+ setUiZoomFactor: noop,
getPathForFile: (): string => '',
notify: async (payload: NotifyPayload): Promise<'shown' | 'failed' | 'skipped'> => {
if (typeof Notification !== 'undefined' && Notification.permission === 'granted') {
diff --git a/src/renderer/components/settings/sections/AppearanceSection.tsx b/src/renderer/components/settings/sections/AppearanceSection.tsx
index f9217191c..108b6669f 100644
--- a/src/renderer/components/settings/sections/AppearanceSection.tsx
+++ b/src/renderer/components/settings/sections/AppearanceSection.tsx
@@ -12,6 +12,9 @@ import {
type HideableRow
} from '@renderer/lib/ui-visibility'
import { cn } from '@renderer/ui/cn'
+import { Select } from '@renderer/ui/Select'
+import { isBrowserRuntime } from '@renderer/bridge/runtime'
+import { UI_SCALE_CHOICES, resolveUiScale, uiScaleLabel } from '@shared/ui-scale'
import { SectionReset } from '../SectionReset'
import { APPEARANCE_RESET_KEYS } from '@renderer/lib/settingsReset'
@@ -20,6 +23,10 @@ const ROWS = {
title: 'Appearance',
keywords: ['appearance', 'theme', 'light', 'dark', 'mode', 'colour', 'color', 'chrome']
},
+ uiScale: {
+ title: 'UI scale',
+ keywords: ['ui', 'scale', 'zoom', 'size', 'text', 'bigger', 'larger', '4k', 'hidpi', 'dpi', 'display', 'readability']
+ },
accent: { title: 'Accent', keywords: ['accent', 'color', 'theme', 'appearance'] },
windowTitle: {
title: 'Window title',
@@ -95,6 +102,54 @@ function VisibilityToggles({
)
}
+/** UI scale (issue #299) — page zoom for the whole app chrome; see shared/ui-scale.ts for the
+ * mechanism decision. The row stays visible but DISABLED on the Server Edition (a hidden row
+ * teaches nothing — the house rule the SSH-worktree affordances follow): a browser page cannot
+ * set its own page zoom, and the browser's Cmd/Ctrl+± already does the identical thing. */
+function UiScaleRow(): React.JSX.Element {
+ const uiScale = useSettings((s) => s.settings.uiScale)
+ const update = useSettings((s) => s.update)
+ const inBrowser = isBrowserRuntime()
+ const resolved = resolveUiScale(uiScale)
+ // A hand-edited between-step value (1.15, say) is honoured by the applier, so the select must
+ // show it rather than silently displaying the nearest preset it would overwrite on next change.
+ const choices: number[] = UI_SCALE_CHOICES.includes(resolved as (typeof UI_SCALE_CHOICES)[number])
+ ? [...UI_SCALE_CHOICES]
+ : [...UI_SCALE_CHOICES, resolved].sort((a, b) => a - b)
+ return (
+ <FieldRow
+ label="UI scale"
+ htmlFor="ui-scale"
+ description={
+ 'Scales the whole application UI — menus, node headers, dialogs, sidebars — like a ' +
+ "browser's page zoom. Terminal text scales with it too: the terminal font size " +
+ '(Settings → Terminal) is multiplied by this, so lower it there if you want terminal ' +
+ 'text to stay as it is.'
+ }
+ note={
+ inBrowser
+ ? "In the browser, use your browser's own page zoom (Cmd/Ctrl and + / −) — it does the same thing and the browser remembers it per site."
+ : undefined
+ }
+ control={
+ <Select
+ id="ui-scale"
+ value={String(resolved)}
+ disabled={inBrowser}
+ aria-label="UI scale"
+ onChange={(e) => update({ uiScale: Number(e.target.value) })}
+ >
+ {choices.map((c) => (
+ <option key={c} value={String(c)}>
+ {uiScaleLabel(c)}
+ </option>
+ ))}
+ </Select>
+ }
+ />
+ )
+}
+
export function AppearanceSection({ isActive }: { isActive: boolean }): React.JSX.Element {
const appTheme = useSettings((s) => s.settings.appTheme)
const accent = useSettings((s) => s.settings.accent)
@@ -128,6 +183,9 @@ export function AppearanceSection({ isActive }: { isActive: boolean }): React.JS
}
/>
</SearchableRow>
+ <SearchableRow {...ROWS.uiScale}>
+ <UiScaleRow />
+ </SearchableRow>
<SearchableRow {...ROWS.accent}>
<div className="flex items-center justify-between gap-4 py-2.5">
<span className="text-[13px] text-text">Accent</span>
diff --git a/src/renderer/lib/settingsReset.ts b/src/renderer/lib/settingsReset.ts
index a99313201..303e6e134 100644
--- a/src/renderer/lib/settingsReset.ts
+++ b/src/renderer/lib/settingsReset.ts
@@ -34,6 +34,7 @@ export const TERMINAL_RESET_KEYS = [
/** The appearance settings the Appearance section owns. */
export const APPEARANCE_RESET_KEYS = [
'appTheme',
+ 'uiScale',
'accent',
'hiddenNodeMenuItems',
'hiddenHeaderButtons',
diff --git a/src/shared/types.ts b/src/shared/types.ts
index e843095aa..601c66f72 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1118,6 +1118,13 @@ export interface Settings {
* takes it from the terminal colour theme, so picking a light terminal theme doesn't leave a
* black window framing it; `dark`/`light` pin it. See renderer/lib/appTheme.ts. */
appTheme: 'auto' | 'dark' | 'light'
+ /** Scale factor for the whole application UI (1 = 100%; issue #299, 4K readability). Applied as
+ * PAGE ZOOM (`webFrame.setZoomFactor`) on desktop, so menus, node headers, dialogs — and
+ * terminal glyphs — all scale together: the terminal font-size setting stays in CSS px, so its
+ * effective size is fontSize × uiScale (the Settings row says so). Hand-editable; every reader
+ * resolves it through `resolveUiScale` (shared/ui-scale.ts), which clamps to [0.5, 2] and maps
+ * garbage to 1. Server Edition: intentionally inert — the browser owns page zoom (Cmd/Ctrl+±). */
+ uiScale: number
/** Reflect the active session in the NATIVE window title ("<node> — <project> — node-terminal"),
* so window-title-based time trackers (ActivityWatch et al.) can tell sessions apart — the same
* thing iTerm2 / Windows Terminal do per tab (issue #414). Opt-in and OFF by default: the title
@@ -1438,6 +1445,7 @@ export const DEFAULT_SETTINGS: Settings = {
// Follows the terminal theme, whose own default is dark — so an install that never touches
// either setting keeps the dark chrome it has always had.
appTheme: 'auto',
+ uiScale: 1,
windowTitleActiveSession: false,
terminalTheme: 'nodeterm-dark',
fontWeight: 400,
@@ -2853,6 +2861,12 @@ export interface NodeTerminalApi {
focusWindow(): void
/** Set the macOS Dock badge to the unread-message count (0 clears it). */
setBadgeCount(count: number): void
+ /** Apply the UI-scale setting as page zoom for THIS window (desktop: `webFrame.setZoomFactor`).
+ * The preload re-clamps through `resolveUiScale` — the value originates in hand-editable
+ * settings.json, and the boundary must not trust the caller to have done it. Server Edition:
+ * documented no-op — a browser page cannot set its own page zoom, and the browser already owns
+ * the identical mechanism (Cmd/Ctrl+±). */
+ setUiZoomFactor(factor: number): void
/** Absolute filesystem path for a dropped/picked File (for drag-into-terminal). */
getPathForFile(file: File): string
/** Absolute writable base dir (Electron userData) for app-managed files like default worktrees. */
diff --git a/src/shared/ui-scale.test.ts b/src/shared/ui-scale.test.ts
new file mode 100644
index 000000000..6d214c070
--- /dev/null
+++ b/src/shared/ui-scale.test.ts
@@ -0,0 +1,56 @@
+import { describe, expect, it } from 'vitest'
+import {
+ UI_SCALE_CHOICES,
+ UI_SCALE_MAX,
+ UI_SCALE_MIN,
+ resolveUiScale,
+ uiScaleLabel
+} from './ui-scale'
+import { DEFAULT_SETTINGS } from './types'
+
+describe('resolveUiScale', () => {
+ it('answers 100% for every non-numeric value (settings.json is hand-editable)', () => {
+ expect(resolveUiScale(undefined)).toBe(1) // every pre-feature settings.json
+ expect(resolveUiScale(null)).toBe(1)
+ expect(resolveUiScale('1.5')).toBe(1)
+ expect(resolveUiScale(NaN)).toBe(1)
+ expect(resolveUiScale(Infinity)).toBe(1)
+ expect(resolveUiScale({})).toBe(1)
+ })
+
+ it('passes in-range values through unchanged, including hand-edited between-step values', () => {
+ for (const c of UI_SCALE_CHOICES) expect(resolveUiScale(c)).toBe(c)
+ expect(resolveUiScale(1.15)).toBe(1.15)
+ })
+
+ it('clamps out-of-range numbers instead of letting them break the window', () => {
+ expect(resolveUiScale(0.01)).toBe(UI_SCALE_MIN)
+ expect(resolveUiScale(50)).toBe(UI_SCALE_MAX)
+ expect(resolveUiScale(-2)).toBe(UI_SCALE_MIN)
+ })
+})
+
+describe('UI_SCALE_CHOICES', () => {
+ it('are ascending, start at 100%, and sit inside the clamp range', () => {
+ expect(UI_SCALE_CHOICES[0]).toBe(1)
+ for (let i = 1; i < UI_SCALE_CHOICES.length; i++)
+ expect(UI_SCALE_CHOICES[i]).toBeGreaterThan(UI_SCALE_CHOICES[i - 1])
+ for (const c of UI_SCALE_CHOICES) expect(resolveUiScale(c)).toBe(c)
+ })
+})
+
+describe('uiScaleLabel', () => {
+ it('renders whole percentages', () => {
+ expect(uiScaleLabel(1)).toBe('100%')
+ expect(uiScaleLabel(1.1)).toBe('110%')
+ expect(uiScaleLabel(1.25)).toBe('125%')
+ expect(uiScaleLabel(2)).toBe('200%')
+ })
+})
+
+describe('DEFAULT_SETTINGS.uiScale', () => {
+ it('is 100% — an upgrade must not rescale anyone who never asked', () => {
+ expect(DEFAULT_SETTINGS.uiScale).toBe(1)
+ expect(resolveUiScale(DEFAULT_SETTINGS.uiScale)).toBe(1)
+ })
+})
diff --git a/src/shared/ui-scale.ts b/src/shared/ui-scale.ts
new file mode 100644
index 000000000..452a8d5c8
--- /dev/null
+++ b/src/shared/ui-scale.ts
@@ -0,0 +1,47 @@
+/**
+ * UI scale for the application chrome — issue #299 (4K / high-DPI readability).
+ *
+ * Mechanism: PAGE ZOOM (`webFrame.setZoomFactor` on desktop), the same thing a browser's
+ * Cmd/Ctrl+± does. Chosen over a rem-based CSS rewrite because styles.css carries ~2,900 px
+ * literals (plus px-valued Tailwind utilities like `text-[13px]`) — a conversion would be a mass
+ * rewrite with visual-regression risk on every surface, while page zoom is coordinate math
+ * Chromium already maintains: React Flow, xterm and Monaco all run under browser zoom today.
+ * Canvas zoom composes independently (it is a CSS transform *inside* the page), and terminal
+ * cols/rows re-fit through the ordinary ResizeObserver → FitAddon path when the CSS-px viewport
+ * changes — the same reflow a window resize causes.
+ *
+ * Trade-off, stated in the Settings copy: page zoom scales TERMINAL glyphs too (the terminal
+ * font-size setting is in CSS px, so the effective glyph size is fontSize × uiScale). The two
+ * settings remain independent *controls*; a user who wants bigger chrome with unchanged terminal
+ * text lowers the terminal font size to compensate. Counter-scaling the terminal font
+ * automatically was rejected: fractional px font sizes render blurry and silently change
+ * cols/rows.
+ *
+ * Server Edition: intentionally inert — a browser page cannot set its own page zoom, and the
+ * browser already owns the identical mechanism (Cmd/Ctrl+±, persisted per site by the browser).
+ * The bridge stub is a documented no-op and the Settings row is disabled with that reason
+ * (VS Code's `window.zoomLevel` draws the same desktop-only line).
+ */
+
+/** The choices the Settings row offers (issue #299's list). A hand-edited value between steps is
+ * honoured, not snapped — the row just shows it as a custom entry. */
+export const UI_SCALE_CHOICES = [1, 1.1, 1.25, 1.5, 1.75, 2] as const
+
+/** Clamp bounds for hand-edited settings.json values: 50% keeps the window usable enough to find
+ * the setting again; 200% is the top of the offered range. */
+export const UI_SCALE_MIN = 0.5
+export const UI_SCALE_MAX = 2
+
+/** Resolve a hand-editable settings value to a safe zoom factor. Anything non-numeric — absent
+ * (every pre-feature settings.json), NaN, Infinity, a string — is 100%; numbers clamp into
+ * [UI_SCALE_MIN, UI_SCALE_MAX] so a wild value can never render the window unusably tiny or
+ * blow it up past recovery. */
+export function resolveUiScale(value: unknown): number {
+ if (typeof value !== 'number' || !Number.isFinite(value)) return 1
+ return Math.min(UI_SCALE_MAX, Math.max(UI_SCALE_MIN, value))
+}
+
+/** "125%" for 1.25 — the Settings row's option labels. */
+export function uiScaleLabel(scale: number): string {
+ return `${Math.round(scale * 100)}%`
+}