From 477a96f9f7b6c89635917197faeb44ef80ee4773 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 20 Jun 2026 16:59:21 -0700 Subject: [PATCH] Clarify SSH IPC error presentation Co-authored-by: codex --- .../src/ipc/methods/sshEnvironment.test.ts | 16 ++++++++++++++-- apps/desktop/src/ipc/methods/sshEnvironment.ts | 9 ++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src/ipc/methods/sshEnvironment.test.ts b/apps/desktop/src/ipc/methods/sshEnvironment.test.ts index fd7b0ac29f..d6cbe5db0f 100644 --- a/apps/desktop/src/ipc/methods/sshEnvironment.test.ts +++ b/apps/desktop/src/ipc/methods/sshEnvironment.test.ts @@ -5,6 +5,7 @@ import { } from "@t3tools/contracts"; import { SshCommandSpawnError, + SshCommandTimeoutError, SshHttpBridgeError, SshPasswordPromptError, } from "@t3tools/ssh/errors"; @@ -22,7 +23,7 @@ import { DesktopSshEnvironmentRequestError, ensureSshEnvironment, fetchSshEnvironmentDescriptor, - toDesktopSshOperationPresentationError, + toDesktopSshIpcPresentationError, } from "./sshEnvironment.ts"; import * as DesktopSshEnvironment from "../../ssh/DesktopSshEnvironment.ts"; import * as DesktopSshPasswordPrompts from "../../ssh/DesktopSshPasswordPrompts.ts"; @@ -102,12 +103,23 @@ describe("SSH environment IPC", () => { cause, }); - const presentation = toDesktopSshOperationPresentationError(structured); + const presentation = toDesktopSshIpcPresentationError(structured); assert.equal(structured.message, "Failed to spawn SSH command for devbox."); assert.equal(presentation.message, cause.message); assert.strictEqual(presentation.cause, structured); }); + it("passes structural SSH errors without process causes through the IPC boundary", () => { + const structured = new SshCommandTimeoutError({ + command: "ssh", + argumentCount: 0, + target: "devbox", + timeoutMs: 30_000, + }); + + assert.strictEqual(toDesktopSshIpcPresentationError(structured), structured); + }); + it.effect("fetches and decodes the remote environment descriptor", () => { const requestUrls: string[] = []; const layer = makeHttpClientLayer((request) => diff --git a/apps/desktop/src/ipc/methods/sshEnvironment.ts b/apps/desktop/src/ipc/methods/sshEnvironment.ts index ced1ab739f..4c3517e761 100644 --- a/apps/desktop/src/ipc/methods/sshEnvironment.ts +++ b/apps/desktop/src/ipc/methods/sshEnvironment.ts @@ -73,7 +73,10 @@ const isSshCausePresentationError = Schema.is( ]), ); -export function toDesktopSshOperationPresentationError( +// Electron only forwards the message from a rejected ipcRenderer.invoke promise. Keep the typed, +// structural SSH error intact as the cause for main-process diagnostics while preserving the +// actionable process message that the renderer historically presented to the user. +export function toDesktopSshIpcPresentationError( error: DesktopSshEnvironment.DesktopSshEnvironmentOperationError, ): DesktopSshEnvironment.DesktopSshEnvironmentOperationError | Error { if (isSshCausePresentationError(error) && error.cause instanceof Error) { @@ -169,7 +172,7 @@ export const ensureSshEnvironment = DesktopIpc.makeIpcMethod({ ) : Effect.fail(error), }), - Effect.mapError(toDesktopSshOperationPresentationError), + Effect.mapError(toDesktopSshIpcPresentationError), ); }), }); @@ -182,7 +185,7 @@ export const disconnectSshEnvironment = DesktopIpc.makeIpcMethod({ const sshEnvironment = yield* DesktopSshEnvironment.DesktopSshEnvironment; yield* sshEnvironment .disconnectEnvironment(target) - .pipe(Effect.mapError(toDesktopSshOperationPresentationError)); + .pipe(Effect.mapError(toDesktopSshIpcPresentationError)); }), });