The best way to control Claude Code, Codex and more from any computer or phone
fix(server): report missing Node on SSH device hosts instead of a connection failure (#20377)
Scott Norteman committed
Oct 18, 2026 at 16:09 UTC
dfda92872d5bcd4459db6f47e3793fe7bbdabc59
2 files changed
+118
-4
apps/server/src/device/DeviceService.test.ts
+79
@@ -12,6 +12,7 @@ import {
12
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
13
import * as NodeServices from "@effect/platform-node/NodeServices";
14
import * as NetService from "@t3tools/shared/Net";
15
+import { SshCommandError } from "@t3tools/ssh/errors";
16
import * as Effect from "effect/Effect";
17
import * as Exit from "effect/Exit";
18
import * as Deferred from "effect/Deferred";
@@ -694,6 +695,84 @@ it.effect("host retry exposes actionable failure without internal IDs or diagnos
695
}).pipe(Effect.scoped),
696
);
697
698
+it.effect.each([
699
+ {
700
+ name: "missing Node among private diagnostic lines",
701
+ exitCode: 1,
702
+ stderr:
703
+ "private diagnostics\r\nNode is missing from the non-interactive SSH PATH\r\nprivate diagnostics",
704
+ expected:
705
+ "Connected over SSH, but Node is not on this host's PATH for non-interactive SSH commands.",
706
+ },
707
+ {
708
+ name: "another remote command failure",
709
+ exitCode: 2,
710
+ stderr: "private diagnostics",
711
+ expected: "Connected over SSH, but the device host check failed (exit code 2).",
712
+ },
713
+ {
714
+ name: "an unrecognized exit-one diagnostic",
715
+ exitCode: 1,
716
+ stderr: "private diagnostics: Node is missing from the non-interactive SSH PATH",
717
+ expected: "Connected over SSH, but the device host check failed (exit code 1).",
718
+ },
719
+ {
720
+ name: "a connection failure",
721
+ exitCode: 255,
722
+ stderr: "Node is missing from the non-interactive SSH PATH",
723
+ expected: "Could not connect to this host over SSH.",
724
+ },
725
+ {
726
+ name: "a command that could not start",
727
+ exitCode: null,
728
+ stderr: "private diagnostics",
729
+ expected: "Could not connect to this host over SSH.",
730
+ },
731
+ {
732
+ name: "an untyped offline cause",
733
+ exitCode: undefined,
734
+ stderr: "private diagnostics",
735
+ expected: "Could not connect to this host over SSH.",
736
+ },
737
+])("reports $name through manual and agent host readiness", ({ exitCode, stderr, expected }) =>
738
+ Effect.gen(function* () {
739
+ const failure = new DeviceHost.DeviceHostError({
740
+ hostId: LOCAL_DEVICE_HOST_ID,
741
+ step: "probe",
742
+ cause:
743
+ exitCode === undefined
744
+ ? "offline"
745
+ : new SshCommandError({
746
+ command: ["ssh", "private arguments"],
747
+ exitCode,
748
+ stderr,
749
+ stdout: "private output",
750
+ message: "private diagnostics",
751
+ }),
752
+ });
753
+ const { service, settings } = yield* fixture(Effect.void, undefined, false, failure);
754
+ yield* Ref.update(settings, (current) => ({
755
+ ...current,
756
+ enableDeviceSupport: true,
757
+ enableAgentDeviceAccess: true,
758
+ }));
759
+ for (const readiness of [service.readiness(), service.agentReadinessIfSupported()]) {
760
+ const error = yield* readiness.pipe(Effect.flip);
761
+ expect(error).toMatchObject({ reason: expected, cause: failure });
762
+ expect((yield* service.state).hostStatuses[LOCAL_DEVICE_HOST_ID]).toEqual({
763
+ status: "failed",
764
+ detail: expected,
765
+ });
766
+ }
767
+ for (const state of [yield* service.list, yield* service.retryHost(LOCAL_DEVICE_HOST_ID)]) {
768
+ expect(state.hostStatuses[LOCAL_DEVICE_HOST_ID]).toEqual({
769
+ status: "failed",
770
+ detail: expected,
771
+ });
772
+ }
773
+ }).pipe(Effect.scoped),
774
+);
775
+
776
it.effect("version discovery does not grant consent or start device tools", () =>
777
Effect.gen(function* () {
778
const { service, starts, agentStarts, requests } = yield* fixture();
apps/server/src/device/DeviceService.ts
+39
-4
@@ -23,6 +23,7 @@ import {
23
LOCAL_DEVICE_HOST_ID,
24
type ThreadId,
25
} from "@t3tools/contracts";
26
+import { SshCommandError } from "@t3tools/ssh/errors";
27
import * as FileSystem from "effect/FileSystem";
28
import { resolveNodeExecutable, nodeRuntimeUnavailableMessage } from "@t3tools/shared/nodeRuntime";
29
import * as Path from "effect/Path";
@@ -59,6 +60,28 @@ import * as LocalDeviceHost from "./LocalDeviceHost.ts";
60
61
export const DEVICE_HUB_ROUTE_PREFIX = "/api/device-hub";
62
63
+const sshProbeFailureMessage = (error: DeviceHost.DeviceHostError): string => {
64
+ const cause = error.cause;
65
+ if (
66
+ !(cause instanceof SshCommandError) ||
67
+ cause.exitCode === null ||
68
+ cause.exitCode < 1 ||
69
+ cause.exitCode > 254
70
+ )
71
+ return "Could not connect to this host over SSH.";
72
+
73
+ // Only the known bootstrap diagnostic is safe to expose as Node guidance.
74
+ if (
75
+ cause.exitCode === 1 &&
76
+ cause.stderr
77
+ .split(/\r?\n/u)
78
+ .some((line) => line.trim() === "Node is missing from the non-interactive SSH PATH")
79
+ )
80
+ return "Connected over SSH, but Node is not on this host's PATH for non-interactive SSH commands.";
81
+
82
+ return `Connected over SSH, but the device host check failed (exit code ${cause.exitCode}).`;
83
+};
84
+
85
const BOOT_TIMEOUT = Duration.minutes(3);
86
const SCREENSHOT_TIMEOUT = Duration.seconds(20);
87
@@ -250,7 +273,13 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
273
)
274
.pipe(
275
Effect.tapError((error) =>
253
- setHostStatus(host.id, { status: "failed", detail: error.message }),
276
+ setHostStatus(host.id, {
277
+ status: "failed",
278
+ detail:
279
+ error._tag === "DeviceHostError" && error.step === "probe"
280
+ ? sshProbeFailureMessage(error)
281
+ : error.message,
282
+ }),
283
),
284
Effect.mapError(
285
(error) =>
@@ -260,7 +289,7 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
289
error._tag === "NodeRuntimeUnavailableError"
290
? nodeRuntimeUnavailableMessage("Local device support")
291
: error.step === "probe"
263
- ? "Could not connect to this host over SSH."
292
+ ? sshProbeFailureMessage(error)
293
: `Device support failed during ${error.step}.`,
294
cause: error,
295
}),
@@ -305,7 +334,13 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
334
)
335
.pipe(
336
Effect.tapError((error) =>
308
- setHostStatus(host.id, { status: "failed", detail: error.message }),
337
+ setHostStatus(host.id, {
338
+ status: "failed",
339
+ detail:
340
+ error._tag === "DeviceHostError" && error.step === "probe"
341
+ ? sshProbeFailureMessage(error)
342
+ : error.message,
343
+ }),
344
),
345
Effect.mapError(
346
(error) =>
@@ -319,7 +354,7 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
354
: error._tag === "AgentDeviceStartError"
355
? error.message
356
: error.step === "probe"
322
- ? "Could not connect to this host over SSH."
357
+ ? sshProbeFailureMessage(error)
358
: `Device support failed during ${error.step}.`,
359
cause: error,
360
}),