@devries-cameron20 / t3code-1 / commits / c273a8f6fa
Fork 0

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

feat(contracts): device hosts as a tagged union with EAS hosts (#21842)

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

Julius Marminge committed Oct 20, 2026 at 00:57 UTC c273a8f6fa921f02e7f2fc2d055aa6891cfe04f9
13 files changed +297 -51
apps/server/src/device/DeviceService.test.ts
+6 -1
@@ -1245,7 +1245,12 @@ it.effect("reconciles SSH host settings without publishing no-op changes", () =>
1245 const initial = yield* service.state;
1246 expect(yield* update([])).toEqual(initial);
1247
1248 - const host: SshDeviceHostConfig = { id: "remote", label: "Remote", target: "remote-fixture" };
1248 + const host: SshDeviceHostConfig = {
1249 + kind: "ssh",
1250 + id: "remote",
1251 + label: "Remote",
1252 + target: "remote-fixture",
1253 + };
1254 const added = yield* update([host]);
1255 expect(added.hosts.map((entry) => entry.id)).toEqual([LOCAL_DEVICE_HOST_ID, host.id]);
1256 expect(yield* update([{ ...host }])).toEqual(added);
apps/server/src/device/DeviceService.ts
+16 -6
@@ -17,6 +17,8 @@ import {
17 type DeviceSession,
18 type DeviceShutdownInput,
19 type DeviceSummary,
20 + type DeviceHostConfig,
21 + type EasDeviceHostConfig,
22 type SshDeviceHostConfig,
23 type DeviceHostSummary,
24 LOCAL_DEVICE_HOST_ID,
@@ -916,11 +918,11 @@ export const make = Effect.gen(function* () {
918 yield* Effect.context<Effect.Services<ReturnType<typeof SshDeviceHost.make>>>();
919 const configured = new Map<string, { config: SshDeviceHostConfig; scope: Scope.Closeable }>();
920 const reconcile = Effect.fn("DeviceService.reconcile")(function* (
919 - configuredHosts: ReadonlyArray<SshDeviceHostConfig>,
921 + configuredHosts: ReadonlyArray<DeviceHostConfig>,
922 ) {
921 - const next = yield* remoteSshDeviceHosts(configuredHosts).pipe(
922 - Effect.provide(localTargetContext),
923 - );
923 + const next = yield* remoteSshDeviceHosts(
924 + configuredHosts.filter((host): host is SshDeviceHostConfig => host.kind === "ssh"),
925 + ).pipe(Effect.provide(localTargetContext));
926 const removed = yield* service.withLifecycleLock(
927 Effect.gen(function* () {
928 const removed: Array<{ id: string; scope: Scope.Closeable }> = [];
@@ -989,9 +991,17 @@ export const make = Effect.gen(function* () {
991 );
992 });
993 const changes = yield* settings.subscribeChanges;
992 - yield* reconcile((yield* settings.getSettings).deviceHosts);
994 + // Settings keep EAS hosts apart from SSH hosts; an id both lists use stays the SSH host's.
995 + const configuredHosts = (value: {
996 + readonly deviceHosts: ReadonlyArray<SshDeviceHostConfig>;
997 + readonly easDeviceHosts: ReadonlyArray<EasDeviceHostConfig>;
998 + }): ReadonlyArray<DeviceHostConfig> => [
999 + ...value.deviceHosts,
1000 + ...value.easDeviceHosts.filter((host) => !value.deviceHosts.some((ssh) => ssh.id === host.id)),
1001 + ];
1002 + yield* reconcile(configuredHosts(yield* settings.getSettings));
1003 yield* changes.pipe(
994 - Stream.runForEach((value) => reconcile(value.deviceHosts)),
1004 + Stream.runForEach((value) => reconcile(configuredHosts(value))),
1005 Effect.forkIn(scope),
1006 );
1007 yield* Effect.addFinalizer(() =>
apps/server/src/device/SshDeviceHost.test.ts
+7 -2
@@ -101,7 +101,7 @@ it.effect("preserves installed status after probes and cleans failed agent activ
101 }),
102 );
103 const host = yield* SshDeviceHost.make(
104 - { id: "test", label: "Test", target: "test.example" },
104 + { kind: "ssh", id: "test", label: "Test", target: "test.example" },
105 () =>
106 rejectConfig
107 ? Effect.fail(
@@ -123,7 +123,12 @@ it.effect("preserves installed status after probes and cleans failed agent activ
123 ),
124 );
125 yield* host.ensureReady(() => Effect.void);
126 - yield* SshDeviceHost.probe({ id: "test", label: "Test", target: "test.example" }).pipe(
126 + yield* SshDeviceHost.probe({
127 + kind: "ssh",
128 + id: "test",
129 + label: "Test",
130 + target: "test.example",
131 + }).pipe(
132 Effect.provide(ServerConfig.layerTest(home, home)),
133 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
134 );
apps/server/src/device/localSshDeviceHost.test.ts
+11 -2
@@ -11,6 +11,7 @@ import {
11 } from "./localSshDeviceHost.ts";
12
13 const host = (target: string, port?: number) => ({
14 + kind: "ssh" as const,
15 id: target,
16 label: target,
17 target,
@@ -78,9 +79,17 @@ it.effect("keeps remote, forwarded, proxied, and unresolved destinations", () =>
79 it.effect("removes only self targets from a fanned-out host list", () =>
80 provide(
81 Effect.gen(function* () {
82 + const eas = {
83 + kind: "eas" as const,
84 + id: "eas",
85 + label: "EAS Simulator",
86 + maxSessionMinutes: 30,
87 + idleMinutes: 10,
88 + maxConcurrentSessions: 2,
89 + };
90 expect(
82 - yield* remoteSshDeviceHosts([host("mac-mini"), host("remote"), host("forwarded")]),
83 - ).toEqual([host("remote"), host("forwarded")]);
91 + yield* remoteSshDeviceHosts([host("mac-mini"), eas, host("remote"), host("forwarded")]),
92 + ).toEqual([eas, host("remote"), host("forwarded")]);
93 }),
94 ),
95 );
apps/server/src/device/localSshDeviceHost.ts
+13 -10
@@ -1,6 +1,6 @@
1 import * as NodeDnsPromises from "node:dns/promises";
2 import * as NodeNet from "node:net";
3 -import type { SshDeviceHostConfig } from "@t3tools/contracts";
3 +import type { DeviceHostConfig, SshDeviceHostConfig } from "@t3tools/contracts";
4 import * as NodeOS from "node:os";
5 import * as Context from "effect/Context";
6 import { runSshCommand } from "@t3tools/ssh/command";
@@ -59,12 +59,15 @@ export const isLocalSshDeviceHost = Effect.fn("isLocalSshDeviceHost")(function*
59 );
60 });
61
62 -export const remoteSshDeviceHosts = Effect.fn("remoteSshDeviceHosts")(function* (
63 - hosts: ReadonlyArray<SshDeviceHostConfig>,
64 -) {
65 - return yield* Effect.filter(
66 - hosts,
67 - (host) => isLocalSshDeviceHost(host).pipe(Effect.map((local) => !local)),
68 - { concurrency: 4 },
69 - );
70 -});
62 +/** Drops SSH hosts that resolve to this machine; other host kinds pass through. */
63 +export const remoteSshDeviceHosts = Effect.fn("remoteSshDeviceHosts")(
64 + <Host extends DeviceHostConfig>(hosts: ReadonlyArray<Host>) =>
65 + Effect.filter(
66 + hosts,
67 + (host) =>
68 + host.kind === "ssh"
69 + ? isLocalSshDeviceHost(host).pipe(Effect.map((local) => !local))
70 + : Effect.succeed(true),
71 + { concurrency: 4 },
72 + ),
73 +);
apps/web/src/components/settings/DeviceHostsSettings.tsx
+1 -1
@@ -145,7 +145,7 @@ export function DeviceHostsSettings(props: { environmentId: EnvironmentId | null
145 }
146 onClick={() => {
147 setOriginalHost(null);
148 - setEditing({ id: randomUUID(), label: "", target: "" });
148 + setEditing({ kind: "ssh", id: randomUUID(), label: "", target: "" });
149 }}
150 >
151 <PlusIcon className="size-3.5" /> Add host
apps/web/src/components/settings/deviceHostConnectionChecks.test.ts
+1 -1
@@ -8,7 +8,7 @@ import {
8 type DeviceHostCheck,
9 } from "./deviceHostConnectionChecks";
10
11 -const host = { id: "mac", label: "Mac mini", target: "user@mac" };
11 +const host = { kind: "ssh" as const, id: "mac", label: "Mac mini", target: "user@mac" };
12 const ids = ["a", "b", "c", "d"].map((id) => EnvironmentId.make(id));
13 const targets = ids.map((environmentId, index) => ({
14 environmentId,
apps/web/src/components/settings/deviceHostsSettings.logic.test.ts
+7 -2
@@ -2,8 +2,13 @@ import { describe, expect, it } from "vite-plus/test";
2 import { updateDeviceHosts } from "./deviceHostsSettings.logic";
3
4 describe("device host changes across environments", () => {
5 - const shared = { id: "shared", label: "Mac mini", target: "julius@macmini" };
6 - const local = { id: "other", label: "Android", target: "julius@android" };
5 + const shared = {
6 + kind: "ssh" as const,
7 + id: "shared",
8 + label: "Mac mini",
9 + target: "julius@macmini",
10 + };
11 + const local = { kind: "ssh" as const, id: "other", label: "Android", target: "julius@android" };
12
13 it("adds to differing host lists without losing environment-specific hosts, including on retry", () => {
14 const environments = [[], [local], [shared, local]];
packages/contracts/src/device.test.ts
+74 -1
@@ -1,5 +1,11 @@
1 import { describe, expect, it } from "@effect/vitest";
2 -import { deviceToolInstallMessage } from "./device.ts";
2 +import { Schema } from "effect";
3 +import {
4 + DeviceServiceState,
5 + EasDeviceHostConfigs,
6 + SshDeviceHostConfigs,
7 + deviceToolInstallMessage,
8 +} from "./device.ts";
9
10 describe("device tool install progress", () => {
11 it("distinguishes a new install from an upgrade and chooses versions numerically", () => {
@@ -19,3 +25,70 @@ describe("device tool install progress", () => {
25 ).toBe("Updating device hub from 0.10.0 to 0.11.0…");
26 });
27 });
28 +
29 +const decodeSshHosts = Schema.decodeUnknownSync(SshDeviceHostConfigs);
30 +const decodeEas = Schema.decodeUnknownSync(EasDeviceHostConfigs);
31 +const encodeState = Schema.encodeSync(DeviceServiceState);
32 +const decodeState = Schema.decodeUnknownSync(DeviceServiceState);
33 +// The host summary as clients decoded it before EAS hosts existed.
34 +const decodeOlderState = Schema.decodeUnknownSync(
35 + Schema.Struct({
36 + hosts: Schema.Array(
37 + Schema.Struct({ id: Schema.String, kind: Schema.Literals(["local", "ssh"]) }),
38 + ),
39 + }),
40 +);
41 +
42 +describe("configured device hosts", () => {
43 + it("reads SSH hosts saved before hosts had a kind, and bounds EAS sessions", () => {
44 + expect(decodeSshHosts([{ id: "mac", label: "Mac mini", target: "julius@mac" }])).toEqual([
45 + { kind: "ssh", id: "mac", label: "Mac mini", target: "julius@mac" },
46 + ]);
47 + expect(decodeEas([{ kind: "eas", id: "eas", label: "EAS Simulator" }])).toEqual([
48 + {
49 + kind: "eas",
50 + id: "eas",
51 + label: "EAS Simulator",
52 + maxSessionMinutes: 30,
53 + idleMinutes: 10,
54 + maxConcurrentSessions: 2,
55 + },
56 + ]);
57 + expect(() =>
58 + decodeEas([{ kind: "eas", id: "eas", label: "EAS", maxSessionMinutes: 600 }]),
59 + ).toThrow();
60 + // The default idle limit of 10 is not smaller than a session limit of 10.
61 + expect(() =>
62 + decodeEas([{ kind: "eas", id: "eas", label: "EAS", maxSessionMinutes: 10 }]),
63 + ).toThrow();
64 + });
65 +});
66 +
67 +describe("device state for clients from before EAS hosts", () => {
68 + const summary = {
69 + label: "Host",
70 + platforms: [],
71 + hubInstalled: true,
72 + agentDeviceInstalled: true,
73 + };
74 + const state = {
75 + hosts: [
76 + { ...summary, id: "local", kind: "local" as const },
77 + { ...summary, id: "eas", kind: "eas" as const },
78 + ],
79 + hostStatus: "ready" as const,
80 + hostStatuses: {},
81 + devices: [],
82 + sessions: [],
83 + onboardingCompleted: true,
84 + agentAccessEnabled: true,
85 + hubBasePath: "/api/device-hub",
86 + revision: 1,
87 + };
88 +
89 + it("sends EAS hosts where an older client does not look, and reads them back", () => {
90 + const wire = encodeState(state);
91 + expect(decodeOlderState(wire).hosts.map((host) => host.id)).toEqual(["local"]);
92 + expect(decodeState(wire).hosts).toEqual(state.hosts);
93 + });
94 +});
packages/contracts/src/device.ts
+115 -22
@@ -1,4 +1,6 @@
1 -import { Schema } from "effect";
1 +import * as Effect from "effect/Effect";
2 +import * as Schema from "effect/Schema";
3 +import * as SchemaTransformation from "effect/SchemaTransformation";
4
5 import { ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
6
@@ -10,11 +12,15 @@ export type DeviceHostId = typeof DeviceHostId.Type;
12
13 export const LOCAL_DEVICE_HOST_ID = "local" as DeviceHostId;
14
15 +const ConfiguredDeviceHostId = DeviceHostId.check(
16 + Schema.isPattern(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/),
17 + Schema.makeFilter((id) => id !== "local" || "The local host id is reserved."),
18 +);
19 +
20 export const SshDeviceHostConfig = Schema.Struct({
14 - id: DeviceHostId.check(
15 - Schema.isPattern(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/),
16 - Schema.makeFilter((id) => id !== "local" || "The local host id is reserved."),
17 - ),
21 + // Hosts saved before EAS hosts existed carry no kind.
22 + kind: Schema.Literal("ssh").pipe(Schema.withDecodingDefaultKey(Effect.succeed("ssh" as const))),
23 + id: ConfiguredDeviceHostId,
24 label: TrimmedNonEmptyString,
25 target: TrimmedNonEmptyString.check(Schema.isPattern(/^[^\s-][^\s]*$/)),
26 identityFile: Schema.optional(TrimmedNonEmptyString),
@@ -22,13 +28,52 @@ export const SshDeviceHostConfig = Schema.Struct({
28 });
29 export type SshDeviceHostConfig = typeof SshDeviceHostConfig.Type;
30
25 -export const SshDeviceHostConfigs = Schema.Array(SshDeviceHostConfig).check(
31 +/**
32 + * Cloud simulators from EAS Simulator. Sessions bill the Expo account until
33 + * they stop, so every one is bounded. The Expo credential is not stored here.
34 + */
35 +export const EasDeviceHostConfig = Schema.Struct({
36 + kind: Schema.Literal("eas"),
37 + id: ConfiguredDeviceHostId,
38 + label: TrimmedNonEmptyString,
39 + /** EAS project that sessions run under, when the project's app config does not name one. */
40 + appId: Schema.optional(TrimmedNonEmptyString),
41 + /** EAS allows at most 40 minutes on free accounts and 115 on paid ones. */
42 + maxSessionMinutes: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 115 })).pipe(
43 + Schema.withDecodingDefaultKey(Effect.succeed(30)),
44 + ),
45 + idleMinutes: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 60 })).pipe(
46 + Schema.withDecodingDefaultKey(Effect.succeed(10)),
47 + ),
48 + maxConcurrentSessions: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 20 })).pipe(
49 + Schema.withDecodingDefaultKey(Effect.succeed(2)),
50 + ),
51 +}).check(
52 + // EAS requires the idle limit to be smaller than the session limit.
53 Schema.makeFilter(
27 - (hosts) =>
28 - new Set(hosts.map((host) => host.id)).size === hosts.length ||
29 - "Device host ids must be unique.",
54 + (host: { readonly idleMinutes: number; readonly maxSessionMinutes: number }) =>
55 + host.idleMinutes < host.maxSessionMinutes ||
56 + "Idle minutes must be smaller than session minutes.",
57 ),
58 );
59 +export type EasDeviceHostConfig = typeof EasDeviceHostConfig.Type;
60 +
61 +export type DeviceHostConfig = SshDeviceHostConfig | EasDeviceHostConfig;
62 +
63 +const uniqueHostIds = Schema.makeFilter(
64 + (hosts: ReadonlyArray<{ readonly id: string }>) =>
65 + new Set(hosts.map((host) => host.id)).size === hosts.length ||
66 + "Device host ids must be unique.",
67 +);
68 +
69 +export const SshDeviceHostConfigs = Schema.Array(SshDeviceHostConfig).check(uniqueHostIds);
70 +
71 +/**
72 + * Kept apart from the SSH hosts in settings: servers and clients from before
73 + * EAS hosts decode `deviceHosts` as SSH hosts and would reject the whole file
74 + * or snapshot over one EAS entry.
75 + */
76 +export const EasDeviceHostConfigs = Schema.Array(EasDeviceHostConfig).check(uniqueHostIds);
77
78 export const DeviceId = TrimmedNonEmptyString.check(Schema.isMaxLength(256));
79 export type DeviceId = typeof DeviceId.Type;
@@ -64,16 +109,24 @@ export const DeviceToolVersions = Schema.Struct({
109 });
110 export type DeviceToolVersions = typeof DeviceToolVersions.Type;
111
67 -export const DeviceHostSummary = Schema.Struct({
112 +const deviceHostSummaryFields = {
113 id: DeviceHostId,
69 - kind: Schema.Literals(["local", "ssh"]),
114 label: TrimmedNonEmptyString,
115 platforms: Schema.Array(DevicePlatformAvailability),
116 tools: Schema.optional(DeviceToolVersions),
117 toolInspectionError: Schema.optional(Schema.String),
118 hubInstalled: Schema.Boolean,
119 agentDeviceInstalled: Schema.Boolean,
120 +};
121 +const MachineDeviceHostSummary = Schema.Struct({
122 + ...deviceHostSummaryFields,
123 + kind: Schema.Literals(["local", "ssh"]),
124 +});
125 +const EasDeviceHostSummary = Schema.Struct({
126 + ...deviceHostSummaryFields,
127 + kind: Schema.Literal("eas"),
128 });
129 +export const DeviceHostSummary = Schema.Union([MachineDeviceHostSummary, EasDeviceHostSummary]);
130 export type DeviceHostSummary = typeof DeviceHostSummary.Type;
131
132 export const DeviceHostStatus = Schema.Literals([
@@ -95,21 +148,22 @@ export const DeviceSession = Schema.Struct({
148 });
149 export type DeviceSession = typeof DeviceSession.Type;
150
98 -export const DeviceServiceState = Schema.Struct({
151 +export const DeviceHostStatuses = Schema.Record(
152 + DeviceHostId,
153 + Schema.Struct({
154 + status: DeviceHostStatus,
155 + detail: Schema.optional(Schema.String),
156 + androidDiscoveryIncomplete: Schema.optional(Schema.Boolean),
157 + }),
158 +);
159 +
160 +const deviceServiceStateFields = {
161 supportsHostRetry: Schema.optional(Schema.Boolean),
162 supportsToolUpdate: Schema.optional(Schema.Boolean),
163 supportsToolInspection: Schema.optional(Schema.Boolean),
102 - hosts: Schema.Array(DeviceHostSummary),
164 hostStatus: DeviceHostStatus,
165 hostStatusDetail: Schema.optional(Schema.String),
105 - hostStatuses: Schema.Record(
106 - DeviceHostId,
107 - Schema.Struct({
108 - status: DeviceHostStatus,
109 - detail: Schema.optional(Schema.String),
110 - androidDiscoveryIncomplete: Schema.optional(Schema.Boolean),
111 - }),
112 - ),
166 + hostStatuses: DeviceHostStatuses,
167 devices: Schema.Array(DeviceSummary),
168 sessions: Schema.Array(DeviceSession),
169 bootingDevices: Schema.optional(
@@ -119,7 +173,46 @@ export const DeviceServiceState = Schema.Struct({
173 agentAccessEnabled: Schema.Boolean,
174 hubBasePath: Schema.String,
175 revision: Schema.Int,
176 +};
177 +
178 +/**
179 + * EAS host summaries travel as `easHosts`: clients from before EAS hosts
180 + * decode `hosts` with a `local | ssh` kind and would reject the whole state.
181 + * Decoded, every host is in `hosts`.
182 + */
183 +const DeviceServiceStateWire = Schema.Struct({
184 + ...deviceServiceStateFields,
185 + hosts: Schema.Array(MachineDeviceHostSummary),
186 + easHosts: Schema.optional(Schema.Array(EasDeviceHostSummary)),
187 +});
188 +const DeviceServiceStateDecoded = Schema.Struct({
189 + ...deviceServiceStateFields,
190 + hosts: Schema.Array(DeviceHostSummary),
191 });
192 +
193 +export const DeviceServiceState = DeviceServiceStateWire.pipe(
194 + Schema.decodeTo(
195 + Schema.toType(DeviceServiceStateDecoded),
196 + SchemaTransformation.transform<
197 + typeof DeviceServiceStateDecoded.Type,
198 + typeof DeviceServiceStateWire.Type
199 + >({
200 + decode: ({ easHosts, ...state }) => ({
201 + ...state,
202 + hosts: [...state.hosts, ...(easHosts ?? [])],
203 + }),
204 + encode: (state) => ({
205 + ...state,
206 + hosts: state.hosts.filter(
207 + (host): host is typeof MachineDeviceHostSummary.Type => host.kind !== "eas",
208 + ),
209 + easHosts: state.hosts.filter(
210 + (host): host is typeof EasDeviceHostSummary.Type => host.kind === "eas",
211 + ),
212 + }),
213 + }),
214 + ),
215 +);
216 export type DeviceServiceState = typeof DeviceServiceState.Type;
217
218 export const DeviceListInput = Schema.Struct({
@@ -423,7 +516,7 @@ export const DeviceError = Schema.Union([
516 export type DeviceError = typeof DeviceError.Type;
517
518 export const DeviceToolListResult = Schema.Struct({
426 - hostStatuses: DeviceServiceState.fields.hostStatuses,
519 + hostStatuses: DeviceHostStatuses,
520 hosts: Schema.Array(DeviceHostSummary),
521 devices: Schema.Array(DeviceSummary),
522 open: Schema.Array(Schema.Struct({ hostId: DeviceHostId, deviceId: DeviceId })),
packages/contracts/src/settings.test.ts
+23 -1
@@ -1087,9 +1087,31 @@ describe("ServerSettings environment icon", () => {
1087
1088 const decodeDeviceHostSettings = Schema.decodeSync(ServerSettings);
1089
1090 +// `deviceHosts` as it was decoded before EAS hosts existed: an SSH host needs a target.
1091 +const decodeOlderDeviceHostSettings = Schema.decodeUnknownSync(
1092 + Schema.Struct({
1093 + deviceHosts: Schema.Array(Schema.Struct({ id: Schema.String, target: Schema.String })),
1094 + }),
1095 +);
1096 +
1097 +it("keeps EAS hosts out of the SSH host list servers and clients before EAS hosts decode", () => {
1098 + const settings = decodeDeviceHostSettings({
1099 + deviceHosts: [{ id: "mini", label: "Mac mini", target: "user@mini" }],
1100 + easDeviceHosts: [{ kind: "eas", id: "eas", label: "EAS Simulator" }],
1101 + });
1102 + const wire = encodeServerSettings(settings);
1103 + expect(decodeOlderDeviceHostSettings(wire).deviceHosts).toEqual([
1104 + { id: "mini", target: "user@mini" },
1105 + ]);
1106 + expect(settings.easDeviceHosts.map((host) => host.id)).toEqual(["eas"]);
1107 +});
1108 +
1109 it("validates remote device hosts and rejects ambiguous host ids", () => {
1110 const host = { id: "mini", label: "Mac mini", target: "user@mini", port: 2222 };
1092 - expect(decodeDeviceHostSettings({ deviceHosts: [host] }).deviceHosts).toEqual([host]);
1111 + // Hosts saved before EAS hosts existed have no `kind`; they are SSH hosts.
1112 + expect(decodeDeviceHostSettings({ deviceHosts: [host] }).deviceHosts).toEqual([
1113 + { kind: "ssh", ...host },
1114 + ]);
1115 expect(() => decodeDeviceHostSettings({ deviceHosts: [host, host] })).toThrow();
1116 expect(() => decodeDeviceHostSettings({ deviceHosts: [{ ...host, id: "local" }] })).toThrow();
1117 expect(() =>
packages/contracts/src/settings.ts
+3 -1
@@ -1,4 +1,4 @@
1 -import { SshDeviceHostConfigs } from "./device.ts";
1 +import { EasDeviceHostConfigs, SshDeviceHostConfigs } from "./device.ts";
2 import {
3 AuthOrchestrationOperateScope,
4 AuthSettingsWriteScope,
@@ -1155,6 +1155,7 @@ export const ServerSettings = Schema.Struct({
1155 enableDeviceSupport: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
1156 deviceOnboardingCompleted: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
1157 deviceHosts: SshDeviceHostConfigs.pipe(Schema.withDecodingDefault(Effect.succeed([]))),
1158 + easDeviceHosts: EasDeviceHostConfigs.pipe(Schema.withDecodingDefault(Effect.succeed([]))),
1159 sidebarAutoSettleAfterDays: Schema.NullOr(SidebarAutoSettleAfterDays).pipe(
1160 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS)),
1161 ),
@@ -1471,6 +1472,7 @@ export const ServerSettingsPatch = Schema.Struct({
1472 enableDeviceSupport: Schema.optionalKey(Schema.Boolean),
1473 deviceOnboardingCompleted: Schema.optionalKey(Schema.Boolean),
1474 deviceHosts: Schema.optionalKey(SshDeviceHostConfigs),
1475 + easDeviceHosts: Schema.optionalKey(EasDeviceHostConfigs),
1476 sidebarAutoSettleAfterDays: Schema.optionalKey(Schema.NullOr(SidebarAutoSettleAfterDays)),
1477 compactIdleThreads: Schema.optionalKey(Schema.Boolean),
1478 sidebarAutoSettleKeepPullRequests: Schema.optionalKey(Schema.Boolean),
packages/shared/src/serverSettings.test.ts
+20 -1
@@ -86,7 +86,7 @@ describe("serverSettings helpers", () => {
86 });
87 });
88 it("replaces SSH host lists when saving, editing, and removing hosts", () => {
89 - const host = { id: "mini", label: "Mac mini", target: "mini" };
89 + const host = { kind: "ssh" as const, id: "mini", label: "Mac mini", target: "mini" };
90 const saved = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, { deviceHosts: [host] });
91 expect(saved.deviceHosts).toEqual([host]);
92 const replacement = { ...host, target: "other-mini" };
@@ -95,6 +95,25 @@ describe("serverSettings helpers", () => {
95 expect(applyServerSettingsPatch(edited, { deviceHosts: [] }).deviceHosts).toEqual([]);
96 });
97
98 + it("replaces EAS host lists the same way", () => {
99 + const host = {
100 + kind: "eas" as const,
101 + id: "eas",
102 + label: "EAS Simulator",
103 + accessToken: "",
104 + maxSessionMinutes: 30,
105 + idleMinutes: 10,
106 + maxConcurrentSessions: 2,
107 + };
108 + const saved = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, { easDeviceHosts: [host] });
109 + expect(saved.easDeviceHosts).toEqual([host]);
110 + const edited = applyServerSettingsPatch(saved, {
111 + easDeviceHosts: [{ ...host, maxSessionMinutes: 60 }],
112 + });
113 + expect(edited.easDeviceHosts).toEqual([{ ...host, maxSessionMinutes: 60 }]);
114 + expect(applyServerSettingsPatch(edited, { easDeviceHosts: [] }).easDeviceHosts).toEqual([]);
115 + });
116 +
117 it("inherits actions, preserves existing actions, and supports empty overrides and reset", () => {
118 const project = { id: ProjectId.make("project-actions"), scripts: [] };
119 const action = {