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(ssh-p3): quoteRemotePath for remote fs paths (tilde) + explicit sshFs flag (no dialog wrong-write) (final-review)
enesb25e10d40120
diff --git a/src/main/ssh-fs.test.ts b/src/main/ssh-fs.test.tsindex d02feda4a..c1962efe3 100644--- a/src/main/ssh-fs.test.ts+++ b/src/main/ssh-fs.test.ts@@ -1,5 +1,5 @@import { describe, expect, it, vi } from 'vitest'-import { sshListArgs, sshReadArgs, sshReadBinaryArgs, sshWriteArgs, parseLsEntries, SshFs } from './ssh-fs'+import { sshListArgs, sshReadArgs, sshReadBinaryArgs, sshWriteArgs, sshCheckIgnoreArgs, parseLsEntries, SshFs } from './ssh-fs'const conn = { host: 'h', user: 'u' }const ref = { conn, controlPath: '/s.sock' }@@ -19,6 +19,20 @@ describe('ssh-fs arg builders', () => {expect(j).toContain(`mkdir -p '/d/e'`)expect(j).toContain(`cat > '/d/e/f.txt'`)})+ // CRITICAL: SSH projects default to a home-relative remoteCwd (`~`). quoteRemotePath must leave a+ // leading `~/` UNQUOTED so the remote shell tilde-expands it; the remainder stays single-quoted.+ it('list leaves a leading ~/ unquoted so the remote shell tilde-expands the path', () => {+ expect(sshListArgs(conn, '/s', '~/projects').join(' ')).toContain(`ls -Ap1 ~/'projects'`)+ })+ it('write keeps ~/ unquoted for BOTH the mkdir dirname and the cat target', () => {+ const j = sshWriteArgs(conn, '/s', '~/projects/file.txt').join(' ')+ expect(j).toContain(`mkdir -p ~/'projects'`)+ expect(j).toContain(`cat > ~/'projects/file.txt'`)+ })+ it('check-ignore quotes the dir as a remote path (~ expands) but quotes entry NAMES literally', () => {+ const j = sshCheckIgnoreArgs(conn, '/s', '~/p', ['node_modules', "a'b"]).join(' ')+ expect(j).toContain(`git -C ~/'p' check-ignore -- 'node_modules' 'a'\\''b'`)+ })})describe('parseLsEntries', () => {diff --git a/src/main/ssh-fs.ts b/src/main/ssh-fs.tsindex d5917c154..92d675b30 100644--- a/src/main/ssh-fs.ts+++ b/src/main/ssh-fs.ts@@ -1,8 +1,10 @@// SSH filesystem ops over a project's ControlMaster. The remote analog of fs-ops.ts: same// fail-open contract ([]/''/false on any error), reused by the renderer's sshFs(projectId) FsApi.-// Every path is posixQuote'd; write content goes on stdin (never interpolated).+// Paths are quoteRemotePath'd (a leading `~`/`~/` stays UNQUOTED so the remote shell tilde-expands+// it — SSH projects default to a home-relative remoteCwd); write content goes on stdin (never+// interpolated). check-ignore entry NAMES are bare filenames, so they stay posixQuote'd.import { childArgs } from './remote-ssh/control-master'-import { posixQuote, type SshConnection } from '../shared/ssh'+import { posixQuote, quoteRemotePath, type SshConnection } from '../shared/ssh'import type { DirEntry } from '../shared/types'export interface SshFsRef {@@ -17,19 +19,21 @@ function dirname(p: string): string {}export function sshListArgs(conn: SshConnection, cp: string, path: string): string[] {- return childArgs(conn, cp, `ls -Ap1 ${posixQuote(path)}`)+ return childArgs(conn, cp, `ls -Ap1 ${quoteRemotePath(path)}`)}export function sshReadArgs(conn: SshConnection, cp: string, path: string): string[] {- return childArgs(conn, cp, `cat ${posixQuote(path)}`)+ return childArgs(conn, cp, `cat ${quoteRemotePath(path)}`)}export function sshReadBinaryArgs(conn: SshConnection, cp: string, path: string): string[] {- return childArgs(conn, cp, `base64 ${posixQuote(path)}`)+ return childArgs(conn, cp, `base64 ${quoteRemotePath(path)}`)}export function sshWriteArgs(conn: SshConnection, cp: string, path: string): string[] {- return childArgs(conn, cp, `mkdir -p ${posixQuote(dirname(path))} && cat > ${posixQuote(path)}`)+ return childArgs(conn, cp, `mkdir -p ${quoteRemotePath(dirname(path))} && cat > ${quoteRemotePath(path)}`)}export function sshCheckIgnoreArgs(conn: SshConnection, cp: string, dir: string, names: string[]): string[] {- return childArgs(conn, cp, `git -C ${posixQuote(dir)} check-ignore -- ${names.map(posixQuote).join(' ')}`)+ // The dir is a remote path (may be tilde-prefixed) → quoteRemotePath; the entry NAMES are bare+ // filenames with no tilde → posixQuote literally (and inject-safe).+ return childArgs(conn, cp, `git -C ${quoteRemotePath(dir)} check-ignore -- ${names.map(posixQuote).join(' ')}`)}/** Parse `ls -Ap1` output → DirEntry[]: trailing-slash = dir, hide .git, folders-first alpha. */diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 30fba4040..4c2f9533f 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -924,10 +924,12 @@ export function Canvas() {}}, [mountRemoteMirror])- /** Open a file as a code editor node on the canvas. */+ /** Open a file as a code editor node on the canvas. `sshFs` must be passed explicitly by the+ * caller: only genuinely-remote, Explorer-opened files in an SSH project pass `true`; native+ * dialog / quick-open paths are LOCAL and stay local (so their ⌘S never writes to the host). */const openFile = useCallback(- (filePath: string, center?: { x: number; y: number }) => {- setNodes((ns) => [...ns, createEditorNode(ns.length, filePath, center ?? viewCenter())])+ (filePath: string, center?: { x: number; y: number }, sshFs?: boolean) => {+ setNodes((ns) => [...ns, createEditorNode(ns.length, filePath, center ?? viewCenter(), sshFs)])markDirty()},[setNodes, markDirty, viewCenter]@@ -2596,7 +2598,11 @@ export function Canvas() {{shortcutsOpen && <ShortcutsPanel onClose={() => setShortcutsOpen(false)} />}{explorerOpen && (- <ExplorerPanel onClose={() => setExplorerOpen(false)} onOpenFile={openFile} reveal={reveal} />+ <ExplorerPanel+ onClose={() => setExplorerOpen(false)}+ onOpenFile={(path, isSsh) => openFile(path, undefined, isSsh)}+ reveal={reveal}+ />)}<SessionsSidebardiff --git a/src/renderer/components/ExplorerPanel.tsx b/src/renderer/components/ExplorerPanel.tsxindex 5a40ff525..171799515 100644--- a/src/renderer/components/ExplorerPanel.tsx+++ b/src/renderer/components/ExplorerPanel.tsx@@ -6,7 +6,9 @@ import { sshFs } from '../terminal/ssh-fs'interface ExplorerPanelProps {onClose: () => void- onOpenFile: (path: string) => void+ /** Open a file as an editor node. `sshFs` is true for SSH projects (the path is remote, read/+ * written over the project's ControlMaster fs); false/omitted for local + relay projects. */+ onOpenFile: (path: string, sshFs?: boolean) => void/** 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@@ -153,6 +155,9 @@ export function ExplorerPanel({ onClose, onOpenFile, reveal }: ExplorerPanelProp() => (ssh && project ? sshFs(project.id) : window.nodeTerminal.fs),[project?.id, ssh])+ // Files opened from an SSH project's Explorer are genuinely remote — stamp `sshFs` so the editor+ // node routes its read/write over the project's ControlMaster fs (local/relay projects pass false).+ const handleOpenFile = useCallback<OpenFn>((path) => onOpenFile(path, !!ssh), [onOpenFile, ssh])const [roots, setRoots] = useState<DirEntry[] | null>(null)const [version, setVersion] = useState(0)const [selected, setSelected] = useState<string | null>(null)@@ -224,7 +229,7 @@ export function ExplorerPanel({ onClose, onOpenFile, reveal }: ExplorerPanelPropforcedOpen={forcedOpen}revealNonce={reveal?.nonce}onContext={onContext}- onOpenFile={onOpenFile}+ onOpenFile={handleOpenFile}onSelect={setSelected}/>))}diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex 7dc21accb..7905d9e65 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -3,7 +3,6 @@ import type { CanvasMutation, CanvasNodeState, NodeKind, Project } from '@sharedimport type { AgentId } from '@shared/agents/config'import { agentConfig } from '@shared/agents/config'import { useSettings } from './settings'-import { useProjects } from './projects'/** Preset color palette — macOS system colors (dark mode). */export const NODE_COLORS = [@@ -268,19 +267,19 @@ export function createClaudeNode(}/**- * Creates a code editor node for a file. When created in an SSH project (the active project has an- * `ssh` binding), `data.sshFs` is stamped so EditorNode reads/writes over the project's remote fs- * (`sshFs`) and `filePath` is the remote path — mirroring how `createTerminalNode` stamps- * `data.sshRemoteTmux`. The SSH binding is read from the projects store (the editor always belongs- * to the active project), so every open path (Explorer, palette) routes consistently.+ * Creates a code editor node for a file. When `sshFs` is true, `data.sshFs` is stamped so EditorNode+ * reads/writes over the project's remote fs (`sshFs`) and `filePath` is the remote path — mirroring+ * how `createTerminalNode` stamps `data.sshRemoteTmux`. The SSH-ness is passed EXPLICITLY by the+ * caller (only genuinely-remote, Explorer-opened files pass `true`); native-dialog-opened files+ * carry LOCAL paths and must stay local, so they omit it. (Self-detecting the active SSH project+ * here would wrongly stamp a dialog-opened local path and route its ⌘S write to the remote host.)*/export function createEditorNode(index: number,filePath: string,- center?: { x: number; y: number }+ center?: { x: number; y: number },+ sshFs?: boolean): CanvasNode {- const active = useProjects.getState()- const isSsh = !!active.getProject(active.activeProjectId)?.sshreturn {id: nextId('editor'),type: 'editor',@@ -293,7 +292,7 @@ export function createEditorNode(color: '#6ac4dc',group: null,filePath,- ...(isSsh ? { sshFs: true } : {})+ ...(sshFs ? { sshFs: true } : {})}}}