Skip to content

The agent that grows with you

fix(desktop): make the Windows SSH Test check the helper Connect requires

yoniebans41523aaa5164
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 2020eecf938..e7102ccb6c3 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -684,7 +684,8 @@ import {
detectRemotePlatform,
helper,
probeWindowsRemote,
- terminateOwnedWindowsDashboardForUpdate
+ terminateOwnedWindowsDashboardForUpdate,
+ windowsHelperOwnsRuntime
} from './windows-remote-lifecycle'
import {
alreadyHasNoSandbox,
@@ -10303,7 +10304,7 @@ async function testDesktopConnectionConfig(input: any = {}) {
hermesPath = runtime.hermesPath
const inspection = await helper(ssh, runtime, 'inspect', [runtime.hermesPath])
hermesVersion = inspection.version
- supported = inspection.supported
+ supported = inspection.supported && windowsHelperOwnsRuntime(runtime, inspection)
} else {
hermesPath = await remoteLifecycle.locateHermes(ssh, sshConfig.remoteHermesPath || '')
hermesVersion = await remoteLifecycle.probeHermesVersion(ssh, hermesPath)
diff --git a/apps/desktop/electron/windows-remote-lifecycle.ts b/apps/desktop/electron/windows-remote-lifecycle.ts
index 0ff0eebdf50..9ccd37e4f8d 100644
--- a/apps/desktop/electron/windows-remote-lifecycle.ts
+++ b/apps/desktop/electron/windows-remote-lifecycle.ts
@@ -669,6 +669,12 @@ async function waitForWindowsSpawnCompletion(ssh, runtime, ownershipId, timeoutM
throw error
}
+// A backend started through the launcher's boot-selecting runtime is recognised as
+// ours only by a helper that advertises it; an older one would orphan or refuse it.
+function windowsHelperOwnsRuntime(runtime, inspection) {
+ return !runtime.runtimeCommand || inspection?.runtimeBootstrapOwnership === 1
+}
+
async function connectWindowsRemote(deps) {
const {
ssh,
@@ -691,7 +697,7 @@ async function connectWindowsRemote(deps) {
await assertWindowsRemoteInstallUpdateClear(ssh, runtime.hermesHome, runtime.python)
const inspection = await helper(ssh, runtime, 'inspect', [runtime.hermesPath])
- if (runtime.runtimeCommand && inspection.runtimeBootstrapOwnership !== 1) {
+ if (!windowsHelperOwnsRuntime(runtime, inspection)) {
const error: any = new Error('The remote Windows SSH helper must be updated with boot-selecting runtime ownership support before connecting.')
error.kind = 'update-required'
throw error
@@ -913,5 +919,6 @@ export {
reusableWindowsLock,
stripPowerShellNoise,
terminateOwnedWindowsDashboardForUpdate,
- validLock
+ validLock,
+ windowsHelperOwnsRuntime
}
diff --git a/apps/desktop/electron/windows-ssh-repair.test.ts b/apps/desktop/electron/windows-ssh-repair.test.ts
index 30d54b597ea..a7e0afb373a 100644
--- a/apps/desktop/electron/windows-ssh-repair.test.ts
+++ b/apps/desktop/electron/windows-ssh-repair.test.ts
@@ -3,7 +3,7 @@ import assert from 'node:assert/strict'
import { test } from 'vitest'
import { listRemoteHermesProfiles, readRemoteInstallId } from './remote-lifecycle'
-import { assertWindowsRemoteInstallUpdateClear, connectWindowsRemote, probeWindowsRemote } from './windows-remote-lifecycle'
+import { assertWindowsRemoteInstallUpdateClear, connectWindowsRemote, probeWindowsRemote, windowsHelperOwnsRuntime } from './windows-remote-lifecycle'
const runtime = {
os: 'Windows', arch: 'AMD64', hermesHome: 'C:\\Users\\A\\AppData\\Local\\hermes',
@@ -130,3 +130,11 @@ test('the complete connect path keeps atomic spawn off argv and delivers the exp
assert.equal(spawned, true)
assert.equal(result.remotePort, 5555)
})
+
+test('Test and Connect share one verdict on a helper too old for a boot-selected backend', () => {
+ const selected = { ...runtime, runtimeCommand: [runtime.python, '-I', '-c', 'boot'] }
+
+ assert.equal(windowsHelperOwnsRuntime(selected, { supported: true }), false)
+ assert.equal(windowsHelperOwnsRuntime(selected, { supported: true, runtimeBootstrapOwnership: 1 }), true)
+ assert.equal(windowsHelperOwnsRuntime(runtime, { supported: true }), true)
+})