Skip to content

The agent that grows with you

fix(desktop): show the cause of an unclassified SSH connection failure

yoniebans362e79f46267
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index e7102ccb6c3..39bc7cc1d0f 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -10340,7 +10340,7 @@ async function testDesktopConnectionConfig(input: any = {}) {
}
}
} catch (error: any) {
- return { reachable: false, sshError: error.kind || 'unknown', error: error.message }
+ return { reachable: false, sshError: error.kind || 'unknown', error: redactSecrets(String(error?.message || error)) }
} finally {
try {
await ssh.close()
diff --git a/apps/desktop/src/app/settings/gateway-settings.test.tsx b/apps/desktop/src/app/settings/gateway-settings.test.tsx
index 4872c1de0ba..dd722857afc 100644
--- a/apps/desktop/src/app/settings/gateway-settings.test.tsx
+++ b/apps/desktop/src/app/settings/gateway-settings.test.tsx
@@ -549,6 +549,38 @@ describe('GatewaySettings', () => {
})
})
+ it('shows the remote cause for an unclassified SSH test failure, not the generic copy', async () => {
+ getConnectionConfig.mockResolvedValue({
+ ...localConnection,
+ mode: 'ssh',
+ sshHost: 'build-box',
+ sshUser: '',
+ sshPort: 22,
+ sshKeyPath: '',
+ sshRemoteHermesPath: '',
+ sshRemoteProfile: ''
+ })
+ const cause = 'The Windows remote probe failed. (probe: Path was not found: C:\\h\\bin\\python.exe)'
+ const testConnectionConfig = vi.fn().mockResolvedValue({ reachable: false, sshError: 'unknown', error: cause })
+ Object.assign(window.hermesDesktop, { testConnectionConfig })
+
+ render(<GatewaySettings />)
+ fireEvent.click(await screen.findByRole('button', { name: 'Test SSH' }))
+
+ try {
+ await waitFor(() =>
+ expect($notifications.get()).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({ kind: 'error', message: expect.stringContaining('Path was not found') })
+ ])
+ )
+ )
+ expect($notifications.get().some((n: { message?: string }) => n.message === 'SSH connection failed.')).toBe(false)
+ } finally {
+ $notifications.set([])
+ }
+ })
+
it('surfaces the Tailscale browser-check guidance for an interactive-auth SSH test failure', async () => {
getConnectionConfig.mockResolvedValue({
...localConnection,
diff --git a/apps/desktop/src/app/settings/gateway-settings.tsx b/apps/desktop/src/app/settings/gateway-settings.tsx
index b0ff8236638..63a0b3930ac 100644
--- a/apps/desktop/src/app/settings/gateway-settings.tsx
+++ b/apps/desktop/src/app/settings/gateway-settings.tsx
@@ -616,7 +616,7 @@ function GatewayConnectionSettings({ embedded, standalone }: { embedded: boolean
notify({
kind: 'error',
title: apply ? g.applyFailed : g.saveFailed,
- message: (errors as Record<string, string>)[sshError] || g.sshErrUnknown
+ message: (errors as Record<string, string>)[sshError] || readableError(err, g.sshErrUnknown).message
})
} else {
notifyError(err, apply ? g.applyFailed : g.saveFailed)
@@ -1022,7 +1022,12 @@ function GatewayConnectionSettings({ embedded, standalone }: { embedded: boolean
unknown: g.sshErrUnknown
}
- throw new Error(errors[result.sshError || 'unknown'] || result.error || g.sshErrUnknown)
+ // An unclassified failure carries its own cause (the remote probe's error); the generic copy would hide it.
+ throw new Error(
+ (result.sshError && result.sshError !== 'unknown' && errors[result.sshError]) ||
+ result.error ||
+ g.sshErrUnknown
+ )
}
const message = g.sshReachable(result.host || state.sshHost, result.remotePlatform || '?')