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): maximize a node to fill the viewport (resize + reflow)

enese379c1adc27b
diff --git a/src/renderer/lib/nodeMaximize.ts b/src/renderer/lib/nodeMaximize.ts
new file mode 100644
index 000000000..a4e0f12af
--- /dev/null
+++ b/src/renderer/lib/nodeMaximize.ts
@@ -0,0 +1,46 @@
+// Maximize-to-viewport geometry (issue #399): the rect a node should occupy to fill the visible
+// canvas. Pure on purpose — the toggle itself is a workspace transform (`maximizeNodeToRect` /
+// `restoreMaximizedNode` in state/workspace.ts); this module only answers "which flow-space rect
+// is the viewport right now?".
+//
+// Deliberately NOT `viewportForRect` run backwards: that helper moves the CAMERA onto a node, and
+// the whole point of maximize is the opposite — the camera stays put and the NODE is resized, so
+// the terminal reflows and actually gains rows (canvas zoom is a CSS transform; magnifying an
+// 80×24 never shows one extra line).
+
+import type { Viewport } from '@xyflow/system'
+
+/** Screen-pixel margin kept around a maximized node, so the canvas is still visibly behind it. */
+export const NODE_MAXIMIZE_MARGIN_PX = 24
+
+export interface FlowRect {
+ x: number
+ y: number
+ width: number
+ height: number
+}
+
+/**
+ * The visible canvas area in FLOW coordinates, inset by `marginPx` (screen px). Null when the
+ * container has no usable size yet (first tick after mount) or is too small for a node to mean
+ * anything — the caller must then leave the node alone, exactly like `viewportForRect`'s null.
+ */
+export function maximizeTargetRect(
+ viewport: Viewport,
+ containerWidth: number,
+ containerHeight: number,
+ marginPx: number = NODE_MAXIMIZE_MARGIN_PX
+): FlowRect | null {
+ if (!(viewport.zoom > 0)) return null
+ const innerW = containerWidth - marginPx * 2
+ const innerH = containerHeight - marginPx * 2
+ // Below this the "maximized" node would be smaller than a default terminal's header — refuse
+ // rather than produce a comic-strip node the user then has to fish the restore button out of.
+ if (!(innerW >= 120) || !(innerH >= 120)) return null
+ return {
+ x: (marginPx - viewport.x) / viewport.zoom,
+ y: (marginPx - viewport.y) / viewport.zoom,
+ width: innerW / viewport.zoom,
+ height: innerH / viewport.zoom
+ }
+}
diff --git a/src/renderer/lib/ui-visibility.test.ts b/src/renderer/lib/ui-visibility.test.ts
index 6fd48c996..2e9198a2e 100644
--- a/src/renderer/lib/ui-visibility.test.ts
+++ b/src/renderer/lib/ui-visibility.test.ts
@@ -27,7 +27,7 @@ describe('hideable inventories', () => {
'markdown-view', 'refresh-terminal'
])
expect(HIDEABLE_HEADER_BUTTONS.map((r) => r.id)).toEqual([
- 'refresh', 'mic', 'ai-name', 'comments', 'hide-fanout', 'tidy-fanout'
+ 'maximize', 'refresh', 'mic', 'ai-name', 'comments', 'hide-fanout', 'tidy-fanout'
])
})
it('gives every entry a user-facing label', () => {
diff --git a/src/renderer/lib/ui-visibility.ts b/src/renderer/lib/ui-visibility.ts
index ed9b8307f..0c19bb448 100644
--- a/src/renderer/lib/ui-visibility.ts
+++ b/src/renderer/lib/ui-visibility.ts
@@ -30,6 +30,7 @@ export const HIDEABLE_MENU_ITEMS: readonly HideableRow[] = [
/** Hideable terminal node header buttons, in header order. */
export const HIDEABLE_HEADER_BUTTONS: readonly HideableRow[] = [
+ { id: 'maximize', label: 'Maximize' },
{ id: 'refresh', label: 'Refresh' },
{ id: 'mic', label: 'Dictate' },
{ id: 'ai-name', label: 'Name with AI' },
diff --git a/src/renderer/nodes/DiffNode.tsx b/src/renderer/nodes/DiffNode.tsx
index b3467a9a5..ebf8caade 100644
--- a/src/renderer/nodes/DiffNode.tsx
+++ b/src/renderer/nodes/DiffNode.tsx
@@ -10,6 +10,7 @@ import { sshFs } from '../terminal/ssh-fs'
import { useSession } from '../session/session'
import type { CanvasNode } from '../state/workspace'
import { tooLargeSize, formatBytes } from '@shared/fsLimits'
+import { MaximizeButton } from './MaximizeButton'
/**
* A Monaco diff editor node for a changed file. Staged diff = HEAD vs index;
@@ -139,6 +140,7 @@ export function DiffNode({ id, data, selected }: NodeProps<CanvasNode>) {
<NodeResizer minWidth={NODE_MIN_SIZES.diff.width} minHeight={NODE_MIN_SIZES.diff.height} isVisible={selected} color={data.color} />
<div className="term-node__header">
+ <MaximizeButton id={id} maximized={!!data.premaxRect} />
<span className="term-node__title-text" title={`${rel} — ${commitOid ? commitOid.slice(0, 7) : staged ? 'staged' : 'working'}`}>
{rel.split('/').pop()}
<span className="diff-node__tag">{commitOid ? commitOid.slice(0, 7) : staged ? 'staged' : 'changes'}</span>
diff --git a/src/renderer/nodes/EditorNode.tsx b/src/renderer/nodes/EditorNode.tsx
index 7ebce8d33..29a03dd69 100644
--- a/src/renderer/nodes/EditorNode.tsx
+++ b/src/renderer/nodes/EditorNode.tsx
@@ -14,6 +14,7 @@ import { tooLargeSize, formatBytes } from '@shared/fsLimits'
import { hintLabel } from '@shared/platform-utils'
import { chipFor, commandTooltip } from '../lib/keybindingOverrides'
import { pdfBlobUrl } from '../lib/pdfBlob'
+import { MaximizeButton } from './MaximizeButton'
// Image extensions get a visual preview instead of the Monaco text editor.
const IMAGE_MIME: Record<string, string> = {
@@ -262,6 +263,7 @@ export function EditorNode({ id, data, selected }: NodeProps<CanvasNode>) {
/>
<div className="term-node__header">
+ <MaximizeButton id={id} maximized={!!data.premaxRect} />
<span className="term-node__title-text" title={filePath}>
{fileName}
{!isImage && !isPdf && dirty ? ' ●' : ''}
diff --git a/src/renderer/nodes/MaximizeButton.tsx b/src/renderer/nodes/MaximizeButton.tsx
new file mode 100644
index 000000000..d179b7aeb
--- /dev/null
+++ b/src/renderer/nodes/MaximizeButton.tsx
@@ -0,0 +1,61 @@
+// The macOS-style green maximize toggle in a node's header (issue #399). One click resizes the
+// NODE to fill the visible canvas — a real resize through the normal resize path, so a terminal
+// reflows and gains rows (the camera never moves; canvas zoom is a CSS transform and magnifying
+// an 80×24 shows no extra line). The second click restores the exact previous rect. Shared by the
+// terminal, editor and diff nodes; the transforms live in state/workspace.ts so grouped nodes
+// re-fit their ancestor frames in the same tick.
+
+import { useReactFlow, useStoreApi } from '@xyflow/react'
+import { Tooltip } from '../components/Tooltip'
+import { markWorkspaceDirty } from '../state/workspaceDirty'
+import { maximizeNodeToRect, restoreMaximizedNode, type CanvasNode } from '../state/workspace'
+import { maximizeTargetRect } from '../lib/nodeMaximize'
+
+export function MaximizeButton({ id, maximized }: { id: string; maximized: boolean }) {
+ const { setNodes, getViewport } = useReactFlow()
+ const store = useStoreApi()
+
+ const toggle = () => {
+ setNodes((ns) => {
+ const flow = ns as CanvasNode[]
+ if (maximized) return restoreMaximizedNode(flow, id)
+ const { width, height } = store.getState()
+ const rect = maximizeTargetRect(getViewport(), width, height)
+ return rect ? maximizeNodeToRect(flow, id, rect) : ns
+ })
+ // Direct setNodes bypasses handleNodesChange, so the project must be marked dirty
+ // explicitly (same rule as Canvas's onApplyMutation) — else the new rect is lost on restart.
+ markWorkspaceDirty()
+ }
+
+ return (
+ <Tooltip
+ label={maximized ? 'Restore previous size and position' : 'Maximize — fill the visible canvas'}
+ >
+ <button
+ className="term-node__maximize nodrag"
+ aria-label={maximized ? 'Restore node size' : 'Maximize node'}
+ aria-pressed={maximized}
+ onClick={(e) => {
+ e.stopPropagation()
+ toggle()
+ }}
+ >
+ {/* macOS traffic-light arrows: outward when it will maximize, inward when it will restore. */}
+ <svg viewBox="0 0 12 12" aria-hidden="true">
+ {maximized ? (
+ <>
+ <path d="M 5.2 1.6 L 5.2 6.8 L 0 6.8 Z" />
+ <path d="M 6.8 10.4 L 6.8 5.2 L 12 5.2 Z" />
+ </>
+ ) : (
+ <>
+ <path d="M 1.6 6.8 L 1.6 1.6 L 6.8 1.6 Z" />
+ <path d="M 10.4 5.2 L 10.4 10.4 L 5.2 10.4 Z" />
+ </>
+ )}
+ </svg>
+ </button>
+ </Tooltip>
+ )
+}
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 2c3166d5f..be20c3a64 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -183,6 +183,7 @@ import { hintLabel, isWindowsPlatform, isMacPlatform } from '@shared/platform-ut
import { ColumnPill } from '../components/kanban/ColumnPill'
import { BoardLogPanel } from '../components/kanban/BoardLogPanel'
import { AgentMascot } from './AgentMascot'
+import { MaximizeButton } from './MaximizeButton'
import { connectHostAttachment } from '../lib/sshAttachments'
/** Which physical modifier the registry's abstract `Cmd` resolves to for the find-bar chord. */
@@ -4437,6 +4438,9 @@ export function TerminalNode({
))}
</div>
)}
+ {!collapsed && !isHidden('maximize', hiddenHeaderButtons) && (
+ <MaximizeButton id={id} maximized={!!data.premaxRect} />
+ )}
{editingTitle ? (
<input
className="term-node__title nodrag"
diff --git a/src/renderer/state/workspace.maximize.test.ts b/src/renderer/state/workspace.maximize.test.ts
new file mode 100644
index 000000000..f76da3391
--- /dev/null
+++ b/src/renderer/state/workspace.maximize.test.ts
@@ -0,0 +1,164 @@
+import { describe, it, expect } from 'vitest'
+import {
+ flowToNodeStates,
+ maximizeNodeToRect,
+ nodeStatesToFlow,
+ restoreMaximizedNode
+} from './workspace'
+import type { CanvasNode } from './workspace'
+import { maximizeTargetRect } from '../lib/nodeMaximize'
+
+// Maximize-to-viewport (issue #399): the node is RESIZED to the visible canvas and toggles back
+// to the exact rect it had — the restore is the half users cannot do by hand, so it is the half
+// these tests pin hardest.
+
+const term = (
+ id: string,
+ pos: { x: number; y: number },
+ size = { width: 320, height: 240 },
+ extra: Partial<CanvasNode> = {}
+): CanvasNode =>
+ ({
+ id,
+ type: 'terminal',
+ position: pos,
+ width: size.width,
+ height: size.height,
+ style: { width: size.width, height: size.height },
+ data: { title: id, color: '#fff', group: null },
+ ...extra
+ }) as CanvasNode
+
+const group = (id: string, pos: { x: number; y: number }, size = { width: 600, height: 500 }): CanvasNode =>
+ ({
+ id,
+ type: 'group',
+ position: pos,
+ width: size.width,
+ height: size.height,
+ style: { width: size.width, height: size.height },
+ data: { title: id, color: '#fff', group: null }
+ }) as CanvasNode
+
+const RECT = { x: 1000, y: 2000, width: 1600, height: 900 }
+
+describe('maximizeNodeToRect', () => {
+ it('resizes a top-level node to the rect and remembers the previous rect', () => {
+ const nodes = [term('a', { x: 40, y: 60 })]
+ const next = maximizeNodeToRect(nodes, 'a', RECT)
+ const a = next.find((n) => n.id === 'a')!
+ expect(a.position).toEqual({ x: 1000, y: 2000 })
+ expect(a.width).toBe(1600)
+ expect(a.height).toBe(900)
+ expect(a.style).toMatchObject({ width: 1600, height: 900 })
+ expect(a.data.premaxRect).toEqual({ x: 40, y: 60, width: 320, height: 240 })
+ })
+
+ it('drops the stale measurement so a same-tick persist serializes the NEW size', () => {
+ const nodes = [term('a', { x: 0, y: 0 }, { width: 320, height: 240 }, {
+ measured: { width: 320, height: 240 }
+ })]
+ const next = maximizeNodeToRect(nodes, 'a', RECT)
+ const state = flowToNodeStates(next).find((s) => s.id === 'a')!
+ expect(state.size).toEqual({ width: 1600, height: 900 })
+ })
+
+ it('is a no-op for unknown ids, group frames, collapsed nodes and already-maximized nodes', () => {
+ const collapsed = term('c', { x: 0, y: 0 })
+ collapsed.data = { ...collapsed.data, collapsed: true }
+ const maxed = maximizeNodeToRect([term('m', { x: 0, y: 0 })], 'm', RECT)
+ expect(maximizeNodeToRect([term('a', { x: 0, y: 0 })], 'nope', RECT)).toEqual([
+ term('a', { x: 0, y: 0 })
+ ])
+ expect(maximizeNodeToRect([group('g', { x: 0, y: 0 })], 'g', RECT)[0].width).toBe(600)
+ expect(maximizeNodeToRect([collapsed], 'c', RECT)[0].data.premaxRect).toBeUndefined()
+ expect(maximizeNodeToRect(maxed, 'm', RECT)).toEqual(maxed)
+ })
+
+ it('writes a grouped node parent-relative and re-fits the frame around it', () => {
+ const g = group('g', { x: 100, y: 100 })
+ const child = term('a', { x: 50, y: 80 }, { width: 320, height: 240 }, { parentId: 'g', extent: 'parent' })
+ const next = maximizeNodeToRect([g, child], 'a', RECT)
+ const a = next.find((n) => n.id === 'a')!
+ const frame = next.find((n) => n.id === 'g')!
+ // Absolute position must equal the rect; relative = rect − frame origin (post-fit).
+ expect(frame.position.x + a.position.x).toBeCloseTo(RECT.x)
+ expect(frame.position.y + a.position.y).toBeCloseTo(RECT.y)
+ // The frame now contains the maximized child (extent:'parent' cannot clamp it).
+ expect(frame.position.x).toBeLessThanOrEqual(RECT.x)
+ expect((frame.width as number)!).toBeGreaterThanOrEqual(RECT.width)
+ })
+})
+
+describe('restoreMaximizedNode', () => {
+ it('round-trips a top-level node back to the exact previous rect', () => {
+ const nodes = [term('a', { x: 40, y: 60 })]
+ const restored = restoreMaximizedNode(maximizeNodeToRect(nodes, 'a', RECT), 'a')
+ const a = restored.find((n) => n.id === 'a')!
+ expect(a.position).toEqual({ x: 40, y: 60 })
+ expect(a.width).toBe(320)
+ expect(a.height).toBe(240)
+ expect(a.data.premaxRect).toBeUndefined()
+ expect(a.data.expandedHeight).toBe(240)
+ })
+
+ it('round-trips a grouped node: same absolute rect, frame re-fitted back down', () => {
+ const g = group('g', { x: 100, y: 100 })
+ const other = term('b', { x: 30, y: 70 }, { width: 200, height: 150 }, { parentId: 'g', extent: 'parent' })
+ const child = term('a', { x: 260, y: 80 }, { width: 320, height: 240 }, { parentId: 'g', extent: 'parent' })
+ const before = [g, other, child]
+ const restored = restoreMaximizedNode(maximizeNodeToRect(before, 'a', RECT), 'a')
+ const a = restored.find((n) => n.id === 'a')!
+ // The OTHER child's absolute position never moved across the whole cycle.
+ const frame = restored.find((n) => n.id === 'g')!
+ const b = restored.find((n) => n.id === 'b')!
+ expect(frame.position.x + b.position.x).toBeCloseTo(100 + 30)
+ expect(frame.position.y + b.position.y).toBeCloseTo(100 + 70)
+ expect(frame.position.x + a.position.x).toBeCloseTo(100 + 260)
+ expect(frame.position.y + a.position.y).toBeCloseTo(100 + 80)
+ expect(a.width).toBe(320)
+ expect(a.height).toBe(240)
+ })
+
+ it('is a no-op when the node is not maximized', () => {
+ const nodes = [term('a', { x: 1, y: 2 })]
+ expect(restoreMaximizedNode(nodes, 'a')).toEqual(nodes)
+ })
+})
+
+describe('premaxRect persistence', () => {
+ it('survives the flow → state → flow round trip', () => {
+ const maxed = maximizeNodeToRect([term('a', { x: 40, y: 60 })], 'a', RECT)
+ const back = nodeStatesToFlow(flowToNodeStates(maxed))
+ expect(back[0].data.premaxRect).toEqual({ x: 40, y: 60, width: 320, height: 240 })
+ // ...and the restore still works on the rehydrated node.
+ const restored = restoreMaximizedNode(back as CanvasNode[], 'a')
+ expect(restored[0].position).toEqual({ x: 40, y: 60 })
+ expect(restored[0].width).toBe(320)
+ })
+})
+
+describe('maximizeTargetRect', () => {
+ it('converts the visible pane to flow coordinates, inset by the margin', () => {
+ // zoom 1, camera at origin: flow == screen.
+ expect(maximizeTargetRect({ x: 0, y: 0, zoom: 1 }, 1200, 800, 24)).toEqual({
+ x: 24,
+ y: 24,
+ width: 1152,
+ height: 752
+ })
+ // zoom 0.5, panned: flow rect is twice the screen size, offset by the camera.
+ expect(maximizeTargetRect({ x: -100, y: 50, zoom: 0.5 }, 1200, 800, 24)).toEqual({
+ x: (24 + 100) / 0.5,
+ y: (24 - 50) / 0.5,
+ width: 1152 / 0.5,
+ height: 752 / 0.5
+ })
+ })
+
+ it('refuses a container that has no usable size', () => {
+ expect(maximizeTargetRect({ x: 0, y: 0, zoom: 1 }, 0, 0, 24)).toBeNull()
+ expect(maximizeTargetRect({ x: 0, y: 0, zoom: 1 }, 160, 800, 24)).toBeNull()
+ expect(maximizeTargetRect({ x: 0, y: 0, zoom: 0 }, 1200, 800, 24)).toBeNull()
+ })
+})
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index 228f2a6da..aa7b0e970 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -71,6 +71,11 @@ export interface NodeData {
hideFanout?: boolean
/** Expanded height to restore when un-collapsing (kept out of the persisted size). */
expandedHeight?: number
+ /**
+ * Set while the node is maximized to the viewport (issue #399): the ROOT-space rect the
+ * restore toggle gives back. Persisted — see CanvasNodeState.premaxRect.
+ */
+ premaxRect?: { x: number; y: number; width: number; height: number }
/** One-shot command run once when the terminal first opens (not persisted). */
initialCommand?: string
/**
@@ -1186,6 +1191,89 @@ function fitAncestorChain(nodes: CanvasNode[], groupId: string | undefined): Can
return next
}
+/**
+ * Maximize (issue #399): resize `nodeId` to occupy `rect` — the visible viewport in ROOT/flow
+ * coordinates, computed by the caller from the camera (`maximizeTargetRect`) — remembering the
+ * node's own rect in `data.premaxRect` so `restoreMaximizedNode` can put everything back. This is
+ * a real resize, not a camera move: the node goes through its normal resize path, so a terminal
+ * reflows and the pty gets its new cols/rows.
+ *
+ * Grouped nodes work too: the new position is written parent-relative and every ancestor frame is
+ * re-fitted (`fitAncestorChain`) in the SAME transform — `extent:'parent'` would otherwise clamp a
+ * child bigger than its frame into an inverted range (the snap `groupSelectedNodes` documents).
+ *
+ * Refused (returned unchanged): unknown id, a group frame (maximizing the container would drag its
+ * whole subtree), a collapsed node (header-only; expand first), and a node already maximized.
+ */
+export function maximizeNodeToRect(
+ nodes: CanvasNode[],
+ nodeId: string,
+ rect: { x: number; y: number; width: number; height: number }
+): CanvasNode[] {
+ const node = nodes.find((n) => n.id === nodeId)
+ if (!node || node.type === 'group' || node.data.collapsed || node.data.premaxRect) return nodes
+ // The remembered position is ROOT-space, not parent-relative: re-fitting the frame around the
+ // maximized child MOVES the frame's origin (it hugs), so a parent-relative restore would come
+ // back a few px off — and root-space also survives the frame being ungrouped meanwhile.
+ const root = rootPosition(node, nodes)
+ const premaxRect = {
+ x: root.x,
+ y: root.y,
+ width: nodeW(node) || (node.style?.width as number) || 0,
+ height: nodeH(node) || (node.style?.height as number) || 0
+ }
+ if (!(premaxRect.width > 0) || !(premaxRect.height > 0)) return nodes
+ // rect is root-space; a grouped node's position is relative to its frame, so subtract the
+ // ancestor origins (root position minus own offset = the parent chain's origin).
+ const originX = root.x - node.position.x
+ const originY = root.y - node.position.y
+ const next = nodes.map((n) =>
+ n.id === nodeId
+ ? {
+ ...n,
+ position: { x: rect.x - originX, y: rect.y - originY },
+ width: rect.width,
+ height: rect.height,
+ style: { ...n.style, width: rect.width, height: rect.height },
+ // Drop the stale measurement in the same tick: flowToNodeStates prefers `measured` over
+ // `width`/`height`, and a commit racing the re-measure would persist the OLD size.
+ measured: undefined,
+ data: { ...n.data, premaxRect, expandedHeight: rect.height }
+ }
+ : n
+ )
+ return fitAncestorChain(next, node.parentId)
+}
+
+/**
+ * The toggle's second click: give the node back the rect `maximizeNodeToRect` remembered — the
+ * exact canvas spot it occupied, converted from root-space into wherever its parent chain sits
+ * now — and re-fit the ancestor frames back down around it. No-op when the node is missing or
+ * not maximized.
+ */
+export function restoreMaximizedNode(nodes: CanvasNode[], nodeId: string): CanvasNode[] {
+ const node = nodes.find((n) => n.id === nodeId)
+ const prev = node?.data.premaxRect
+ if (!node || !prev) return nodes
+ const root = rootPosition(node, nodes)
+ const originX = root.x - node.position.x
+ const originY = root.y - node.position.y
+ const next = nodes.map((n) =>
+ n.id === nodeId
+ ? {
+ ...n,
+ position: { x: prev.x - originX, y: prev.y - originY },
+ width: prev.width,
+ height: prev.height,
+ style: { ...n.style, width: prev.width, height: prev.height },
+ measured: undefined,
+ data: { ...n.data, premaxRect: undefined, expandedHeight: prev.height }
+ }
+ : n
+ )
+ return fitAncestorChain(next, node.parentId)
+}
+
/**
* Wraps nodes that share ONE container in a new group frame. The members may themselves be
* frames, so this is how a nested tree is built. The frame is created beside its members inside
@@ -1514,6 +1602,7 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {
collapsed,
hideFanout: n.hideFanout,
expandedHeight: n.size.height,
+ premaxRect: n.premaxRect,
shell: n.shell,
cwd: n.cwd,
text: n.text,
@@ -1604,7 +1693,8 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {
ssh: n.data.ssh,
sshRemoteTmux: n.data.sshRemoteTmux,
sshFs: n.data.sshFs,
- worktree: n.data.worktree
+ worktree: n.data.worktree,
+ premaxRect: n.data.premaxRect
}
})
}
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 2377571ef..a35fc5807 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -1255,6 +1255,37 @@ body,
flex-shrink: 0;
}
+/* Maximize toggle (issue #399): the macOS green traffic light, next to the color dot. The arrow
+ glyphs appear on header hover — same behavior as the real thing. */
+.term-node__maximize {
+ width: 12px;
+ height: 12px;
+ border-radius: 50%;
+ border: none;
+ padding: 0;
+ background: #28c840;
+ cursor: pointer;
+ flex-shrink: 0;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.term-node__maximize svg {
+ width: 8px;
+ height: 8px;
+ fill: rgba(0, 0, 0, 0.55);
+ opacity: 0;
+}
+
+.term-node__header:hover .term-node__maximize svg {
+ opacity: 1;
+}
+
+.term-node__maximize:hover {
+ background: #2fd948;
+}
+
.term-node__title {
flex: 1;
background: transparent;
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 64e771ab8..01c5a2a07 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -377,6 +377,14 @@ export interface CanvasNodeState {
commitOid?: string
/** group-only: when bound, the git worktree this group works in. */
worktree?: GroupWorktree
+ /**
+ * Set while the node is maximized to fill the viewport (issue #399): the rect to give back on
+ * the toggle's second click — the node's ROOT-space (absolute canvas) position plus its size.
+ * Absent = not maximized. Persisted so the restore survives a reload. Root-space on purpose:
+ * maximizing a grouped node re-fits (and thereby moves) its frame, so a parent-relative rect
+ * would restore a few px off — and root-space also survives the frame being ungrouped meanwhile.
+ */
+ premaxRect?: { x: number; y: number; width: number; height: number }
}
/**