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
fix(focus): close both review findings — budget starvation + shared-mode blank frame
enes680c5b52372f
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex a672ab2b1..71a6cf7d7 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -1906,26 +1906,6 @@ export function Canvas() {useEffect(() => registerWorkspaceDirty(markDirty), [markDirty])const kanbanOpen = useViewMode((s) => !!activeProjectId && viewFor(s, activeProjectId) === 'kanban')- // 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)- useEffect(() => {- document.body.classList.toggle('focus-mode', !!focusedId)- return () => document.body.classList.remove('focus-mode')- }, [focusedId])- 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 projectKanban = useProjects((s) => s.projects.find((p) => p.id === s.activeProjectId)?.kanban)// Fresh default per project — ids must not be shared across projects; NOT persisted// until the first edit writes it (spec lazy-default rule).@@ -5153,15 +5133,51 @@ export function Canvas() {[fitView, setViewport, getInternalNode])+ // 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) {- const id = 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.focusedIdstore.clear()- // Land framed on what was just being looked at — goToNode owns the measured/unmeasured- // doctrine, so no bare fitView here.- const node = nodesRef.current.find((n) => n.id === id)- if (node) goToNode(node)return}// The kanban board is an opaque overlay and its card modal already IS a focused view of adiff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 6efc6adc7..615dd5a77 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -1118,6 +1118,12 @@ export function TerminalNode({const root = rootRef.currentconst surface = focusSurfaceEl()if (!root || !surface) return+ // Shared mode: the grid teardown must land in THIS commit, before paint. The participation+ // effect below is passive (after paint), so without this a fullscreen frame paints while the+ // grid is still registered at the old on-canvas position and the node still wears the+ // glyph-mode styling (transparent body, rows hidden) — one blank frame per ⌘⇧F. The passive+ // effect then re-runs with the same answer and no-ops. (Review finding on #267.)+ glyphSyncRef.current?.(false)const home = root.parentElementsurface.appendChild(root)return () => {@@ -1927,7 +1933,11 @@ export function TerminalNode({// keeps its last size (the "parked SOLO subscriber leaves the pty alone" case). When the board// closes, the boardOpen effect re-runs applyFit and the `sentCols/sentRows` reset below forces// a fresh report of the real fit.- if (boardOpenRef.current) {+ // Focus mode covers this node the same way the board does: the flow wrapper is+ // display:none (so the WebGL budget can reclaim the hidden holders — review finding on+ // #267), and a 0-sized container must vote "not viewing", never a clamped tiny grid.+ const coveredByFocus = focusedNodeId() !== null && focusedNodeId() !== id+ if (boardOpenRef.current || coveredByFocus) {if (sessionId && !boardParked) {boardParked = truesentCols = 0@@ -3845,6 +3855,11 @@ export function TerminalNode({applyFitRef.current?.()}, [boardOpen])+ // Focus mode engaged/exited anywhere on the canvas: re-run our size vote (applyFit reads+ // focusedNodeId() live). Mount-stable — the focused-node subscription above only re-renders+ // the node whose own membership flipped, and every OTHER terminal is the one being covered.+ useEffect(() => subscribeFocusedNode(() => applyFitRef.current?.()), [])+const toggleCollapse = () =>setNodes((ns) =>ns.map((n) => {diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 3f48975c8..fafa3a524 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -10677,6 +10677,15 @@ body,.focus-exit:hover {opacity: 1;}+/* The canvas itself goes display:none, not merely covered (review finding on #267): an+ IntersectionObserver does not model occlusion, so covered-but-displayed terminals kept+ reporting visible, kept their WebGL contexts, and a full budget then refused the one node+ filling the screen (tryGrant only evicts HIDDEN holders). display:none zeroes their geometry,+ they report hidden, the budget reclaims them — and 16+ occluded terminals stop rendering+ frames nobody can see. Their size votes go null via applyFit's focus gate, like the board. */+body.focus-mode .flow-wrap {+ display: none;+}/* Dock reveal: proximity (Canvas toggles `focus-reveal-bottom` on mousemove) or direct hoverkeeps it up once revealed. Lifted above the surface, faded via opacity only. */body.focus-mode .dock {