@devries-cameron20 / t3code-1 / commits / 17fa628866
Fork 0

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

fix(web): device tool update failures show the server error, not network advice (#17569)

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

Scott Norteman committed Oct 18, 2026 at 15:22 UTC 17fa6288665626be83ef9024f13e4c1da23a727c
4 files changed +209 -6
apps/server/src/device/DeviceService.test.ts
+62
@@ -886,3 +886,65 @@ it.effect("reconciles SSH host settings without publishing no-op changes", () =>
886 Effect.provide(Layer.mergeAll(ServerSettings.layerTest(), NodeServices.layer)),
887 ),
888 );
889 +
890 +it.effect("a failed tool update reports npm's exit code but not its output", () =>
891 + Effect.gen(function* () {
892 + const host: DeviceHost.DeviceHost["Service"] = {
893 + id: LOCAL_DEVICE_HOST_ID,
894 + summary: Effect.succeed({
895 + id: LOCAL_DEVICE_HOST_ID,
896 + kind: "local",
897 + label: "Test server",
898 + platforms: [],
899 + hubInstalled: false,
900 + agentDeviceInstalled: false,
901 + }),
902 + platformAvailability: (platform) => Effect.succeed({ platform, available: false }),
903 + ensureReady: () => Effect.die("Updating a tool does not start the hub"),
904 + ensureAgentReady: () => Effect.die("Updating a tool does not start the agent"),
905 + current: Effect.succeed(null),
906 + stopAgent: Effect.void,
907 + stop: Effect.void,
908 + };
909 + const npmFailure = {
910 + code: ChildProcessSpawner.ExitCode(243),
911 + stdout: "",
912 + stderr: "npm error EACCES https://private:credential@registry.example.test/expo-device-hub",
913 + timedOut: false,
914 + stdoutTruncated: false,
915 + stderrTruncated: false,
916 + stdoutInvalidUtf8: false,
917 + stderrInvalidUtf8: false,
918 + };
919 + const service = yield* DeviceService.make.pipe(
920 + Effect.provideService(DeviceHost.DeviceHost, host),
921 + Effect.provideService(ProcessRunner.ProcessRunner, {
922 + run: () => Effect.succeed(npmFailure),
923 + }),
924 + Effect.provideService(
925 + HttpClient.HttpClient,
926 + HttpClient.make(() => Effect.die("Updating a tool makes no hub requests")),
927 + ),
928 + );
929 +
930 + const error = yield* service.updateTool("hub").pipe(Effect.flip);
931 + expect(error).toMatchObject({
932 + _tag: "DeviceOperationError",
933 + reason: "command_failed",
934 + exitCode: 243,
935 + });
936 + expect(error.message).toBe(
937 + "Device update device tool failed: The device command failed (exit code 243).",
938 + );
939 + }).pipe(
940 + Effect.provide(
941 + Layer.mergeAll(
942 + ServerSettings.layerTest({ enableDeviceSupport: true }),
943 + ServerConfig.layerTest(process.cwd(), { prefix: "t3-device-update-" }),
944 + NodeCrypto.layer,
945 + NetService.layer,
946 + ).pipe(Layer.provideMerge(NodeServices.layer)),
947 + ),
948 + Effect.scoped,
949 + ),
950 +);
apps/server/src/device/DeviceService.ts
+2
@@ -1033,6 +1033,8 @@ export const make = Effect.gen(function* () {
1033 new DeviceOperationError({
1034 operation: "update device tool",
1035 reason: "command_failed",
1036 + // Only the exit code goes into the shown message; npm's stderr can carry registry credentials.
1037 + ...(cause.exitCode !== undefined ? { exitCode: cause.exitCode } : {}),
1038 cause,
1039 }),
1040 ),
apps/web/src/components/settings/DeviceToolUpdate.test.tsx new
+142
@@ -0,0 +1,142 @@
1 +import { EnvironmentRpcUnavailableError } from "@t3tools/client-runtime/rpc";
2 +import {
3 + DeviceOperationError,
4 + EnvironmentId,
5 + LOCAL_DEVICE_HOST_ID,
6 + type DeviceServiceState,
7 +} from "@t3tools/contracts";
8 +import * as Cause from "effect/Cause";
9 +import { act, type ReactNode } from "react";
10 +import { create, type ReactTestRenderer } from "react-test-renderer";
11 +import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
12 +
13 +const { list } = vi.hoisted(() => ({ list: vi.fn() }));
14 +
15 +vi.mock("~/state/use-atom-command", () => ({
16 + useAtomCommand: (command: unknown) => (command === "list" ? list : vi.fn()),
17 +}));
18 +vi.mock("~/state/device", () => ({
19 + deviceEnvironment: { list: "list", configure: "configure" },
20 + useDeviceState: () => ({ state: deviceState, loaded: true }),
21 +}));
22 +vi.mock("~/state/session", async (importOriginal) => ({
23 + ...(await importOriginal<typeof import("~/state/session")>()),
24 + useEnvironmentScope: () => true,
25 + readEnvironmentScope: () => true,
26 +}));
27 +vi.mock("./SettingsScopeContext", () => ({
28 + useSettingsScope: () => ({
29 + scope: { kind: "all", environmentIds: [] },
30 + search: {},
31 + environment: null,
32 + environments: [],
33 + target: null,
34 + connectedEnvironments: [],
35 + targets: [],
36 + }),
37 + useOptionalSettingsScope: () => null,
38 +}));
39 +vi.mock("./useScopedSettings", async (importOriginal) => ({
40 + ...(await importOriginal<typeof import("./useScopedSettings")>()),
41 + useUpdateScopedSettings: () => vi.fn(),
42 +}));
43 +// Rows resolve scope and permissions; only their controls matter here.
44 +vi.mock("./settingsLayout", async (importOriginal) => ({
45 + ...(await importOriginal<typeof import("./settingsLayout")>()),
46 + SettingsRow: ({ control, children }: { control?: ReactNode; children?: ReactNode }) => (
47 + <>
48 + {control}
49 + {children}
50 + </>
51 + ),
52 +}));
53 +// The version popover holds the Update button; render the button in place of the popover.
54 +vi.mock("../device/DeviceToolVersions", () => ({
55 + DeviceToolVersions: ({ action }: { action?: ReactNode }) => action ?? null,
56 +}));
57 +vi.mock("../device/DeviceHostUpdates", () => ({ DeviceHostUpdates: () => null }));
58 +vi.mock("./DeviceHostsSettings", () => ({ DeviceHostsSettings: () => null }));
59 +
60 +import { DeviceIntegrationControls } from "./IntegrationsSettings";
61 +
62 +const environmentId = EnvironmentId.make("environment-1");
63 +const deviceState = {
64 + supportsToolUpdate: true,
65 + hosts: [
66 + {
67 + id: LOCAL_DEVICE_HOST_ID,
68 + kind: "local",
69 + label: "This computer",
70 + platforms: [],
71 + tools: {
72 + hub: { requiredVersion: "0.12.0", installedVersions: [], runningVersion: null },
73 + agent: { requiredVersion: "1.0.0", installedVersions: ["1.0.0"], runningVersion: null },
74 + },
75 + hubInstalled: false,
76 + agentDeviceInstalled: true,
77 + },
78 + ],
79 + hostStatus: "idle",
80 + hostStatuses: {},
81 + devices: [],
82 + sessions: [],
83 + onboardingCompleted: true,
84 + agentAccessEnabled: false,
85 + hubBasePath: "/device-hub",
86 + revision: 1,
87 +} satisfies DeviceServiceState;
88 +
89 +let renderer: ReactTestRenderer | undefined;
90 +
91 +beforeEach(() => {
92 + vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
93 + list.mockReset();
94 +});
95 +
96 +afterEach(async () => {
97 + await act(() => renderer?.unmount());
98 + vi.unstubAllGlobals();
99 +});
100 +
101 +it.each([
102 + {
103 + name: "a failed install",
104 + error: new DeviceOperationError({
105 + operation: "update device tool",
106 + reason: "command_failed",
107 + exitCode: 243,
108 + cause: new Error("npm error EACCES https://private:credential@registry.example.test/hub"),
109 + }),
110 + message: "Device update device tool failed: The device command failed (exit code 243).",
111 + },
112 + {
113 + name: "a lost connection",
114 + error: new EnvironmentRpcUnavailableError({
115 + environmentId,
116 + message: "Query environment is not connected.",
117 + }),
118 + message: "Query environment is not connected.",
119 + },
120 +])(
121 + "reports $name as the server describes it, not as a network problem",
122 + async ({ error, message }) => {
123 + list.mockResolvedValue({ _tag: "Failure", cause: Cause.fail(error) });
124 + await act(() => {
125 + renderer = create(
126 + <DeviceIntegrationControls
127 + environmentId={environmentId}
128 + enabled
129 + agentAccessEnabled={false}
130 + />,
131 + );
132 + });
133 +
134 + const update = renderer!.root.find(
135 + (node) => node.type === "button" && node.props.children === "Update to v0.12.0",
136 + );
137 + await act(async () => update.props.onClick());
138 +
139 + expect(list).toHaveBeenCalledWith({ environmentId, input: { updateTool: "hub" } });
140 + expect(renderer!.root.find((node) => node.props.role === "alert").props.children).toBe(message);
141 + },
142 +);
apps/web/src/components/settings/IntegrationsSettings.tsx
+3 -6
@@ -44,6 +44,7 @@ import { useEnvironments, usePrimaryEnvironment } from "~/state/environments";
44 import { deviceEnvironment, useDeviceState } from "~/state/device";
45 import { readEnvironmentScope, useEnvironmentScope } from "~/state/session";
46 import { useAtomCommand } from "~/state/use-atom-command";
47 +import { formatEnvironmentQueryError } from "~/state/query";
48 import { previewEnvironment } from "~/state/preview";
49 import { useServerConfigs } from "~/state/entities";
50 import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
@@ -728,7 +729,7 @@ function DeviceIntegrationSettings() {
729 );
730 }
731
731 -function DeviceIntegrationControls({
732 +export function DeviceIntegrationControls({
733 environmentId,
734 enabled,
735 agentAccessEnabled,
@@ -820,11 +821,7 @@ function DeviceIntegrationControls({
821 void list({ environmentId, input: { updateTool: tool } })
822 .then((result) => {
823 if (result._tag === "Failure")
823 - setUpdateError({
824 - tool,
825 - message:
826 - "Update failed. Check this host's network connection and try again.",
827 - });
824 + setUpdateError({ tool, message: formatEnvironmentQueryError(result.cause) });
825 })
826 .finally(() => setPending(null));
827 }}