Skip to content

The agent that grows with you

fix(desktop): preserve typed Windows probe errors

lorenzozanee807849194f06
diff --git a/apps/desktop/electron/windows-remote-lifecycle.test.ts b/apps/desktop/electron/windows-remote-lifecycle.test.ts
index 9c2ea723330..c08a7d9e9e8 100644
--- a/apps/desktop/electron/windows-remote-lifecycle.test.ts
+++ b/apps/desktop/electron/windows-remote-lifecycle.test.ts
@@ -276,6 +276,29 @@ test('platform detection surfaces transport failures as themselves, not unsuppor
)
})
+test('platform detection preserves typed Windows probe failures', async () => {
+ const probeErr: any = new Error('PowerShell remote command failed with exit code 1')
+ probeErr.kind = 'exec-failed'
+
+ await assert.rejects(
+ detectRemotePlatform(
+ sshWith(async command => {
+ if (command.startsWith('uname ')) {
+ throw new Error('PowerShell does not recognize uname')
+ }
+
+ throw probeErr
+ })
+ ),
+ (err: any) =>
+ err.kind === 'exec-failed' &&
+ err.cause === probeErr &&
+ /Windows remote probe failed/.test(err.message) &&
+ /PowerShell remote command failed/.test(err.message) &&
+ !/operating system is not supported/.test(err.message)
+ )
+})
+
test('helper command uses the fixed remote Python entry point and quotes path data', () => {
const command = helperCommand({ python: "C:\\Program Files\\Hermes's\\python.exe" }, 'inspect', [
'C:\\x y\\hermes.exe'
diff --git a/apps/desktop/electron/windows-remote-lifecycle.ts b/apps/desktop/electron/windows-remote-lifecycle.ts
index ea387d514bc..41394a5de26 100644
--- a/apps/desktop/electron/windows-remote-lifecycle.ts
+++ b/apps/desktop/electron/windows-remote-lifecycle.ts
@@ -202,6 +202,8 @@ async function detectRemotePlatform(ssh, explicitHermesPath = '') {
throw cause
}
+ const kind = cause?.kind
+
// detail is remote-controlled output headed for the UI: redact + strip control chars.
const detail = redactSecrets(String(cause?.message || cause || ''))
// eslint-disable-next-line no-control-regex -- deliberately strip control chars from remote output
@@ -209,10 +211,10 @@ async function detectRemotePlatform(ssh, explicitHermesPath = '') {
.trim()
const error: any = new Error(
- `The remote operating system is not supported by Desktop SSH.${detail ? ` (probe: ${detail.slice(0, 300)})` : ''}`
+ `${kind ? 'The Windows remote probe failed.' : 'The remote operating system is not supported by Desktop SSH.'}${detail ? ` (probe: ${detail.slice(0, 300)})` : ''}`
)
- error.kind = 'unsupported-platform'
+ error.kind = kind || 'unsupported-platform'
error.cause = cause
throw error
}