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(palette): re-trigger reveal via nonce; keep revealed dirs collapsible
enes5712b1d615d1
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex b1ab900be..113b6f79c 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -123,9 +123,9 @@ export function Canvas() {const [scOpen, setScOpen] = useState(false)const [shortcutsOpen, setShortcutsOpen] = useState(false)const [explorerOpen, setExplorerOpen] = useState(false)- // Reveal-in-Explorer target (relative to the active project cwd). Cleared shortly after so- // the same file can be revealed twice in a row.- const [revealPath, setRevealPath] = useState<string | null>(null)+ // Reveal-in-Explorer target (relative to the active project cwd). The nonce makes each reveal+ // distinct so revealing the same file twice still re-fires the Explorer effect.+ const [reveal, setReveal] = useState<{ path: string; nonce: number } | null>(null)// When set, a full-surface remote mirror of a connected host is shown over the local canvas.const [remoteConnId, setRemoteConnId] = useState<string | null>(null)const [confirm, setConfirm] = useState<{@@ -751,6 +751,8 @@ export function Canvas() {(relPath: string) => {const cwd = useProjects.getState().getProject(activeProjectId ?? '')?.cwdif (!cwd) return+ // relPath comes from the trusted local file index (always cwd-relative), so the+ // `cwd + relPath` join needs no traversal guard in v1; a future remote/untrusted source would.const abs = `${cwd.replace(/\/$/, '')}/${relPath}`if (opensInEditor(relPath)) openFile(abs)else window.nodeTerminal.shell.openPath(abs)@@ -759,11 +761,10 @@ export function Canvas() {)/** Reveal a file in the Explorer drawer: open the drawer and hand it the (relative) path.- * Cleared after a tick so revealing the same file twice still triggers the effect. */+ * Each call bumps a nonce so revealing the same file twice still re-fires the effect. */const revealProjectFile = useCallback((relPath: string) => {setExplorerOpen(true)- setRevealPath(relPath)- setTimeout(() => setRevealPath(null), 1000)+ setReveal((r) => ({ path: relPath, nonce: (r?.nonce ?? 0) + 1 }))}, [])/** Open a git diff editor node for a changed file (from Source Control). */@@ -1862,7 +1863,7 @@ export function Canvas() {{shortcutsOpen && <ShortcutsPanel onClose={() => setShortcutsOpen(false)} />}{explorerOpen && (- <ExplorerPanel onClose={() => setExplorerOpen(false)} onOpenFile={openFile} revealPath={revealPath} />+ <ExplorerPanel onClose={() => setExplorerOpen(false)} onOpenFile={openFile} reveal={reveal} />)}{confirm && (diff --git a/src/renderer/components/ExplorerPanel.tsx b/src/renderer/components/ExplorerPanel.tsxindex 8b27efcfb..9fc0b8576 100644--- a/src/renderer/components/ExplorerPanel.tsx+++ b/src/renderer/components/ExplorerPanel.tsx@@ -6,8 +6,9 @@ import { useProjects } from '../state/projects'interface ExplorerPanelProps {onClose: () => voidonOpenFile: (path: string) => void- /** Absolute-or-relative file path to reveal (expand ancestors + select + scroll). Relative to the active project cwd. */- revealPath?: string | null+ /** File to reveal (expand ancestors + select + scroll). `path` is relative to the active project+ * cwd; `nonce` increments per request so revealing the same file twice still re-fires. */+ reveal?: { path: string; nonce: number } | null}type ContextFn = (x: number, y: number, path: string, isDir: boolean) => void@@ -33,6 +34,7 @@ function TreeEntry({depth,selected,forcedOpen,+ revealNonce,onContext,onOpenFile,onSelect@@ -42,6 +44,7 @@ function TreeEntry({depth: numberselected: string | nullforcedOpen: Set<string>+ revealNonce: number | undefinedonContext: ContextFnonOpenFile: OpenFnonSelect: SelectFn@@ -49,6 +52,9 @@ function TreeEntry({const [open, setOpen] = useState(false)const [children, setChildren] = useState<DirEntry[] | null>(null)const rowRef = useRef<HTMLDivElement>(null)+ // The last reveal nonce this row force-opened for, so we honor each reveal edge exactly once+ // and don't re-assert open afterwards (otherwise a manual collapse wouldn't stick).+ const lastHonoredRef = useRef<number | undefined>(undefined)const expandDir = useCallback(async () => {const next = !open@@ -56,13 +62,16 @@ function TreeEntry({if (next && children === null) setChildren(await window.nodeTerminal.fs.list(path))}, [open, children, path])- // Reveal: when this directory is force-opened (an ancestor of the reveal target),- // lazy-load its children (awaiting the list, like the click path) and expand.+ // Reveal: when this directory is force-opened (an ancestor of the reveal target), expand it+ // ONCE per reveal edge. After the edge, a manual collapse sticks because this effect won't+ // re-fire for the same nonce. Lazy-load children (awaiting the list, like the click path).useEffect(() => {if (!entry.dir || !forcedOpen.has(path)) return+ if (revealNonce === lastHonoredRef.current) return+ lastHonoredRef.current = revealNonceif (children === null) void window.nodeTerminal.fs.list(path).then(setChildren)setOpen(true)- }, [forcedOpen, path, entry.dir, children])+ }, [forcedOpen, path, entry.dir, children, revealNonce])// Reveal: scroll the selected (target) row into view once it has mounted.useEffect(() => {@@ -111,6 +120,7 @@ function TreeEntry({depth={depth + 1}selected={selected}forcedOpen={forcedOpen}+ revealNonce={revealNonce}onContext={onContext}onOpenFile={onOpenFile}onSelect={onSelect}@@ -127,7 +137,7 @@ function TreeEntry({* filesystem yet. Once `canvas:state` carries the host cwd (Task 6), this can switch to* `remoteFs(connectionId)` (the per-connection `FsApi`) rooted at that path — the Editor already* proxies over the relay via `data.remote.connectionId`. */-export function ExplorerPanel({ onClose, onOpenFile, revealPath }: ExplorerPanelProps) {+export function ExplorerPanel({ onClose, onOpenFile, reveal }: ExplorerPanelProps) {const project = useProjects((s) => s.projects.find((p) => p.id === s.activeProjectId))const cwd = project?.cwdconst [roots, setRoots] = useState<DirEntry[] | null>(null)@@ -143,7 +153,9 @@ export function ExplorerPanel({ onClose, onOpenFile, revealPath }: ExplorerPanel// Reveal a file: force-open every ancestor directory under cwd, select the file, and// let the matching row scroll itself into view. Only paths inside cwd are revealed.+ // Keyed on the nonce so revealing the same file twice still re-triggers.useEffect(() => {+ const revealPath = reveal?.pathif (!revealPath || !cwd) returnconst base = cwd.replace(/\/$/, '')const rel = revealPath.startsWith(base + '/') ? revealPath.slice(base.length + 1) : revealPath@@ -159,7 +171,8 @@ export function ExplorerPanel({ onClose, onOpenFile, revealPath }: ExplorerPanel}setForcedOpen(dirs)setSelected(abs)- }, [revealPath, cwd])+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [reveal?.nonce, cwd])const onContext: ContextFn = (x, y, path) => setMenu({ x, y, path })@@ -195,6 +208,7 @@ export function ExplorerPanel({ onClose, onOpenFile, revealPath }: ExplorerPaneldepth={0}selected={selected}forcedOpen={forcedOpen}+ revealNonce={reveal?.nonce}onContext={onContext}onOpenFile={onOpenFile}onSelect={setSelected}