Skip to content

The agent that grows with you

fix(desktop): show the PowerShell error behind a failed Windows probe

10523263116417181769fd
diff --git a/apps/desktop/electron/windows-remote-lifecycle.test.ts b/apps/desktop/electron/windows-remote-lifecycle.test.ts
index 395ae4d9574..1d960179b95 100644
--- a/apps/desktop/electron/windows-remote-lifecycle.test.ts
+++ b/apps/desktop/electron/windows-remote-lifecycle.test.ts
@@ -666,6 +666,24 @@ test('platform detection surfaces transport failures as themselves, not unsuppor
),
(err: any) => err.kind === 'unsupported-platform' && /Hermes is not installed/.test(err.message)
)
+
+ await assert.rejects(
+ detectRemotePlatform(
+ sshWith(async command => {
+ if (command.startsWith('uname ')) {
+ throw new Error('not recognized')
+ }
+
+ throw new Error(
+ '#< CLIXML <Objs><S S="progress">module load</S><S S="Error">The remote Hermes Python runtime was not found._x000D__x000A_</S></Objs>'
+ )
+ })
+ ),
+ (err: any) =>
+ err.kind === 'unsupported-platform' &&
+ /probe: The remote Hermes Python runtime was not found\./.test(err.message) &&
+ !/CLIXML|module load/.test(err.message)
+ )
})
test('platform detection preserves typed Windows probe failures', async () => {
diff --git a/apps/desktop/electron/windows-remote-lifecycle.ts b/apps/desktop/electron/windows-remote-lifecycle.ts
index 568ce065459..fca9dca40ec 100644
--- a/apps/desktop/electron/windows-remote-lifecycle.ts
+++ b/apps/desktop/electron/windows-remote-lifecycle.ts
@@ -299,6 +299,20 @@ const TRANSPORT_KINDS = new Set([
SSH_ERROR.UNREACHABLE
])
+function powerShellErrorDetail(value) {
+ const raw = String(value || '')
+ const errors = [...raw.matchAll(/<S S="Error">([\s\S]*?)<\/S>/g)].map(match => match[1])
+ const detail = errors.length ? errors.join(' ') : raw
+
+ return detail
+ .replace(/_x([0-9a-fA-F]{4})_/g, (_, hex) => String.fromCharCode(Number.parseInt(hex, 16)))
+ .replace(/&lt;/g, '<')
+ .replace(/&gt;/g, '>')
+ .replace(/&quot;/g, '"')
+ .replace(/&apos;/g, "'")
+ .replace(/&amp;/g, '&')
+}
+
async function detectRemotePlatform(ssh, explicitHermesPath = '') {
try {
const output = (await ssh.exec('uname -s; uname -m')).trim().split('\n')
@@ -325,7 +339,7 @@ async function detectRemotePlatform(ssh, explicitHermesPath = '') {
const kind = cause?.kind
// detail is remote-controlled output headed for the UI: redact + strip control chars.
- const detail = redactSecrets(String(cause?.message || cause || ''))
+ const detail = redactSecrets(powerShellErrorDetail(cause?.message || cause || ''))
// eslint-disable-next-line no-control-regex -- deliberately strip control chars from remote output
.replace(/[\x00-\x1f\x7f]/g, ' ')
.trim()