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): refuse the OS open where a browser tab cannot perform it

albaneselorenzo5bcaed7cefb6
diff --git a/src/renderer/lib/download.test.ts b/src/renderer/lib/download.test.ts
index fd5fca89b..efb7192f8 100644
--- a/src/renderer/lib/download.test.ts
+++ b/src/renderer/lib/download.test.ts
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
-import { canRevealLocally, downloadRoute } from './download'
+import { canRevealLocally, canUseLocalShell, downloadRoute } from './download'
describe('downloadRoute', () => {
it('pulls an SSH project over scp on the desktop', () => {
@@ -35,3 +35,30 @@ describe('canRevealLocally', () => {
expect(canRevealLocally({ browser: false, ssh: false, source: 'relay' })).toBe(false)
})
})
+
+describe('canUseLocalShell', () => {
+ // The Server Edition bug this predicate was extracted for: a browser tab's session source is
+ // 'local' (SessionSource's 'server' is declared but never constructed), so `source` alone can
+ // never tell you you are in a browser — only `isBrowserRuntime()` can. `shell.openPath` is a
+ // `noop` stub there, so an ungated call on a .zip or .dmg was a silent dead click.
+ it('is false in a browser tab even though its session source is local', () => {
+ expect(canUseLocalShell({ browser: true, ssh: false, source: 'local' })).toBe(false)
+ })
+
+ it('is true only for a desktop shell acting on this machine', () => {
+ expect(canUseLocalShell({ browser: false, ssh: false, source: 'local' })).toBe(true)
+ expect(canUseLocalShell({ browser: false, ssh: true, source: 'local' })).toBe(false)
+ expect(canUseLocalShell({ browser: false, ssh: false, source: 'relay' })).toBe(false)
+ })
+
+ // One rule, not two that drift: reveal was gated and openPath was not, which is how the
+ // Server Edition ended up with a dead click on one member of the same namespace.
+ it('is the same rule reveal already used', () => {
+ for (const browser of [true, false])
+ for (const ssh of [true, false])
+ for (const source of ['local', 'relay', 'server'] as const)
+ expect(canUseLocalShell({ browser, ssh, source })).toBe(
+ canRevealLocally({ browser, ssh, source })
+ )
+ })
+})
diff --git a/src/renderer/lib/download.ts b/src/renderer/lib/download.ts
index 388845b2e..a59dfe90d 100644
--- a/src/renderer/lib/download.ts
+++ b/src/renderer/lib/download.ts
@@ -42,15 +42,27 @@ export function downloadRoute({ browser, ssh, source }: DownloadContext): Downlo
}
/**
- * True when "Reveal in Finder" can actually do something: an Electron shell, showing paths that
- * are on THIS machine. It was previously offered unconditionally — on an SSH project it handed a
- * remote path to the local file manager, and in a browser tab it is an inert stub. Both were
- * silent no-ops, which reads as a broken app rather than as an unavailable feature.
+ * True when this machine's Electron `shell.*` can actually act on a path the UI is showing:
+ * an Electron shell (both members are `noop` stubs in a browser tab — see `bridge/stubs.ts`),
+ * and a path that is on THIS machine (an SSH host's or a relay peer's is not).
+ *
+ * ONE predicate for every `shell.*` path action, because they share one precondition for one
+ * reason. `reveal` was gated first; `openPath` was not, and a `.zip` in the Server Edition's file
+ * manager was therefore a silent dead click. Writing that rule a second time beside this one is
+ * how the two would drift apart again.
*/
-export function canRevealLocally({ browser, ssh, source }: DownloadContext): boolean {
+export function canUseLocalShell({ browser, ssh, source }: DownloadContext): boolean {
return !browser && !ssh && source !== 'relay'
}
+/**
+ * True when "Reveal in Finder" can actually do something. It was previously offered
+ * unconditionally — on an SSH project it handed a remote path to the local file manager, and in a
+ * browser tab it is an inert stub. Both were silent no-ops, which reads as a broken app rather
+ * than as an unavailable feature.
+ */
+export const canRevealLocally = canUseLocalShell
+
/**
* Start a browser download for `url` without navigating the page. An anchor with `download` is
* used rather than `location.assign` so a response that (for any reason) lacks
diff --git a/src/renderer/nodes/FilesNode.tsx b/src/renderer/nodes/FilesNode.tsx
index 9997c9086..a332e1bdb 100644
--- a/src/renderer/nodes/FilesNode.tsx
+++ b/src/renderer/nodes/FilesNode.tsx
@@ -40,6 +40,7 @@ import { useProjects } from '../state/projects'
import { promptDialog } from '../components/promptDialog'
import { ContextMenu, type MenuItem } from '../components/ContextMenu'
import { isBrowserRuntime } from '../bridge/runtime'
+import { canUseLocalShell } from '../lib/download'
/** Surface a transient error the way every other node does (Canvas listens for this). */
const toast = (message: string): void => {
@@ -87,9 +88,10 @@ export function FilesNode({ id, data, selected }: NodeProps<CanvasNode>) {
const fs = isSshFs && activeProjectId ? sshFs(activeProjectId) : api.fs
/** A listing this machine's OS cannot act on: an SSH host's files, or a relay peer's. */
const remote = isSshFs || source === 'relay'
- /** `shell.*` is Electron-only — in the browser the reveal row would be a button that does
- * nothing, which teaches less than not offering it. */
- const canReveal = !remote && !isBrowserRuntime()
+ /** The ONE precondition every `shell.*` path action shares: an Electron shell, and a path on
+ * THIS machine. Both members are `noop` stubs in a browser tab, so an ungated call is a dead
+ * click — which is what "Reveal" was written to avoid and what `openPath` still did. */
+ const localShell = canUseLocalShell({ browser: isBrowserRuntime(), ssh: isSshFs, source })
useEffect(() => {
let live = true
@@ -162,6 +164,14 @@ export function FilesNode({ id, data, selected }: NodeProps<CanvasNode>) {
return
}
if (fileOpenTarget(path, { remote }) === 'os') {
+ // `fileOpenTarget` has already refused a remote path, so the only way to be here without
+ // a usable shell is a browser tab — where `openPath` is an inert stub and the click would
+ // simply do nothing. Say so instead: an unavailable feature that explains itself reads
+ // better than an app that looks broken.
+ if (!localShell) {
+ toast(`“${entry.name}” can only be opened by the desktop app — a browser tab cannot hand a file to your operating system.`)
+ return
+ }
api.shell.openPath(path)
return
}
@@ -171,7 +181,7 @@ export function FilesNode({ id, data, selected }: NodeProps<CanvasNode>) {
new CustomEvent('nodeterm:open-file', { detail: { path, ssh: isSshFs } })
)
},
- [cwd, navigate, remote, api, isSshFs]
+ [cwd, navigate, remote, api, isSshFs, localShell]
)
/** Create a file or a folder under `dir`, then re-list. Shared by both menu rows because the
@@ -242,12 +252,12 @@ export function FilesNode({ id, data, selected }: NodeProps<CanvasNode>) {
label: 'Copy path',
onClick: () => api.clipboard.writeText(path)
})
- if (canReveal) {
+ if (localShell) {
items.push({ label: 'Reveal in file manager', onClick: () => api.shell.reveal(path) })
}
setMenu({ x: e.clientX, y: e.clientY, items })
},
- [cwd, open, create, api, canReveal]
+ [cwd, open, create, api, localShell]
)
const toggleCollapse = () =>