diff --git a/apps/desktop/src/ssh/DesktopSshEnvironment.ts b/apps/desktop/src/ssh/DesktopSshEnvironment.ts index 2fbf1f4357..4fb47d7201 100644 --- a/apps/desktop/src/ssh/DesktopSshEnvironment.ts +++ b/apps/desktop/src/ssh/DesktopSshEnvironment.ts @@ -25,6 +25,7 @@ import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; import * as Path from "effect/Path"; +import * as Schema from "effect/Schema"; import { HttpClient } from "effect/unstable/http"; import { ChildProcessSpawner } from "effect/unstable/process"; @@ -75,6 +76,8 @@ export interface DesktopSshEnvironmentLayerOptions { readonly resolveCliRunner?: Effect.Effect; } +const isSshPasswordPromptError = Schema.is(SshPasswordPromptError); + function discoverDesktopSshHostsEffect(input?: { readonly homeDir?: string }) { return discoverSshHosts(input ?? {}); } @@ -83,7 +86,7 @@ export function isDesktopSshPasswordPromptCancellation( error: unknown, ): error is SshPasswordPromptError { return ( - error instanceof SshPasswordPromptError && + isSshPasswordPromptError(error) && DesktopSshPasswordPrompts.isDesktopSshPasswordPromptCancellation(error.cause) ); } diff --git a/apps/desktop/src/ssh/DesktopSshRemoteApi.test.ts b/apps/desktop/src/ssh/DesktopSshRemoteApi.test.ts index 8b6798d38c..2d32f224e4 100644 --- a/apps/desktop/src/ssh/DesktopSshRemoteApi.test.ts +++ b/apps/desktop/src/ssh/DesktopSshRemoteApi.test.ts @@ -2,10 +2,13 @@ import { assert, describe, it } from "@effect/vitest"; import { SshHttpBridgeError } from "@t3tools/ssh/errors"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; +import * as Schema from "effect/Schema"; import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http"; import * as DesktopSshRemoteApi from "./DesktopSshRemoteApi.ts"; +const isSshHttpBridgeError = Schema.is(SshHttpBridgeError); + function jsonResponse(request: HttpClientRequest.HttpClientRequest, body: unknown, status = 200) { return HttpClientResponse.fromWeb( request, @@ -73,7 +76,7 @@ describe("DesktopSshRemoteApi", () => { assert.instanceOf(error, DesktopSshRemoteApi.DesktopSshRemoteApiError); assert.equal(error.operation, "fetch-environment-descriptor"); - assert.equal(error.cause instanceof SshHttpBridgeError, false); + assert.equal(isSshHttpBridgeError(error.cause), false); }).pipe(Effect.provide(layer)); }); });