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.

fix(canvas): the three small file-manager notes from the review

albaneselorenzoa98dda645e11
diff --git a/src/renderer/lib/explorerCreate.ts b/src/renderer/lib/explorerCreate.ts
index 57671cdd2..014ebe90c 100644
--- a/src/renderer/lib/explorerCreate.ts
+++ b/src/renderer/lib/explorerCreate.ts
@@ -35,3 +35,16 @@ export function ancestorDirs(baseDir: string, name: string): string[] {
}
return out
}
+
+/**
+ * The name of a directory — its last segment, or '/' at the root.
+ *
+ * Lives HERE rather than beside the file manager's other pure helpers because `state/workspace.ts`
+ * needs it too (`createFilesNode`'s title) and `lib/filesNode.ts` imports `isVideoFile` FROM
+ * workspace, so importing back would close a cycle. This module imports nothing, which is what
+ * makes it the right home. `lib/filesNode.ts` re-exports it, so every existing call site is
+ * unchanged.
+ */
+export function folderTitle(path: string): string {
+ return path.split('/').filter(Boolean).pop() ?? '/'
+}
diff --git a/src/renderer/lib/filesNode.ts b/src/renderer/lib/filesNode.ts
index e6464c18e..ccd74e1b9 100644
--- a/src/renderer/lib/filesNode.ts
+++ b/src/renderer/lib/filesNode.ts
@@ -6,11 +6,21 @@
* Paths are `/`-separated absolutes throughout, remote ones included — the node talks to an
* `FsApi`, which is the same shape for the local filesystem, an SSH project's host over the
* ControlMaster, and a relay peer's core.
+ *
+ * **Windows is a known, INHERITED gap.** Every split here is on `/` alone, so `C:\\x\\y` reads as a
+ * single segment: one breadcrumb, and `folderTitle` returning the whole path. This is shared with
+ * `lib/explorerCreate.ts` (`parentDir`, `newEntryPath`, `ancestorDirs`), which the Explorer drawer
+ * and the canvas "New file…" already run on, so a files node is not the thing that introduces it —
+ * but Windows is being brought up as a first-class desktop target, and `quality-windows` now runs
+ * on this branch. When it is closed, close it in ONE place for both: the path dialect belongs to
+ * the filesystem-owning CORE, not the viewer, which is the rule `terminal/file-links.ts` already
+ * implements and the one to copy.
*/
import { isVideoFile } from '../state/workspace'
import { opensInEditor } from './openTarget'
+import { folderTitle } from './explorerCreate'
-export { parentDir } from './explorerCreate'
+export { folderTitle, parentDir } from './explorerCreate'
/** One breadcrumb: what to show, and where clicking it goes. */
export interface Crumb {
@@ -40,11 +50,34 @@ export function breadcrumbs(path: string, max = 3): Crumb[] {
return [all[0], ellipsis, ...all.slice(all.length - max)]
}
-/** The node's title: the directory's own name, or '/' at the root. */
-export function folderTitle(path: string): string {
- return path.split('/').filter(Boolean).pop() ?? '/'
+/**
+ * How a files node is re-pointed when the worktree it was living in is removed
+ * (`resetDisplacedCwd`). It is caught by path wherever it sits, like an editor and unlike a
+ * terminal, because it has no session to disturb — and it is re-pointed rather than flagged
+ * `fileMissing`, because a directory can be re-pointed and a dead file cannot.
+ *
+ * `null` means LEAVE IT ALONE, and that is the interesting answer: with no fallback directory
+ * there is nowhere honest to send it, and writing `undefined` is worse than doing nothing —
+ * `FilesNode` reads `data.cwd || '/'`, so the node would silently begin listing the filesystem
+ * ROOT. Left on the dead path, the parent-listing probe says "Could not read this folder", which
+ * is the truth.
+ *
+ * The title rides along while `titleAuto` holds. This is the one cwd write that does NOT go
+ * through `navigate` — the only other place that pairs the two — so without it the node moves to
+ * a new directory still wearing the removed worktree's name.
+ */
+export function displacedFilesPatch(
+ data: { titleAuto?: unknown },
+ fallbackCwd: string | undefined
+): { cwd: string; title?: string } | null {
+ if (!fallbackCwd) return null
+ return data.titleAuto !== false
+ ? { cwd: fallbackCwd, title: folderTitle(fallbackCwd) }
+ : { cwd: fallbackCwd }
}
+export type EmptyListingVerdict = 'empty' | 'missing' | 'unknown'
+
/**
* What an EMPTY listing actually means.
*
@@ -74,34 +107,6 @@ export function folderTitle(path: string): string {
* entry depending on the leg, and mistaking one for "missing" is the false alarm this exists to
* avoid.
*/
-/**
- * How a files node is re-pointed when the worktree it was living in is removed
- * (`resetDisplacedCwd`). It is caught by path wherever it sits, like an editor and unlike a
- * terminal, because it has no session to disturb — and it is re-pointed rather than flagged
- * `fileMissing`, because a directory can be re-pointed and a dead file cannot.
- *
- * `null` means LEAVE IT ALONE, and that is the interesting answer: with no fallback directory
- * there is nowhere honest to send it, and writing `undefined` is worse than doing nothing —
- * `FilesNode` reads `data.cwd || '/'`, so the node would silently begin listing the filesystem
- * ROOT. Left on the dead path, the parent-listing probe says "Could not read this folder", which
- * is the truth.
- *
- * The title rides along while `titleAuto` holds. This is the one cwd write that does NOT go
- * through `navigate` — the only other place that pairs the two — so without it the node moves to
- * a new directory still wearing the removed worktree's name.
- */
-export function displacedFilesPatch(
- data: { titleAuto?: unknown },
- fallbackCwd: string | undefined
-): { cwd: string; title?: string } | null {
- if (!fallbackCwd) return null
- return data.titleAuto !== false
- ? { cwd: fallbackCwd, title: folderTitle(fallbackCwd) }
- : { cwd: fallbackCwd }
-}
-
-export type EmptyListingVerdict = 'empty' | 'missing' | 'unknown'
-
export function classifyEmptyListing(
cwd: string,
/** The parent's entries, or `null` when the parent was not asked or could not be read. */
diff --git a/src/renderer/nodes/FilesNode.tsx b/src/renderer/nodes/FilesNode.tsx
index 07eac57f2..72281d301 100644
--- a/src/renderer/nodes/FilesNode.tsx
+++ b/src/renderer/nodes/FilesNode.tsx
@@ -65,6 +65,8 @@ export function FilesNode({ id, data, selected }: NodeProps<CanvasNode>) {
const [showColors, setShowColors] = useState(false)
const [editingTitle, setEditingTitle] = useState(false)
const [titleBefore, setTitleBefore] = useState('')
+ /** `titleAuto` as it stood before the rename began — Escape has to put BOTH halves back. */
+ const [autoBefore, setAutoBefore] = useState(true)
/** Kept WITH the directory it belongs to. Deriving `entries` from a cwd match is what makes
* "Loading…" reachable: before this, nothing ever reset the list, so navigating showed the
* PREVIOUS folder's rows until the new promise resolved and the loading state existed only on
@@ -335,7 +337,11 @@ export function FilesNode({ id, data, selected }: NodeProps<CanvasNode>) {
setEditingTitle(false)
} else if (e.key === 'Escape') {
e.preventDefault()
- updateNodeData(id, { title: titleBefore })
+ // Restore `titleAuto` as well as the text. `onChange` sets it false on the first
+ // keystroke, so cancelling a rename you never committed used to leave the title
+ // permanently detached from the folder — the node stopped following navigation
+ // and nothing said why.
+ updateNodeData(id, { title: titleBefore, titleAuto: autoBefore })
setEditingTitle(false)
}
}}
@@ -346,6 +352,7 @@ export function FilesNode({ id, data, selected }: NodeProps<CanvasNode>) {
title="Click to rename"
onClick={() => {
setTitleBefore((data.title as string) ?? '')
+ setAutoBefore(data.titleAuto !== false)
setEditingTitle(true)
}}
>
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index de57e4653..70663eaf5 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -23,6 +23,7 @@ import { mintFreeGrokSessionId } from '@shared/agents/grok-session-mint'
import { projectLaunchInfoNow } from './projectLaunchInfo'
import { isAgentEnabled, launchableDefaultAgent } from './agentAvailability'
import { codexSharedIdentity } from './codexIdentity'
+import { folderTitle } from '../lib/explorerCreate'
import { sshHostKey } from '@shared/ssh'
import { normalizeNodeIcon } from '@shared/node-icon'
import { useSettings } from './settings'
@@ -1062,7 +1063,7 @@ export function createFilesNode(
height: FILES_SIZE.height,
style: { width: FILES_SIZE.width, height: FILES_SIZE.height },
data: {
- title: cwd.split('/').filter(Boolean).pop() || '/',
+ title: folderTitle(cwd),
color: '#ffd60a',
group: null,
cwd,