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): headless start refuses an SSH node before any claim (#925)

review9db663c4ce6b
diff --git a/src/renderer/lib/headlessRun.test.ts b/src/renderer/lib/headlessRun.test.ts
index 50983a455..a5a55657f 100644
--- a/src/renderer/lib/headlessRun.test.ts
+++ b/src/renderer/lib/headlessRun.test.ts
@@ -125,6 +125,36 @@ describe('startHeadless', () => {
expect(d.inFlight.size).toBe(0)
})
+ // A remote node is NEVER spawned locally: the headless path builds LOCAL pty options, so an SSH
+ // node is refused before any claim and keeps its queued launch for the ordinary on-view start.
+ it.each([
+ ['sshRemoteTmux', { sshRemoteTmux: true }],
+ ['ssh', { ssh: { host: 'example.com' } as unknown as CanvasNodeState['ssh'] }]
+ ] as const)('an SSH node (%s) is refused before any claim, save or launch', async (_label, over) => {
+ const { d, saved } = deps({ outcome: 'delivered', fresh: true })
+ expect(await startHeadless(d, { project, node: node(over) })).toEqual({
+ id: 'n1',
+ started: false,
+ reason: 'remote-unsupported'
+ })
+ expect(d.savePending).not.toHaveBeenCalled()
+ expect(d.launch).not.toHaveBeenCalled()
+ expect(d.markStarting).not.toHaveBeenCalled()
+ expect(d.markFailed).not.toHaveBeenCalled()
+ expect(d.clearDelivery).not.toHaveBeenCalled()
+ expect(saved).toHaveLength(0)
+ expect(d.inFlight.size).toBe(0)
+ })
+
+ it('an SSH node is refused even while the same id is in flight (no inFlight read or mutation)', async () => {
+ const { d } = deps({ outcome: 'delivered', fresh: true })
+ d.inFlight.add('n1')
+ expect(await startHeadless(d, { project, node: node({ sshRemoteTmux: true }) })).toMatchObject({
+ reason: 'remote-unsupported'
+ })
+ expect([...d.inFlight]).toEqual(['n1'])
+ })
+
it('a node with nothing queued is not started', async () => {
const { d } = deps({ outcome: 'delivered', fresh: true })
expect(await startHeadless(d, { project, node: node({ pendingLaunch: undefined }) })).toEqual({
diff --git a/src/renderer/lib/headlessRun.ts b/src/renderer/lib/headlessRun.ts
index c308d72d7..e0f32bd7b 100644
--- a/src/renderer/lib/headlessRun.ts
+++ b/src/renderer/lib/headlessRun.ts
@@ -1,6 +1,7 @@
// Canvas-control headless start (#925): `open-* --run-now` and `run --node`. Pure planners plus
// one orchestrator with injected effects, so Canvas.tsx only wires. See the spec (§4) for the flow:
// write-ahead claim → launch through main → patch the node wherever it lives NOW.
+// Headless starts are local-only: a remote (SSH) node is refused here, before any claim.
import type { CanvasNodeState, PendingLaunch, Project, PtyCreateOptions } from '@shared/types'
import type { HeadlessLaunchFailure, HeadlessLaunchResult } from '@shared/headless-launch'
import { HEADLESS_COLS, HEADLESS_ROWS, localNodePtyOptions } from '@shared/node-pty-options'
@@ -40,7 +41,12 @@ export type HeadlessStartOutcome =
| {
id: string
started: false
- reason: HeadlessLaunchFailure | 'already-starting' | 'claim-not-saved' | 'nothing-queued'
+ reason:
+ | HeadlessLaunchFailure
+ | 'already-starting'
+ | 'claim-not-saved'
+ | 'nothing-queued'
+ | 'remote-unsupported'
}
export interface HeadlessStartDeps {
@@ -62,6 +68,9 @@ export async function startHeadless(
const id = node.id
const original = node.pendingLaunch
if (!original?.command) return { id, started: false, reason: 'nothing-queued' }
+ // A remote node is NEVER spawned locally. The options below are LOCAL (no requireRemote), so
+ // refuse before touching anything: the untouched pending launch starts on view, over SSH.
+ if (node.ssh || node.sshRemoteTmux) return { id, started: false, reason: 'remote-unsupported' }
if (deps.inFlight.has(id)) return { id, started: false, reason: 'already-starting' }
deps.inFlight.add(id)
try {