@devries-cameron20 / t3code Mirror · read-only / commits / 3ee55151e0
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 05:45 UTC

fix(web): device host checks show the error without a stack trace (#29912)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Alex Southwell committed Nov 3, 2026 at 17:45 UTC 3ee55151e075441a798094202503087fcf1268f0
2 files changed +66 -2
apps/web/src/components/settings/useHostConnectionChecks.browser.test.tsx new
+64
@@ -0,0 +1,64 @@
1 +import { DeviceHostUnavailableError, EnvironmentId } from "@t3tools/contracts";
2 +import * as Cause from "effect/Cause";
3 +import { AsyncResult } from "effect/reactivity";
4 +import { describe, expect, it, vi } from "vite-plus/test";
5 +
6 +import { act, render } from "../../../test/render";
7 +
8 +const state = vi.hoisted(() => ({ test: vi.fn() }));
9 +function setup() {
10 + state.test.mockReset();
11 +}
12 +
13 +vi.mock(import("../../state/use-atom-command"), async (original) => ({
14 + ...(await original()),
15 + useAtomCommand: (() => state.test) as never,
16 +}));
17 +vi.mock(import("../../state/session"), async (original) => ({
18 + ...(await original()),
19 + readEnvironmentScope: (() => true) as never,
20 +}));
21 +
22 +import { useHostConnectionChecks } from "./useHostConnectionChecks";
23 +
24 +const environmentId = EnvironmentId.make("environment-1");
25 +const targets = [{ environmentId, label: "This Mac", connected: true }];
26 +
27 +function Harness({
28 + onReady,
29 +}: {
30 + onReady: (run: ReturnType<typeof useHostConnectionChecks>) => void;
31 +}) {
32 + onReady(useHostConnectionChecks(targets));
33 + return null;
34 +}
35 +
36 +describe("useHostConnectionChecks", () => {
37 + it("reports a failed check by its message, without a stack trace", async () => {
38 + setup();
39 + state.test.mockResolvedValue(
40 + AsyncResult.failure(
41 + Cause.fail(
42 + new DeviceHostUnavailableError({
43 + hostId: "mac",
44 + hostLabel: "Mac mini",
45 + reason: "SSH connection refused.",
46 + }),
47 + ),
48 + ),
49 + );
50 + let checks!: ReturnType<typeof useHostConnectionChecks>;
51 + await using _screen = await render(<Harness onReady={(next) => (checks = next)} />, {
52 + router: false, // the hook reads no route state
53 + });
54 +
55 + const results = await act(() =>
56 + checks.testConnection({ kind: "ssh", id: "mac", label: "Mac mini", target: "user@mac" }),
57 + );
58 +
59 + expect(results?.[environmentId]).toEqual({
60 + status: "failed",
61 + error: "Mac mini is unavailable: SSH connection refused.",
62 + });
63 + });
64 +});
apps/web/src/components/settings/useHostConnectionChecks.ts
+2 -2
@@ -1,7 +1,7 @@
1 import { AuthSettingsWriteScope } from "@t3tools/contracts";
2 import { readEnvironmentScope } from "../../state/session";
3 import { useRef, useState } from "react";
4 -import * as Cause from "effect/Cause";
4 +import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
5 import type { SshDeviceHostConfig } from "@t3tools/contracts";
6 import { deviceEnvironment } from "../../state/device";
7 import { useAtomCommand } from "../../state/use-atom-command";
@@ -30,7 +30,7 @@ export function useHostConnectionChecks(targets: ReadonlyArray<DeviceHostCheckTa
30 throw new Error("This connection cannot test device hosts.");
31 }
32 const result = await test({ environmentId, input });
33 - if (result._tag === "Failure") throw new Error(Cause.pretty(result.cause));
33 + if (result._tag === "Failure") throw squashAtomCommandFailure(result);
34 return result.value;
35 },
36 (environmentId, result) => {