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
feat(canvas): minimize button on the minimap
review491d58af852f
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 8552a5f2c..6af6624f2 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -1,6 +1,7 @@import { reportTextDelivery } from '../lib/textDelivery'import { TEXT_NOT_SUBMITTED } from '@shared/text-delivery'import { VisibleMiniMap } from './VisibleMiniMap'+import { MinimapDock } from './MinimapDock'import { keepGlassBlurWhileMoving } from '../lib/glassContrast'import { LINK_ENDPOINT_NOT_FOUND } from '@shared/canvas-link'import { createControlOpenBatch } from '../lib/controlOpenBatch'@@ -15103,7 +15104,9 @@ export function Canvas() {{/* Peer cursors live INSIDE <ReactFlow>: PresenceLayer uses ViewportPortal +useReactFlow, which throw outside the provider — and cursors are flow coordinates. */}<PresenceLayer />- <StatusAwareMiniMap onNodeDoubleClick={goToNode} />+ <MinimapDock>+ <StatusAwareMiniMap onNodeDoubleClick={goToNode} />+ </MinimapDock></ReactFlow></SessionProvider>diff --git a/src/renderer/canvas/MinimapDock.test.tsx b/src/renderer/canvas/MinimapDock.test.tsxnew file mode 100644index 000000000..b6f5d42ef--- /dev/null+++ b/src/renderer/canvas/MinimapDock.test.tsx@@ -0,0 +1,60 @@+// @vitest-environment jsdom+import { act } from 'react'+import { createRoot, type Root } from 'react-dom/client'+import { afterEach, beforeEach, expect, it } from 'vitest'+import { MinimapDock } from './MinimapDock'+import { MINIMAP_COLLAPSED_KEY } from '../lib/minimapCollapse'++;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true+let root: Root+let host: HTMLDivElement++function mount() {+ host = document.createElement('div')+ document.body.append(host)+ root = createRoot(host)+ act(() =>+ root.render(+ <MinimapDock>+ <div id="map" />+ </MinimapDock>+ )+ )+}+const button = (label: string) => host.querySelector<HTMLButtonElement>(`button[aria-label="${label}"]`)++beforeEach(() => localStorage.clear())+afterEach(() => {+ act(() => root.unmount())+ host.remove()+})++it('shows the map with a minimize control by default', () => {+ mount()+ expect(host.querySelector('#map')).not.toBeNull()+ expect(button('Minimize minimap')).not.toBeNull()+ expect(button('Show minimap')).toBeNull()+})++it('minimizing unmounts the map, leaves a restore button, and remembers the choice', () => {+ mount()+ act(() => button('Minimize minimap')!.click())+ // Unmounted, not hidden: the map's status subscription must stop with it.+ expect(host.querySelector('#map')).toBeNull()+ const restore = button('Show minimap')+ expect(restore).not.toBeNull()+ // fit-view must still treat the corner as occupied.+ expect(restore!.closest('[data-canvas-chrome]')).not.toBeNull()+ expect(localStorage.getItem(MINIMAP_COLLAPSED_KEY)).toBe('1')++ act(() => restore!.click())+ expect(host.querySelector('#map')).not.toBeNull()+ expect(localStorage.getItem(MINIMAP_COLLAPSED_KEY)).toBe('0')+})++it('starts minimized when the choice was remembered', () => {+ localStorage.setItem(MINIMAP_COLLAPSED_KEY, '1')+ mount()+ expect(host.querySelector('#map')).toBeNull()+ expect(button('Show minimap')).not.toBeNull()+})diff --git a/src/renderer/canvas/MinimapDock.tsx b/src/renderer/canvas/MinimapDock.tsxnew file mode 100644index 000000000..4975e3ca9--- /dev/null+++ b/src/renderer/canvas/MinimapDock.tsx@@ -0,0 +1,52 @@+import { useCallback, useState, type ReactNode } from 'react'+import { Tooltip } from '../components/Tooltip'+import { IconMinimap, IconMinus } from '../components/icons'+import { readMinimapCollapsed, writeMinimapCollapsed } from '../lib/minimapCollapse'++/**+ * The bottom-right minimap with a minimize control: hovering the map reveals a small "−" in its+ * top-left corner, and a minimized map leaves a single restore button in its place. The choice is+ * personal and remembered per machine (`lib/minimapCollapse`).+ *+ * The map is passed as `children` and simply NOT rendered while minimized, so its agent-status+ * subscription and store projection stop with it instead of repainting an invisible map.+ *+ * Both states live inside <ReactFlow> (the map needs its store); neither uses a library Panel for+ * the wrapper — the dock positions itself and turns the map's own Panel into an in-flow child+ * (styles.css `.minimap-dock`), so the hover area is exactly the map. The restore button opts into+ * fit-view's obstacle list via `data-canvas-chrome`; the expanded map is already on it (`.minimap`).+ */+export function MinimapDock({ children }: { children: ReactNode }) {+ const [collapsed, setCollapsed] = useState(readMinimapCollapsed)+ const setAndRemember = useCallback((next: boolean) => {+ setCollapsed(next)+ writeMinimapCollapsed(next)+ }, [])++ if (collapsed) {+ return (+ <div className="minimap-restore nodrag nopan" data-canvas-chrome>+ <Tooltip label="Show minimap" placement="top">+ <button type="button" aria-label="Show minimap" onClick={() => setAndRemember(false)}>+ <IconMinimap />+ </button>+ </Tooltip>+ </div>+ )+ }+ return (+ <div className="minimap-dock">+ {children}+ <Tooltip label="Minimize minimap" placement="top">+ <button+ type="button"+ className="minimap-dock__minimize nodrag nopan"+ aria-label="Minimize minimap"+ onClick={() => setAndRemember(true)}+ >+ <IconMinus />+ </button>+ </Tooltip>+ </div>+ )+}diff --git a/src/renderer/components/icons.tsx b/src/renderer/components/icons.tsxindex d047d1897..7017f78c3 100644--- a/src/renderer/components/icons.tsx+++ b/src/renderer/components/icons.tsx@@ -70,6 +70,15 @@ export const IconMinus = () => (</svg>)+/** Minimap — a map frame with the viewport rectangle inside it: the minimized minimap's restore+ * button. */+export const IconMinimap = () => (+ <svg {...S}>+ <rect x="3" y="5" width="18" height="14" rx="2" />+ <rect x="11" y="9" width="6" height="6" rx="1" />+ </svg>+)+export const IconSelectAll = () => (<svg {...S}><path d="M4 8V6a2 2 0 0 1 2-2h2M16 4h2a2 2 0 0 1 2 2v2M20 16v2a2 2 0 0 1-2 2h-2M8 20H6a2 2 0 0 1-2-2v-2" />diff --git a/src/renderer/lib/minimapCollapse.test.ts b/src/renderer/lib/minimapCollapse.test.tsnew file mode 100644index 000000000..18c7eee1f--- /dev/null+++ b/src/renderer/lib/minimapCollapse.test.ts@@ -0,0 +1,47 @@+import { describe, expect, it } from 'vitest'+import {+ MINIMAP_COLLAPSED_KEY,+ parseMinimapCollapsed,+ readMinimapCollapsed,+ writeMinimapCollapsed+} from './minimapCollapse'++describe('parseMinimapCollapsed', () => {+ it('is expanded by default — a missing key must not hide the minimap on existing users', () => {+ expect(parseMinimapCollapsed(null)).toBe(false)+ expect(parseMinimapCollapsed('')).toBe(false)+ expect(parseMinimapCollapsed('0')).toBe(false)+ expect(parseMinimapCollapsed('true')).toBe(false)+ expect(parseMinimapCollapsed('1')).toBe(true)+ })+})++describe('readMinimapCollapsed / writeMinimapCollapsed', () => {+ it('reads the namespaced key and writes 1/0', () => {+ const store: Record<string, string> = {}+ const get = (k: string): string | null => store[k] ?? null+ const set = (k: string, v: string): void => {+ store[k] = v+ }+ expect(readMinimapCollapsed(get)).toBe(false)+ writeMinimapCollapsed(true, set)+ expect(store[MINIMAP_COLLAPSED_KEY]).toBe('1')+ expect(readMinimapCollapsed(get)).toBe(true)+ writeMinimapCollapsed(false, set)+ expect(store[MINIMAP_COLLAPSED_KEY]).toBe('0')+ expect(readMinimapCollapsed(get)).toBe(false)+ })++ it('degrades to expanded when storage throws', () => {+ expect(+ readMinimapCollapsed(() => {+ throw new Error('blocked')+ })+ ).toBe(false)+ expect(() =>+ writeMinimapCollapsed(true, () => {+ throw new Error('quota')+ })+ ).not.toThrow()+ })+})diff --git a/src/renderer/lib/minimapCollapse.ts b/src/renderer/lib/minimapCollapse.tsnew file mode 100644index 000000000..4b9cb85c4--- /dev/null+++ b/src/renderer/lib/minimapCollapse.ts@@ -0,0 +1,35 @@+// Personal "minimap minimized" flag. Same storage family as the explorer pin+// (`nodeterm.explorerPinned`) and the sessions sidebar pin: this machine only, never settings.json+// or project.json — how much chrome one viewer wants over their canvas is not something a+// git-shared project file should carry to everyone who clones it.+//+// Default EXPANDED: the minimap has always been on screen, so a missing (or unreadable) key must+// keep it there rather than hide it on every existing user's next launch.++export const MINIMAP_COLLAPSED_KEY = 'nodeterm.minimapCollapsed'++/** `'1'` is minimized; missing, `'0'`, or any other value is expanded. */+export function parseMinimapCollapsed(raw: string | null): boolean {+ return raw === '1'+}++export function readMinimapCollapsed(+ getItem: (key: string) => string | null = (key) => localStorage.getItem(key)+): boolean {+ try {+ return parseMinimapCollapsed(getItem(MINIMAP_COLLAPSED_KEY))+ } catch {+ return false+ }+}++export function writeMinimapCollapsed(+ collapsed: boolean,+ setItem: (key: string, value: string) => void = (key, value) => localStorage.setItem(key, value)+): void {+ try {+ setItem(MINIMAP_COLLAPSED_KEY, collapsed ? '1' : '0')+ } catch {+ /* private-mode / quota: remembering the choice is a nicety, never fail the UI */+ }+}diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 0cb06130b..4b28b9a63 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -7514,6 +7514,93 @@ button.group-node__setup:disabled {box-shadow: 0 8px 28px rgba(0, 0, 0, calc(0.4 * var(--shadow-k)));}+/* Minimize control (canvas/MinimapDock.tsx). The dock takes over the placement React Flow's Panel+ gave the map — one --float-gap in from the bottom-right — and turns the map's own Panel into an+ in-flow child, so the dock's box, and with it the hover area, is exactly the map: no dead band+ of margin over the canvas. */+.minimap-dock {+ position: absolute;+ right: var(--float-gap);+ bottom: var(--float-gap);+ z-index: 5;+}+.minimap-dock > .react-flow__minimap.minimap {+ position: relative;+ margin: 0 !important;+}+/* The "−" sits inside the map's top-left corner and shows only while the map is hovered or the+ button has keyboard focus. A solid panel fill in every appearance: it lies over the map's node+ rectangles, and a translucent one there would be a button over noise. */+.minimap-dock > .tooltip-trigger {+ position: absolute;+ top: 6px;+ left: 6px;+ z-index: 6;+}+.minimap-dock__minimize {+ width: 20px;+ height: 20px;+ padding: 0;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ background: var(--panel);+ border: 1px solid var(--border);+ border-radius: 6px;+ color: var(--text);+ cursor: pointer;+ opacity: 0;+ transition: opacity 0.12s ease;+}+.minimap-dock__minimize svg {+ width: 12px;+ height: 12px;+}+.minimap-dock:hover .minimap-dock__minimize,+.minimap-dock__minimize:focus-visible {+ opacity: 1;+}+.minimap-dock__minimize:hover {+ background: var(--panel-header);+}+/* No hover on a touch screen (the Server Edition on a tablet): keep the control visible there, or+ the map could never be minimized. */+@media (hover: none) {+ .minimap-dock__minimize {+ opacity: 1;+ }+}++/* The minimized map: one button in the corner the map occupied, on the same plate as the other+ floating controls. */+.minimap-restore {+ position: absolute;+ right: var(--float-gap);+ bottom: var(--float-gap);+ z-index: 5;+}+.minimap-restore button {+ width: 34px;+ height: 34px;+ padding: 0;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ background: rgba(var(--menu-rgb), 0.92);+ border: 1px solid var(--border);+ border-radius: 9px;+ color: var(--text);+ cursor: pointer;+ box-shadow: 0 6px 20px rgba(0, 0, 0, calc(0.3 * var(--shadow-k)));+}+.minimap-restore button:hover {+ background: var(--panel-header);+}+.minimap-restore button svg {+ width: 18px;+ height: 18px;+}+/* Minimap-scale status glow (amber working / red needs-you / clay unread in the default look; thestate roles under Liquid Glass — see the --mm-* tokens). A static drop-shadow provides the halo; onlystroke-opacity animates (cheap on tiny svg rects), cadence matching each canvas glow. */@@ -14289,6 +14376,7 @@ body.focus-mode .dock:hover {.controls-cluster > button,.react-flow__controls,.react-flow__minimap.minimap,+ .minimap-restore button,.sysres-pill,.usage-pill,.usage-refresh,