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(breadcrumbs): back/forward camera navigation (chord + Dock buttons)
Mina Sameh0aa849879a0e
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 1036d36de..e7cc3154e 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -216,6 +216,7 @@ import {} from '../lib/nodeFocus'import {recordBreadcrumb,+ stepBreadcrumb,type BreadcrumbState,type BreadcrumbTarget} from '../lib/breadcrumbs'@@ -1136,6 +1137,12 @@ export function Canvas() {*/const hasPeersRef = useRef(false)const [, bumpHist] = useState(0)+ // Same trick as bumpHist, for the breadcrumb cursor: the Dock's back/forward buttons read+ // navRef during render, and a ref mutation is invisible to React — so every write to+ // navRef.current is followed by a bump, or the buttons stay disabled until some unrelated+ // re-render happens to notice. Its own counter rather than bumpHist's: the two stacks are+ // separate facts (node-array history vs camera history) and move at different times.+ const [, bumpNav] = useState(0)const {setViewport,getViewport,@@ -1941,6 +1948,7 @@ export function Canvas() {// (a project reactivated after being away starts "at the end" of its own trail).const bc = project.breadcrumbs ?? []navRef.current = { list: bc, index: bc.length - 1 }+ bumpNav((v) => v + 1)if (preserveViewportRef.current) {// In-place reload (external change / SSH reconcile): keep the user's current camera —// the file's viewport is where another machine last saved, not where this user looks.@@ -5622,6 +5630,7 @@ export function Canvas() {// recordBreadcrumb returns the SAME object on a dedupe no-op, so identity is the skip test.if (next !== navRef.current) {navRef.current = next+ bumpNav((v) => v + 1)useProjects.getState().setProjectBreadcrumbs(activeId, next.list)markDirty()}@@ -5674,6 +5683,56 @@ export function Canvas() {[fitView, setViewport, getInternalNode, markDirty])+ /**+ * Walks the breadcrumb cursor one stop and flies the camera there. Browser back/forward for the+ * canvas: this is the ONE path that must NOT record a stop — calling goToNode would append the+ * landing and turn every step into a new tip, so the framing block below is deliberately a copy+ * of goToNode's (measured ⇒ fitView, unmeasured ⇒ frame from the persisted size, unknowable ⇒+ * stand still) rather than a call into it. A shared `frameNode` helper is the obvious follow-up;+ * it is not done here because goToNode's measured check carries reasoning (it reads React Flow's+ * OWN store, not our node copy) that a hasty extraction is likely to lose.+ *+ * stepBreadcrumb skips stops whose node is gone, so a deleted node is walked THROUGH silently.+ */+ const stepAndFrame = useCallback(+ (direction: 'back' | 'forward') => {+ const activeId = useProjects.getState().activeProjectId+ if (!activeId || isKanbanOpen(activeId)) return+ const next = stepBreadcrumb(navRef.current, direction, (nodeId) =>+ nodesRef.current.some((n) => n.id === nodeId)+ )+ if (!next) return+ // Cursor only: it is machine-local and NOT persisted (only `list` rides the index entry),+ // so a step writes no project state and marks nothing dirty — walking the camera back and+ // forth must not queue a project.json write.+ navRef.current = next+ bumpNav((v) => v + 1)+ const target = nodesRef.current.find((n) => n.id === next.list[next.index].nodeId)+ if (!target) return+ const internal = getInternalNode(target.id)+ if (isMeasured(internal)) {+ const wrap = flowWrapRef.current+ const size = internal?.measured+ const solved =+ wrap && size?.width && size?.height ? solveFitPadding(wrap, size.width, size.height) : null+ void fitView({+ nodes: [{ id: target.id }],+ duration: 300,+ ...FIT_NODE_OPTIONS,+ padding: solved ?? FIT_NODE_OPTIONS.padding+ })+ return+ }+ const rect = nodeFitRect(target as FocusableNode, nodesRef.current as FocusableNode[])+ const wrap = flowWrapRef.current?.getBoundingClientRect()+ const viewport = rect && wrap ? viewportForRect(rect, wrap.width, wrap.height) : null+ if (viewport) void setViewport(viewport, { duration: 300 })+ },+ [fitView, setViewport, getInternalNode]+ )+ const goBack = useCallback(() => stepAndFrame('back'), [stepAndFrame])+ const goForward = useCallback(() => stepAndFrame('forward'), [stepAndFrame])+const onNodeDoubleClick = useCallback((_e: React.MouseEvent, node: Node) => {if (useSettings.getState().settings.doubleClickFocus) goToNode(node)@@ -5814,6 +5873,8 @@ export function Canvas() {'panel.sessions': () => { toggleSessionsPin(); return true },'canvas.undo': () => { undo(); return true },'canvas.redo': () => { redo(); return true },+ 'canvas.goBack': () => { goBack(); return true },+ 'canvas.goForward': () => { goForward(); return true },'canvas.fitAll': () => { fitAll(); return true },'canvas.tidy': () => { arrangeAllNodes(); return true },'canvas.deleteSelection': deleteSelectionCommand,@@ -10764,8 +10825,12 @@ export function Canvas() {zoomPct={zoomPct}canUndo={pastRef.current.length > 0}canRedo={futureRef.current.length > 0}+ canGoBack={navRef.current.index > 0}+ canGoForward={navRef.current.index < navRef.current.list.length - 1}onUndo={undo}onRedo={redo}+ onGoBack={goBack}+ onGoForward={goForward}onAddTerminal={addTerminal}onAddSticky={addSticky}onSpawnTeam={() => setSpawnTeamDialog({})}diff --git a/src/renderer/components/Dock.tsx b/src/renderer/components/Dock.tsxindex 2cc0afbcc..ff2f909c8 100644--- a/src/renderer/components/Dock.tsx+++ b/src/renderer/components/Dock.tsx@@ -17,6 +17,8 @@ interface DockProps {zoomPct: numbercanUndo: booleancanRedo: boolean+ canGoBack: boolean+ canGoForward: booleanonAddTerminal: () => voidonAddSticky: () => void/** Opens the Spawn-a-team dialog (issue #78) — the conductor lands at the Dock's default spot. */@@ -34,6 +36,8 @@ interface DockProps {onAddWorktree: () => voidonUndo: () => voidonRedo: () => void+ onGoBack: () => void+ onGoForward: () => voidonSave: () => voidonFitView: () => voidonZoomIn: () => void@@ -51,6 +55,8 @@ export function Dock({zoomPct,canUndo,canRedo,+ canGoBack,+ canGoForward,onAddTerminal,onAddSticky,onSpawnTeam,@@ -65,6 +71,8 @@ export function Dock({onAddWorktree,onUndo,onRedo,+ onGoBack,+ onGoForward,onSave,onFitView,onZoomIn,@@ -290,6 +298,22 @@ export function Dock({<button className="dock-btn" title={commandTooltip('Redo', 'canvas.redo')} disabled={!canRedo} onClick={onRedo}><RedoIcon /></button>+ <button+ className="dock-btn"+ title={commandTooltip('Go back', 'canvas.goBack')}+ disabled={!canGoBack}+ onClick={onGoBack}+ >+ <ArrowLeftIcon />+ </button>+ <button+ className="dock-btn"+ title={commandTooltip('Go forward', 'canvas.goForward')}+ disabled={!canGoForward}+ onClick={onGoForward}+ >+ <ArrowRightIcon />+ </button><span className="dock-sep" />@@ -356,6 +380,20 @@ function RedoIcon() {</svg>)}+function ArrowLeftIcon() {+ return (+ <svg {...S}>+ <path d="M19 12H5M11 6l-6 6 6 6" />+ </svg>+ )+}+function ArrowRightIcon() {+ return (+ <svg {...S}>+ <path d="M5 12h14M13 6l6 6-6 6" />+ </svg>+ )+}function PlusSmallIcon() {return (<svg {...S} width={15} height={15}>diff --git a/src/renderer/components/ShortcutsPanel.tsx b/src/renderer/components/ShortcutsPanel.tsxindex 1f492e254..2781825e3 100644--- a/src/renderer/components/ShortcutsPanel.tsx+++ b/src/renderer/components/ShortcutsPanel.tsx@@ -63,7 +63,9 @@ function buildSections(dictationChord: string): { title: string; rows: Row[] }[]...(isBrowserRuntime() ? [] : [{ keys: ['⌘', '1-9'], label: 'Jump to project' }]),...dictate(),...cmd('canvas.undo', 'Undo'),- ...cmd('canvas.redo', 'Redo')+ ...cmd('canvas.redo', 'Redo'),+ ...cmd('canvas.goBack', 'Go back'),+ ...cmd('canvas.goForward', 'Go forward')]},{diff --git a/src/shared/keybindings.test.ts b/src/shared/keybindings.test.tsindex 2a537cd70..308039f74 100644--- a/src/shared/keybindings.test.ts+++ b/src/shared/keybindings.test.ts@@ -81,6 +81,10 @@ describe('registry invariants', () => {darwin: ['Cmd+Z'], other: ['Cmd+Z'] },{ id: 'canvas.redo', title: 'Redo', group: 'Canvas', scope: 'canvas',darwin: ['Cmd+Shift+Z'], other: ['Cmd+Shift+Z', 'Cmd+Y'] },+ { id: 'canvas.goBack', title: 'Go back', group: 'Canvas', scope: 'canvas',+ darwin: ['Cmd+['], other: ['Cmd+['] },+ { id: 'canvas.goForward', title: 'Go forward', group: 'Canvas', scope: 'canvas',+ darwin: ['Cmd+]'], other: ['Cmd+]'] },{ id: 'canvas.deleteSelection', title: 'Delete selection', group: 'Canvas', scope: 'canvas',darwin: ['Delete', 'Backspace'], other: ['Delete', 'Backspace'], allowBareKey: true },{ id: 'canvas.fitAll', title: 'Fit all nodes in view', group: 'Canvas', scope: 'canvas',@@ -352,6 +356,15 @@ describe('resolveCommandForKeyEvent', () => {expect(resolveCommandForKeyEvent(ev({ metaKey: true, key: 'k' }), ctx(), {}, true)).toBe('app.commandPalette')})+ it('matches the bracket chords from the KEY the DOM reports', () => {+ // The registry spells these `Cmd+[` / `Cmd+]` because the resolver compares against+ // `e.key`. Spelled as the `e.code` values (`BracketLeft`/`BracketRight`) they would+ // normalize to 'BRACKETLEFT' and match no keydown at all — a silently dead chord.+ expect(resolveCommandForKeyEvent(ev({ metaKey: true, key: '[' }), ctx(), {}, true))+ .toBe('canvas.goBack')+ expect(resolveCommandForKeyEvent(ev({ metaKey: true, key: ']' }), ctx(), {}, true))+ .toBe('canvas.goForward')+ })it('typing blocks commands without allowWhileTyping, allows the flagged ones', () => {expect(resolveCommandForKeyEvent(ev({ metaKey: true, key: 't' }), ctx({ typing: true }), {}, truediff --git a/src/shared/keybindings.ts b/src/shared/keybindings.tsindex e71112217..87f7ef9dc 100644--- a/src/shared/keybindings.ts+++ b/src/shared/keybindings.ts@@ -47,6 +47,8 @@ export type CommandId =| 'panel.sessions'| 'canvas.undo'| 'canvas.redo'+ | 'canvas.goBack'+ | 'canvas.goForward'| 'canvas.deleteSelection'| 'canvas.fitAll'| 'canvas.tidy'@@ -89,6 +91,14 @@ export const COMMAND_DEFINITIONS: readonly CommandDefinition[] = [defaultBindings: both('Cmd+Z') },{ id: 'canvas.redo', title: 'Redo', group: 'Canvas', scope: 'canvas',defaultBindings: { darwin: ['Cmd+Shift+Z'], other: ['Cmd+Shift+Z', 'Cmd+Y'] } },+ // Camera history (breadcrumb trail), not node-array history: `[` / `]` are the literal keys+ // `e.key` reports, which is what the resolver compares against — `BracketLeft`/`BracketRight`+ // are `KeyboardEvent.code` values and would never match (shortcut.ts's KEY_ALIASES covers only+ // Comma/Slash/Period, so brackets have no word-form spelling here).+ { id: 'canvas.goBack', title: 'Go back', group: 'Canvas', scope: 'canvas',+ defaultBindings: both('Cmd+[') },+ { id: 'canvas.goForward', title: 'Go forward', group: 'Canvas', scope: 'canvas',+ defaultBindings: both('Cmd+]') },{ id: 'canvas.deleteSelection', title: 'Delete selection', group: 'Canvas', scope: 'canvas',// Mirrors the current platform-blind handler; the typing guard keeps Backspace safe.defaultBindings: both('Delete', 'Backspace'),