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(canvas): "Zoom to 100%" in the command palette

enes00a4d2860ba0
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index edd96d26c..d95763ea4 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -110,6 +110,7 @@ import { markMobileLaunchSeen, shouldShowMobileLaunch } from '../lib/mobileLaunc
import type { DictationTarget } from '../components/DictationOverlay'
import { describeOs, REPO_URL } from '../lib/bugReport'
import { shouldReleasePaneFocus } from '../lib/paneFocus'
+import { viewportAtZoom1 } from '../lib/zoomReset'
import { isSpaceRelease, spacePanKeydown } from '../lib/spacePan'
import { UpdateCard } from '../components/UpdateCard'
import { AnnouncementBanner } from '../components/AnnouncementBanner'
@@ -956,6 +957,30 @@ export function Canvas() {
void fitView({ duration: 300, padding: padding ?? 0.1 })
}, [fitView, getNodes, getNodesBounds])
+ /**
+ * Back to 100%, keeping whatever is in the middle of the screen in the middle.
+ *
+ * Every canvas app has this and ours did not: `Fit view` was the only way to change zoom from a
+ * command, and it lands on whatever the content bounds imply — never on 1. That gap is not only
+ * an ergonomic one. Zoom 1 is the only ratio at which the shared renderer samples the atlas
+ * texel-for-texel, so "is this actually 1?" is a question both users and bug reports need to be
+ * able to answer, and until now the only way was to read the viewport transform in DevTools
+ * (which is exactly how the 2026-08-09 crispness report was finally pinned, at 0.976).
+ *
+ * The anchor is the viewport CENTRE rather than the origin: zooming about the corner throws the
+ * user's work off screen, which is what makes a reset feel like a jump rather than a correction.
+ */
+ const zoomTo100 = useCallback(() => {
+ const wrap = flowWrapRef.current
+ const current = getViewport()
+ const next = viewportAtZoom1(current, {
+ x: (wrap?.clientWidth ?? 0) / 2,
+ y: (wrap?.clientHeight ?? 0) / 2
+ })
+ if (next === current) return
+ void setViewport(next, { duration: 200 })
+ }, [getViewport, setViewport])
+
const activeProjectId = useProjects((s) => s.activeProjectId)
// The ACTIVE session + its presence — what the canvas-sync publisher and onMutation subscriber
// must follow (Task 4). `sessionForProject` / `presenceForProject` are plain, allocation-free
@@ -7356,6 +7381,7 @@ export function Canvas() {
run: () => void connectRemote()
},
{ id: 'fit', label: 'Fit view', icon: <IconFit />, run: fitAll },
+ { id: 'zoom-100', label: 'Zoom to 100%', icon: <IconFit />, run: zoomTo100 },
{ id: 'save', label: 'Save', icon: <IconSave />, run: () => void persist() },
// Hidden when the canvas has no restartable agent node — the row would have nothing to act
// on. `hint` is searchable, so "new model" / "update" find it too.
@@ -7459,7 +7485,8 @@ export function Canvas() {
connectRemote,
addSshTerminal,
hasRestartableAgents,
- restartIdleAgents
+ restartIdleAgents,
+ zoomTo100
])
// Build the palette's command list only when its inputs change — the inline `buildCommands()`
diff --git a/src/renderer/lib/zoomReset.test.ts b/src/renderer/lib/zoomReset.test.ts
new file mode 100644
index 000000000..fbb799510
--- /dev/null
+++ b/src/renderer/lib/zoomReset.test.ts
@@ -0,0 +1,39 @@
+import { describe, expect, it } from 'vitest'
+import { viewportAtZoom1 } from './zoomReset'
+
+const CENTRE = { x: 600, y: 400 }
+
+describe('viewportAtZoom1', () => {
+ it('lands on zoom 1', () => {
+ expect(viewportAtZoom1({ x: -4194.86, y: -1090.16, zoom: 0.976135 }, CENTRE).zoom).toBe(1)
+ })
+
+ it('keeps the world point under the screen CENTRE where it was', () => {
+ // Anchoring on the origin instead would throw the user's work off screen — the difference
+ // between a reset that reads as a correction and one that reads as a jump.
+ const before = { x: -4194.86, y: -1090.16, zoom: 0.976135 }
+ const worldAt = (v: typeof before, s: { x: number; y: number }) => ({
+ x: (s.x - v.x) / v.zoom,
+ y: (s.y - v.y) / v.zoom
+ })
+ const after = viewportAtZoom1(before, CENTRE)
+ expect(worldAt(after, CENTRE).x).toBeCloseTo(worldAt(before, CENTRE).x, 6)
+ expect(worldAt(after, CENTRE).y).toBeCloseTo(worldAt(before, CENTRE).y, 6)
+ })
+
+ it('is a no-op at 1, returning the SAME object so the caller can skip the animation', () => {
+ const v = { x: 10, y: 20, zoom: 1 }
+ expect(viewportAtZoom1(v, CENTRE)).toBe(v)
+ })
+
+ it('refuses a zoom that is not a usable number rather than producing NaN', () => {
+ for (const zoom of [0, -1, NaN, Infinity]) {
+ const v = { x: 10, y: 20, zoom }
+ expect(viewportAtZoom1(v, CENTRE)).toBe(v)
+ }
+ })
+
+ it('works when zoomed IN as well as out', () => {
+ expect(viewportAtZoom1({ x: 100, y: 100, zoom: 2 }, CENTRE).zoom).toBe(1)
+ })
+})
diff --git a/src/renderer/lib/zoomReset.ts b/src/renderer/lib/zoomReset.ts
new file mode 100644
index 000000000..4eaea2d1b
--- /dev/null
+++ b/src/renderer/lib/zoomReset.ts
@@ -0,0 +1,29 @@
+/** A canvas viewport: React Flow's `{ x, y, zoom }`, in screen px and a scale factor. */
+export interface Viewport {
+ x: number
+ y: number
+ zoom: number
+}
+
+/**
+ * The viewport that puts the canvas back at 100% without moving what the user is looking at.
+ *
+ * The anchor is the viewport CENTRE, not the origin: zooming about the corner throws the user's
+ * work off screen, which makes a reset feel like a jump rather than a correction.
+ *
+ * Zoom 1 matters beyond ergonomics — it is the only ratio at which the shared renderer samples the
+ * glyph atlas texel-for-texel, so "am I actually at 1?" is a question both users and bug reports
+ * need to be able to settle. Until this existed the only way was to read the viewport transform in
+ * DevTools, which is how the 2026-08-09 crispness report was finally pinned (at 0.976).
+ *
+ * A zoom that is already 1, or one that is not a usable number, returns the viewport UNCHANGED —
+ * the command is then a no-op rather than a nudge.
+ */
+export function viewportAtZoom1(current: Viewport, centre: { x: number; y: number }): Viewport {
+ const { x, y, zoom } = current
+ if (!Number.isFinite(zoom) || zoom <= 0 || zoom === 1) return current
+ // The world point under the screen centre, held fixed across the change.
+ const worldX = (centre.x - x) / zoom
+ const worldY = (centre.y - y) / zoom
+ return { x: centre.x - worldX, y: centre.y - worldY, zoom: 1 }
+}