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(windows): do not require ssh.exe for SSH projects on the native transport

reviewde90e736a17a
diff --git a/src/core/pty-manager.ts b/src/core/pty-manager.ts
index 0e7282b15..2d59d967b 100644
--- a/src/core/pty-manager.ts
+++ b/src/core/pty-manager.ts
@@ -61,7 +61,7 @@ import {
type RelayRemoteRef
} from './relay-attach-plan'
import { RemoteSessionIndex, type SessionVerdict } from './remote-ssh/remote-session-index'
-import { isSshProgram, nativeExecFileAsync, nativeMux, useNativeSsh } from './remote-ssh/native/native-runtime'
+import { isSshProgram, nativeExecFileAsync, nativeMux, resolveSshProgram, useNativeSsh } from './remote-ssh/native/native-runtime'
import { NativeSshPty } from './remote-ssh/native/native-pty'
import { remotePtySpawnGate, type SpawnSlot } from './remote-ssh/pty-spawn-gate'
import type { SshConnection } from '../shared/ssh'
@@ -514,8 +514,6 @@ function findTmux(resourcesPath?: string): string | null {
})
}
-/** Resolve an absolute ssh path (GUI apps don't inherit the shell PATH). */
-let cachedSsh: string | null | undefined
/**
* macOS-only diagnostic for the recurring release-clobber incident: `electron-builder --x64`
* rebuilds node-pty IN PLACE in node_modules, leaving an x86_64 spawn-helper that an arm64 app
@@ -549,14 +547,14 @@ function spawnHelperArchMismatch(): string | null {
return null
}
+/**
+ * The ssh program for remote side-calls and remote terminals (native-runtime.ts
+ * `resolveSshProgram`): the binary, else — under the native transport only — the `ssh` sentinel
+ * every runner here routes to NativeMux (runAsync / runWithStdin / NativeSshPty), so a Windows
+ * machine without the OpenSSH Client feature is not refused as "no ssh". POSIX: unchanged.
+ */
function findSsh(): string | null {
- if (cachedSsh !== undefined) return cachedSsh
- // Subprocess-free (was a sync login-shell `command -v ssh` + an `ssh -V` spawn per fallback,
- // all blocking the main thread). A MISS is only memoized once the async login-shell PATH
- // probe has settled — before that a custom-location ssh would be cached away forever.
- const found = findExecutableSync('ssh', ['/usr/bin/ssh', '/usr/local/bin/ssh', '/opt/homebrew/bin/ssh'])
- if (found || shellPathNow() !== undefined) cachedSsh = found
- return found
+ return resolveSshProgram()
}
// resolveShellPath (the one async login-shell PATH probe) lives in exec-path.ts now, shared by
diff --git a/src/core/pty-watch-join.test.ts b/src/core/pty-watch-join.test.ts
index ac7810716..0fa3dfe1a 100644
--- a/src/core/pty-watch-join.test.ts
+++ b/src/core/pty-watch-join.test.ts
@@ -461,6 +461,24 @@ describe('joinAsWatcher over SSH', () => {
})
})
+describe('spawnRefusal with no ssh binary (Windows without the OpenSSH Client feature)', () => {
+ const SSH_REMOTE = { controlPath: '/tmp/nt-test-cm', conn: { host: 'h', user: 'u' }, remoteCwd: '/srv/app' }
+ const opts = { cols: 80, rows: 24, persistKey: 'n-native', sshRemote: SSH_REMOTE, requireRemote: true } as PtyCreateOptions
+ afterEach(() => vi.unstubAllEnvs())
+
+ it('refused as ssh where ssh is a process; served where the native transport carries it', async () => {
+ ssh.path = null
+ const m = await manager()
+ const refusal = (o: PtyCreateOptions): string | undefined =>
+ (m as unknown as { spawnRefusal(o: PtyCreateOptions): string | undefined }).spawnRefusal(o)
+ vi.stubEnv('NODETERM_NATIVE_SSH', '0')
+ expect(refusal(opts)).toBe('ssh')
+ // The `ssh` sentinel every runner routes to NativeMux: nothing is spawned from it.
+ vi.stubEnv('NODETERM_NATIVE_SSH', '1')
+ expect(refusal(opts)).toBeUndefined()
+ })
+})
+
describe('joinAsWatcher (continued)', () => {
it('the join-only, non-voting rules are FORCED — a caller cannot turn them off', async () => {
const m = await manager()
diff --git a/src/core/remote-ssh/agent-probe.ts b/src/core/remote-ssh/agent-probe.ts
index 058fe965e..8a8470e29 100644
--- a/src/core/remote-ssh/agent-probe.ts
+++ b/src/core/remote-ssh/agent-probe.ts
@@ -34,7 +34,7 @@
// behavior, one passphrase prompt at worst. Never a blocked connect.
import { execFile } from 'child_process'
import path from 'path'
-import { findExecutableSync } from '../exec-path'
+import { findSshBinary } from './native/native-runtime'
import type { SshConnection } from '../../shared/ssh'
/** `ssh -G` may run the user's own `Match exec` commands; bound it so a hung one cannot stall a
@@ -45,8 +45,9 @@ const PROBE_TIMEOUT_MS = 3_000
* picked up on the next reconnect without restarting the app. */
const PROBE_TTL_MS = 15_000
+/** The real ssh BINARY (never the native sentinel): this probe execs `ssh -G` itself. */
function findSsh(): string | null {
- return findExecutableSync('ssh', ['/usr/bin/ssh', '/usr/local/bin/ssh', '/opt/homebrew/bin/ssh'])
+ return findSshBinary()
}
/** The `identityagent` line of an `ssh -G` dump, verbatim, or undefined when the effective config
diff --git a/src/core/remote-ssh/remote-git.ts b/src/core/remote-ssh/remote-git.ts
index adcd3a55e..08f327fbb 100644
--- a/src/core/remote-ssh/remote-git.ts
+++ b/src/core/remote-ssh/remote-git.ts
@@ -6,8 +6,7 @@
import { execFile } from 'child_process'
import { promisify } from 'util'
import { childArgs } from './control-master'
-import { nativeExecFileAsync, useNativeSsh } from './native/native-runtime'
-import { findExecutableSync, shellPathNow } from '../exec-path'
+import { nativeExecFileAsync, resolveSshProgram, useNativeSsh } from './native/native-runtime'
import { posixQuote, quoteRemotePath, type SshConnection } from '../../shared/ssh'
const run = promisify(execFile)
@@ -22,20 +21,9 @@ export function remoteGitArgs(conn: SshConnection, controlPath: string, cwd: str
return childArgs(conn, controlPath, remote)
}
-let sshPath: string | null | undefined
+/** The shared resolver (native-runtime.ts): the binary, or the native-transport sentinel. */
function findSsh(): string | null {
- if (sshPath !== undefined) return sshPath
- // GUI apps don't inherit the shell PATH. Subprocess-free (was a sync login-shell probe plus
- // an `ssh -V` spawn per candidate, blocking the main thread): walk the cached login-shell
- // PATH from exec-path.ts, then the hardcoded locations. A MISS is only memoized once the
- // async PATH probe has settled, so a custom-location ssh isn't cached away forever.
- const found = findExecutableSync('ssh', [
- '/usr/bin/ssh',
- '/usr/local/bin/ssh',
- '/opt/homebrew/bin/ssh'
- ])
- if (found || shellPathNow() !== undefined) sshPath = found
- return found
+ return resolveSshProgram()
}
/** Run a git command on the remote over the master. Returns the same shape as the local git() helper. */