Use schema guards for desktop ssh errors

Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
Cursor AgentandJulius Marminge committed 2026-05-16 16:09:56 +00:00
1 parent 72e29731c2
commit 182f9b606d
2 files changed
+8 -2

No files matched your search

@@ -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<RemoteT3RunnerOptions>;
}
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)
);
}
@@ -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));
});
});