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.

Merge branch 'main' into feat/breadcrumb-trail

eneskirca12136c0b03e1
diff --cc src/renderer/canvas/Canvas.tsx
index 5834529ad,7b5d6f366..55994138a
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@@ -5712,59 -5658,67 +5734,117 @@@ export function Canvas()
// teleporting the user to the origin, which is the bug this branch exists for.
if (viewport) void setViewport(viewport, { duration: 300 })
},
+ [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])
+ // Focus mode (issue #78): one terminal fills the window (reparented into the always-mounted
+ // focus surface below); the chrome hides behind it and reveals on pointer proximity.
+ const focusedId = useFocusNode((s) => s.focusedId)
+ // Where to land the camera after an exit — set by toggleFocusMode, consumed below AFTER the
+ // body class flips back. goToNode cannot run inside the toggle: the flow wrapper is
+ // display:none while focused (so the WebGL budget can reclaim covered holders), and fitView
+ // math against a 0-sized pane is exactly the origin-jump bug.
+ const focusReturnRef = useRef<string | null>(null)
+ useEffect(() => {
+ document.body.classList.toggle('focus-mode', !!focusedId)
+ if (!focusedId && focusReturnRef.current) {
+ const returnId = focusReturnRef.current
+ focusReturnRef.current = null
+ // Two frames: React Flow re-learns the pane's dimensions from its own ResizeObserver on
+ // the tick after display is restored; framing before that reads a stale/zero size.
+ requestAnimationFrame(() =>
+ requestAnimationFrame(() => {
+ const node = nodesRef.current.find((n) => n.id === returnId)
+ if (node) goToNode(node)
+ })
+ )
+ }
+ return () => document.body.classList.remove('focus-mode')
+ }, [focusedId, goToNode])
+ useEffect(() => {
+ if (!focusedId) return
+ // Proximity reveal instead of an invisible hover band: a band over the terminal's bottom
+ // edge would eat clicks on the very row a shell keeps its prompt on.
+ const onMove = (e: MouseEvent): void => {
+ document.body.classList.toggle('focus-reveal-bottom', window.innerHeight - e.clientY < 90)
+ }
+ window.addEventListener('mousemove', onMove)
+ return () => {
+ window.removeEventListener('mousemove', onMove)
+ document.body.classList.remove('focus-reveal-bottom')
+ }
+ }, [focusedId])
+
+ const toggleFocusMode = useCallback(() => {
+ const store = useFocusNode.getState()
+ if (store.focusedId) {
+ // Landing on the node is DEFERRED to the focus-mode class effect (see focusReturnRef):
+ // the flow pane is still display:none at this point.
+ focusReturnRef.current = store.focusedId
+ store.clear()
+ return
+ }
+ // The kanban board is an opaque overlay and its card modal already IS a focused view of a
+ // session — engaging under it would just hide the canvas twice.
+ if (isKanbanOpen(useProjects.getState().activeProjectId)) return
+ const target = focusTargetId(nodesRef.current)
+ if (!target) {
+ setNotice({ kind: 'error', text: FOCUS_NO_TARGET_NOTICE })
+ return
+ }
+ store.focus(target)
+ }, [goToNode])
+
const onNodeDoubleClick = useCallback(
(_e: React.MouseEvent, node: Node) => {
if (useSettings.getState().settings.doubleClickFocus) goToNode(node)