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(canvas-control): nodes an agent opens in an SSH project run on the HOST
enes4dd251581771
diff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.tsindex 6cc0cf2ca..231a1a14e 100644--- a/src/main/canvas-control-core.ts+++ b/src/main/canvas-control-core.ts@@ -306,6 +306,10 @@ Verbs:- \`show-video <path>\` — open a video file as a player node.- \`show-web (--url U | --file P.html | --html "<...>")\` — open a web viewer (live URL or local HTML you wrote).- \`open-browser --url U\` — open a navigable browser (back/forward/address bar) at a URL.+ In an SSH project, nodes you open run on the HOST (same machine as you). The media viewers are+ the exception: they read the DESKTOP's disk, so \`show-image\` works (it reads back over the+ connection) but \`show-video\` and \`show-web --file/--html\` are refused for a host path —+ use \`--url\`, or copy the file to the desktop first.- \`group --nodes <id,id> [--label "Frontend Team"]\` — wrap nodes in a labeled group frame.- \`arrange --nodes <id,id> [--layout grid|row|column] [--cols N]\` — tidy layout, no overlap.- \`align --nodes <id,id> --edge left|right|top|bottom|hcenter|vcenter\` — align edges/centers.diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex e2ae85755..9b24e27ea 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -240,6 +240,7 @@ import {createSshTerminalNode,createStickyNode,createTerminalNode,+ nodeSshFor,createVideoNode,createWebNode,isVideoFile,@@ -325,6 +326,13 @@ interface PendingPeerState {const WORKTREE_SSH_HINT = 'Not supported in SSH projects yet'const WORKTREE_SSH_NOTICE = 'Worktrees are not supported in SSH projects yet.'+// Media nodes render off the LOCAL disk (the video allowlist and the webview's file loader have+// no remote counterpart), so a host path from a remote agent could only resolve to a same-named+// local file — or nothing. Refuse and say why, rather than opening a node that quietly shows the+// wrong thing. `%s` is the verb.+const MEDIA_SSH_NOTICE =+ '%s cannot render a file from an SSH project: the viewer reads the local disk, and this path is on the remote host. Use --url, or copy the file to this machine first.'+// Group labels counter-scale when zoomed OUT so they stay readable/clickable from afar// (like map labels): full inverse of the zoom, capped so far-out labels don't get huge,// and never below 1 (zooming IN doesn't shrink them). Written as a CSS var once per@@ -4963,6 +4971,18 @@ export function Canvas() {}const srcTitle = (src.data.title as string) || sourceNodeIdconst srcCwd = src.data.cwd as string | undefined+ // SSH projects: a node an agent opens has to run on the SAME host the agent runs on.+ // Without this the factories build a LOCAL node carrying a REMOTE cwd — it opens on the+ // desktop, in a directory that does not exist there. (The handoff path spelled this out and+ // got it right; every control verb passed `undefined` and got it wrong.) The factory reads+ // the node's cwd out of `remoteCwd`, so the effective cwd is threaded through there —+ // otherwise `--cwd` would be silently replaced by the project root.+ const ctlProject = (() => {+ const st = useProjects.getState()+ return st.getProject(st.activeProjectId ?? '')+ })()+ const ctlSsh = ctlProject?.ssh+ const sshFor = (cwd?: string) => nodeSshFor(ctlSsh, cwd)// Place opened nodes BELOW the source and rope them to it (source flow-out → target// flow-in), mirroring how subagent/loop nodes attach — so they read as "hanging off" the// conversation instead of landing on top of unrelated nodes. `placeBelow` returns a node@@ -5165,13 +5185,15 @@ export function Canvas() {: undefinedconst after = resolveAfter()if (after === null) return // bad --after, already replied+ const termCwd = args.cwd || groupCwd || srcCwdconst make = (i: number): CanvasNode =>armAfter(createTerminalNode(nodesRef.current.length + i,- args.cwd || groupCwd || srcCwd,+ termCwd,placeBelow(i),- args.cmd+ args.cmd,+ sshFor(termCwd)),after ?? [])@@ -5211,15 +5233,16 @@ export function Canvas() {)const after = resolveAfter()if (after === null) return // bad --after, already replied+ const agentCwd = args.cwd || groupCwd || srcCwdconst make = (i: number): CanvasNode =>armAfter(createAgentNode(agentId,nodesRef.current.length + i,- args.cwd || groupCwd || srcCwd,+ agentCwd,placeBelow(i),args.prompt,- undefined,+ sshFor(agentCwd),account,activePermissionMode()),@@ -5263,8 +5286,13 @@ export function Canvas() {return}// EditorNode renders images via fs:read-binary → base64 data URL (not nt-media://),- // so no media allowlist entry is needed here.- const id = addAndConnect(createEditorNode(nodesRef.current.length, args.path, placeBelow()))+ // so no media allowlist entry is needed here. On an SSH project the path the agent+ // gave us is on the HOST, so the node has to read through the project's remote fs+ // (`sshFs` routes fs.readBinary over the ControlMaster) — reading it locally would+ // either miss or, worse, open a same-named local file.+ const id = addAndConnect(+ createEditorNode(nodesRef.current.length, args.path, placeBelow(), !!ctlSsh)+ )reply({ ok: true, message: `showing image ${id}`, result: { id } })return}@@ -5273,6 +5301,14 @@ export function Canvas() {reply({ ok: false, error: 'show-video requires --path' })return}+ // The video node streams through the LOCAL media allowlist, which has no remote+ // counterpart — so on an SSH project a host path could only ever resolve to a local+ // file of the same name, or nothing. Refuse with the reason rather than opening a+ // node that silently shows the wrong thing (same call as worktrees-on-SSH).+ if (ctlSsh) {+ reply({ ok: false, error: MEDIA_SSH_NOTICE.replace('%s', 'show-video') })+ return+ }await window.nodeTerminal.media.allow(args.path)const id = addAndConnect(createVideoNode(nodesRef.current.length, args.path, placeBelow()))reply({ ok: true, message: `showing video ${id}`, result: { id } })@@ -5280,6 +5316,14 @@ export function Canvas() {}case 'show-web': {let webSrc: { url?: string; filePath?: string }+ // A --url is host-independent and works from anywhere. A FILE is not: the webview+ // loads it off the local disk, and on an SSH project the agent's path lives on the+ // host. (--html is written locally by main, but a remote agent asking us to render+ // its HTML would still be reaching across the same gap.)+ if (ctlSsh && !args.url) {+ reply({ ok: false, error: MEDIA_SSH_NOTICE.replace('%s', 'show-web --file/--html') })+ return+ }if (args.url) webSrc = { url: args.url }else if (args.file) webSrc = { filePath: args.file }else if (args.html) {@@ -5452,7 +5496,7 @@ export function Canvas() {shimPath: vShim,focus: args.focus}),- undefined,+ sshFor(targetCwd),vAccount,vMode)@@ -5476,7 +5520,7 @@ export function Canvas() {agentId: reviewAgent,shimPath: vShim}),- undefined,+ sshFor(targetCwd),vAccount,vMode)@@ -5556,7 +5600,7 @@ export function Canvas() {srcCwd,placeBelow(i),r.prompt,- undefined,+ sshFor(srcCwd),teamAccount,activePermissionMode())diff --git a/src/renderer/state/workspace.test.ts b/src/renderer/state/workspace.test.tsindex 614b4fe52..ac82fd06c 100644--- a/src/renderer/state/workspace.test.ts+++ b/src/renderer/state/workspace.test.ts@@ -6,6 +6,7 @@ import {flowToNodeStates,groupSelectedNodes,nodeStatesToFlow,+ nodeSshFor,reorderNodeBefore,reparentNode,resolveNewNodeAccount,@@ -254,6 +255,39 @@ describe('accountId serialization', () => {})})+describe('nodeSshFor', () => {+ const projectSsh = {+ server: { host: 'h', user: 'u' },+ remoteCwd: '/srv/app'+ } as unknown as NonNullable<Parameters<typeof nodeSshFor>[0]>++ it('is undefined for a local project, so nothing changes there', () => {+ expect(nodeSshFor(undefined)).toBeUndefined()+ expect(nodeSshFor(undefined, '/some/dir')).toBeUndefined()+ })++ it('threads the caller cwd through remoteCwd — the factories read a node cwd from there', () => {+ // Passing the project's ssh unchanged would silently replace an explicit --cwd with the+ // project root, which is the second half of this bug.+ expect(nodeSshFor(projectSsh, '/srv/app/sub')).toEqual({+ server: projectSsh.server,+ remoteCwd: '/srv/app/sub'+ })+ })++ it('falls back to the project root when no cwd is given', () => {+ expect(nodeSshFor(projectSsh)).toEqual({ server: projectSsh.server, remoteCwd: '/srv/app' })+ expect(nodeSshFor(projectSsh, '')).toEqual({ server: projectSsh.server, remoteCwd: '/srv/app' })+ })++ it('produces a node that actually runs on the host (remote tmux, remote cwd)', () => {+ const node = createAgentNode('claude', 0, undefined, undefined, undefined, nodeSshFor(projectSsh, '/srv/app/sub'))+ expect(node.data.sshRemoteTmux).toBe(true)+ expect(node.data.ssh).toEqual(projectSsh.server)+ expect(node.data.cwd).toBe('/srv/app/sub')+ })+})+describe('pendingLaunch round-trip', () => {// Unlike initialCommand (one-shot, deliberately NOT persisted), an armed node's held launch// must survive a reload — the station it waits on can take hours, and a restart in betweendiff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex 690ac62d4..8fdb45681 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -160,6 +160,24 @@ function terminalNodeSize(): { width: number; height: number } {* (the active SSH project's binding) is given, the node runs in REMOTE tmux on that host: its* `data.ssh`/`data.sshRemoteTmux`/`data.cwd` are stamped from the binding instead of `cwd`.*/+/**+ * The `ssh` argument a node factory needs so a new node runs on the SAME host as the project.+ *+ * Two things are easy to get wrong here, and both have shipped as bugs: passing `undefined` on an+ * SSH project builds a LOCAL node carrying a REMOTE cwd — it opens on the desktop, in a directory+ * that does not exist there — and passing the project's `ssh` unchanged silently REPLACES the+ * caller's cwd, because the factories read a node's cwd out of `remoteCwd`. So the effective cwd+ * is threaded through `remoteCwd`, and a local project still yields `undefined` (byte-identical to+ * the pre-SSH behaviour).+ */+export function nodeSshFor(+ projectSsh: Project['ssh'] | undefined,+ cwd?: string+): Project['ssh'] | undefined {+ if (!projectSsh) return undefined+ return { server: projectSsh.server, remoteCwd: cwd || projectSsh.remoteCwd }+}+export function createTerminalNode(index: number,cwd?: string,