The best way to control Claude Code, Codex and more from any computer or phone
feat(web): set up EAS Simulator hosts in Settings (#21846)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 20, 2026 at 00:57 UTC
d18352e378c530dc41f3dfa2ffc3f2b263e38914
13 files changed
+639
-3
apps/server/src/auth/RpcAuthorization.ts
+1
@@ -195,6 +195,7 @@ export const RPC_REQUIRED_SCOPES = {
195
[WS_METHODS.subscribeDiscoveredLocalServers]: AuthOrchestrationReadScope,
196
[WS_METHODS.deviceConfigure]: AuthSettingsWriteScope,
197
[WS_METHODS.deviceTestHost]: AuthSettingsWriteScope,
198
+ [WS_METHODS.deviceEasAccount]: AuthSettingsWriteScope,
199
[WS_METHODS.deviceList]: AuthOrchestrationReadScope,
200
[WS_METHODS.deviceOpen]: AuthOrchestrationOperateScope,
201
[WS_METHODS.deviceClose]: AuthOrchestrationOperateScope,
apps/server/src/device/DeviceService.ts
+46
@@ -17,6 +17,9 @@ import {
17
type DeviceSession,
18
type DeviceShutdownInput,
19
type DeviceSummary,
20
+ type DeviceEasAccount,
21
+ DeviceEasAccountError,
22
+ type DeviceEasAccountInput,
23
type DeviceHostConfig,
24
type EasDeviceHostConfig,
25
type SshDeviceHostConfig,
@@ -46,6 +49,7 @@ import * as Scope from "effect/Scope";
49
import * as Semaphore from "effect/Semaphore";
50
import * as Stream from "effect/Stream";
51
import * as SynchronizedRef from "effect/SynchronizedRef";
52
+import * as HttpClient from "effect/http/HttpClient";
53
54
import * as ServerSettings from "../serverSettings.ts";
55
import { isLocalSshDeviceHost, remoteSshDeviceHosts } from "./localSshDeviceHost.ts";
@@ -55,6 +59,7 @@ import * as ProcessRunner from "../processRunner.ts";
59
import * as DeviceHost from "./DeviceHost.ts";
60
import * as SshDeviceHost from "./SshDeviceHost.ts";
61
import * as EasDeviceHost from "./EasDeviceHost.ts";
62
+import { makeExpoApi, resolveExpoCredential } from "./ExpoApi.ts";
63
import * as Exit from "effect/Exit";
64
import * as LocalDeviceHost from "./LocalDeviceHost.ts";
65
@@ -103,6 +108,10 @@ export class DeviceService extends Context.Service<
108
readonly testHost: (
109
config: SshDeviceHostConfig,
110
) => Effect.Effect<DeviceHostSummary, DeviceError>;
111
+ /** Who an Expo credential signs in as and which EAS projects it can run sessions under. */
112
+ readonly easAccount: (
113
+ input: DeviceEasAccountInput,
114
+ ) => Effect.Effect<DeviceEasAccount, DeviceEasAccountError>;
115
/**
116
* The agent-device flags that reach the device: its config and session,
117
* and the id agent-device selects it by, which can differ from its id here.
@@ -199,6 +208,7 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
208
supportsHostRetry: true,
209
supportsToolUpdate: installTool !== undefined,
210
supportsToolInspection: true,
211
+ supportsEasHosts: true,
212
hosts: initialHosts,
213
hostStatus: initialSettings.enabled ? "idle" : "disabled",
214
hostStatuses: {},
@@ -810,6 +820,12 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
820
),
821
retryHost,
822
inspect,
823
+ easAccount: () =>
824
+ Effect.fail(
825
+ new DeviceEasAccountError({
826
+ reason: "EAS accounts are unavailable in this device service.",
827
+ }),
828
+ ),
829
agentCli: Effect.fail(
830
new DeviceHostUnavailableError({
831
hostId: LOCAL_DEVICE_HOST_ID,
@@ -1083,8 +1099,38 @@ export const make = Effect.gen(function* () {
1099
concurrency: 4,
1100
}),
1101
);
1102
+ const easAccount: DeviceService["Service"]["easAccount"] = Effect.fn("DeviceService.easAccount")(
1103
+ function* (input) {
1104
+ const saved =
1105
+ input.hostId === undefined
1106
+ ? ""
1107
+ : ((yield* settings.getSettings).easDeviceHosts.find((host) => host.id === input.hostId)
1108
+ ?.accessToken ?? "");
1109
+ const credential = yield* resolveExpoCredential(input.accessToken ?? saved);
1110
+ const viewer = yield* makeExpoApi(yield* HttpClient.HttpClient, credential).viewer;
1111
+ return { signedInAs: viewer.name, credentialSource: credential.source, apps: viewer.apps };
1112
+ },
1113
+ Effect.provide(easContext),
1114
+ // Only bounded text reaches the browser: the credential errors' own
1115
+ // guidance, or a category for what Expo answered, never Expo's text.
1116
+ Effect.mapError(
1117
+ (cause) =>
1118
+ new DeviceEasAccountError({
1119
+ reason:
1120
+ cause._tag === "ExpoApiError"
1121
+ ? cause.status === 401 || cause.status === 403
1122
+ ? `Expo rejected the credential (HTTP ${cause.status}).`
1123
+ : cause.rejected
1124
+ ? "Expo refused the account check."
1125
+ : "Could not complete the Expo account check."
1126
+ : cause.message,
1127
+ }),
1128
+ ),
1129
+ );
1130
+
1131
return {
1132
...service,
1133
+ easAccount,
1134
agentCli: resolveNodeExecutable("Device automation").pipe(
1135
Effect.andThen(ensureAgentDevice(config.baseDir)),
1136
Effect.provideService(FileSystem.FileSystem, fs),
apps/server/src/observability/RpcInstrumentation.ts
+1
@@ -199,6 +199,7 @@ const RPC_AGGREGATES = {
199
[WS_METHODS.subscribeDiscoveredLocalServers]: "preview",
200
[WS_METHODS.deviceConfigure]: "device",
201
[WS_METHODS.deviceTestHost]: "device",
202
+ [WS_METHODS.deviceEasAccount]: "device",
203
[WS_METHODS.deviceList]: "device",
204
[WS_METHODS.deviceOpen]: "device",
205
[WS_METHODS.deviceClose]: "device",
apps/server/src/ws.ts
+1
@@ -2904,6 +2904,7 @@ export const layerWsRpc = (
2904
[WS_METHODS.subscribePreviewEvents]: (_input) => previewManager.events,
2905
[WS_METHODS.deviceConfigure]: (input) => deviceService.configure(input),
2906
[WS_METHODS.deviceTestHost]: (input) => deviceService.testHost(input),
2907
+ [WS_METHODS.deviceEasAccount]: (input) => deviceService.easAccount(input),
2908
[WS_METHODS.deviceList]: (input) =>
2909
input.inspectOnly && !input.updateTool
2910
? deviceService.inspect
apps/web/src/components/device/DeviceSetup.test.ts
+42
@@ -63,6 +63,48 @@ describe("device setup guidance", () => {
63
expect(platformSetupStatus(state, "android").message).toBe("Android Emulator is missing.");
64
});
65
66
+ it("names an EAS host instead of local tooling when only the cloud can run iOS", () => {
67
+ const state = deviceState({
68
+ hostStatus: "idle",
69
+ hostStatuses: { eas: { status: "ready" } },
70
+ hosts: [
71
+ {
72
+ ...deviceState().hosts[0]!,
73
+ platforms: [
74
+ { platform: "ios", available: false, reason: "Xcode was not found." },
75
+ { platform: "android", available: false, reason: "No SDK." },
76
+ ],
77
+ },
78
+ {
79
+ id: "eas",
80
+ kind: "eas",
81
+ label: "EAS Simulator",
82
+ hubInstalled: true,
83
+ agentDeviceInstalled: true,
84
+ platforms: [
85
+ { platform: "ios", available: true },
86
+ { platform: "android", available: false, reason: "Not supported yet." },
87
+ ],
88
+ },
89
+ ],
90
+ devices: [
91
+ {
92
+ hostId: "eas",
93
+ id: "eas-ios",
94
+ platform: "ios",
95
+ name: "iPhone (EAS Simulator)",
96
+ version: "Cloud",
97
+ booted: false,
98
+ physical: false,
99
+ },
100
+ ],
101
+ });
102
+ expect(platformSetupStatus(state, "ios")).toEqual({
103
+ ready: true,
104
+ message: "EAS Simulator starts iOS Simulators in the cloud with EAS Simulator.",
105
+ });
106
+ });
107
+
108
it("counts a remote device host when this machine has no simulator tooling", () => {
109
const state = deviceState({
110
hostStatus: "idle",
apps/web/src/components/device/DeviceSetup.tsx
+5
-3
@@ -117,9 +117,11 @@ export function platformSetupStatus(state: DeviceServiceState, platform: DeviceP
117
return {
118
ready: true,
119
message:
120
- platform === "ios"
121
- ? `Xcode and iOS Simulator are available${location}.`
122
- : `The Android SDK and Emulator are available${location}.`,
120
+ remoteHost?.kind === "eas"
121
+ ? `${remoteHost.label} starts iOS Simulators in the cloud with EAS Simulator.`
122
+ : platform === "ios"
123
+ ? `Xcode and iOS Simulator are available${location}.`
124
+ : `The Android SDK and Emulator are available${location}.`,
125
};
126
}
127
apps/web/src/components/settings/EasDeviceHostsSettings.tsx
new
+422
@@ -0,0 +1,422 @@
1
+import { useEffect, useEffectEvent, useId, useRef, useState } from "react";
2
+import * as Cause from "effect/Cause";
3
+import * as Option from "effect/Option";
4
+import {
5
+ AuthSettingsWriteScope,
6
+ type DeviceEasAccount,
7
+ type EasDeviceHostConfig,
8
+ type EnvironmentId,
9
+} from "@t3tools/contracts";
10
+import { CloudIcon, PlusIcon, XIcon } from "lucide-react";
11
+
12
+import { randomUUID } from "../../lib/utils";
13
+import { deviceEnvironment } from "../../state/device";
14
+import { serverEnvironment } from "../../state/server";
15
+import { readEnvironmentScope, useEnvironmentScope } from "../../state/session";
16
+import { useAtomCommand } from "../../state/use-atom-command";
17
+import { Button } from "../ui/button";
18
+import {
19
+ Dialog,
20
+ DialogDescription,
21
+ DialogFooter,
22
+ DialogHeader,
23
+ DialogPanel,
24
+ DialogPopup,
25
+ DialogTitle,
26
+} from "../ui/dialog";
27
+import { Input } from "../ui/input";
28
+import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
29
+import { Spinner } from "../ui/spinner";
30
+import { toastManager } from "../ui/toast";
31
+import {
32
+ easSessionLimits,
33
+ newEasDeviceHost,
34
+ parseEasDeviceHostDraft,
35
+ updateEasDeviceHosts,
36
+} from "./easDeviceHostsSettings.logic";
37
+import { SecretInput } from "./SecretInput";
38
+import { useSettingsScope } from "./SettingsScopeContext";
39
+import { SettingsRow } from "./settingsLayout";
40
+
41
+const FROM_THREAD_PROJECT = "thread-project";
42
+
43
+const CREDENTIAL_SOURCES: Record<DeviceEasAccount["credentialSource"], string> = {
44
+ settings: "the access token saved here",
45
+ env: "EXPO_TOKEN on the server",
46
+ "eas-login": "the server's eas login",
47
+};
48
+
49
+const failureMessage = (cause: Cause.Cause<unknown>) => {
50
+ const error = Cause.squash(cause);
51
+ return error instanceof Error ? error.message : String(error);
52
+};
53
+
54
+/** EAS hosts belong to one environment: its server holds the Expo credential and runs the sessions. */
55
+export function EasDeviceHostsSettings(props: { environmentId: EnvironmentId | null }) {
56
+ const { scope, connectedEnvironments } = useSettingsScope();
57
+ const canConfigure = useEnvironmentScope(props.environmentId, AuthSettingsWriteScope);
58
+ const projectScope = scope.kind === "project" || scope.kind === "checkout";
59
+ const update = useAtomCommand(serverEnvironment.updateSettings, { reportFailure: false });
60
+ const environment = connectedEnvironments.find(
61
+ (candidate) => candidate.environmentId === props.environmentId,
62
+ );
63
+ const hosts = environment?.serverConfig?.settings.easDeviceHosts ?? [];
64
+ const [editing, setEditing] = useState<{ host: EasDeviceHostConfig; isNew: boolean } | null>(
65
+ null,
66
+ );
67
+ const [busy, setBusy] = useState(false);
68
+ const disabled = !canConfigure || projectScope || busy || !props.environmentId;
69
+
70
+ const save = async (host: EasDeviceHostConfig, remove: boolean) => {
71
+ if (!props.environmentId || !readEnvironmentScope(props.environmentId, AuthSettingsWriteScope))
72
+ return;
73
+ setBusy(true);
74
+ const result = await update({
75
+ environmentId: props.environmentId,
76
+ input: { patch: { easDeviceHosts: updateEasDeviceHosts(hosts, host, remove) } },
77
+ });
78
+ setBusy(false);
79
+ if (result._tag === "Success") setEditing(null);
80
+ else
81
+ toastManager.add({
82
+ type: "error",
83
+ title: remove ? "EAS host not removed" : "EAS host not saved",
84
+ description: failureMessage(result.cause),
85
+ });
86
+ };
87
+
88
+ return (
89
+ <SettingsRow
90
+ id="eas-device-hosts"
91
+ title="EAS Simulator"
92
+ serverScoped
93
+ settingKeys={["easDeviceHosts"]}
94
+ description="Run iOS Simulators in Expo's cloud from this environment. Sessions bill the Expo account until they stop, so each host limits how many run and for how long. Editing or removing a host stops its running sessions."
95
+ control={
96
+ <Button
97
+ size="sm"
98
+ variant="outline"
99
+ disabled={disabled || editing !== null}
100
+ onClick={() => setEditing({ host: newEasDeviceHost(randomUUID()), isNew: true })}
101
+ >
102
+ <PlusIcon className="size-3.5" /> Add EAS host
103
+ </Button>
104
+ }
105
+ >
106
+ <div className="pt-3 pb-2">
107
+ {hosts.length === 0 ? (
108
+ <p className="text-sm text-muted-foreground">No EAS hosts.</p>
109
+ ) : (
110
+ <ul className="divide-y divide-border/40">
111
+ {hosts.map((host) => (
112
+ <li key={host.id} className="flex items-center justify-between gap-3 py-2.5 text-sm">
113
+ <div className="min-w-0">
114
+ <p className="flex items-center gap-1.5 truncate font-medium">
115
+ <CloudIcon className="size-3.5 shrink-0" /> {host.label}
116
+ </p>
117
+ <p className="truncate text-xs text-muted-foreground">{easSessionLimits(host)}</p>
118
+ </div>
119
+ <div className="flex shrink-0 gap-1">
120
+ <Button
121
+ size="sm"
122
+ variant="ghost"
123
+ disabled={disabled}
124
+ onClick={() => setEditing({ host, isNew: false })}
125
+ >
126
+ Edit
127
+ </Button>
128
+ <Button
129
+ size="sm"
130
+ variant="ghost-destructive"
131
+ disabled={disabled}
132
+ onClick={() => void save(host, true)}
133
+ >
134
+ Remove
135
+ </Button>
136
+ </div>
137
+ </li>
138
+ ))}
139
+ </ul>
140
+ )}
141
+ {editing && props.environmentId ? (
142
+ <EasDeviceHostEditor
143
+ key={editing.host.id}
144
+ environmentId={props.environmentId}
145
+ host={editing.host}
146
+ isNew={editing.isNew}
147
+ busy={busy}
148
+ onSave={(host) => void save(host, false)}
149
+ onClose={() => setEditing(null)}
150
+ />
151
+ ) : null}
152
+ </div>
153
+ </SettingsRow>
154
+ );
155
+}
156
+
157
+function EasDeviceHostEditor(props: {
158
+ environmentId: EnvironmentId;
159
+ host: EasDeviceHostConfig;
160
+ isNew: boolean;
161
+ busy: boolean;
162
+ onSave: (host: EasDeviceHostConfig) => void;
163
+ onClose: () => void;
164
+}) {
165
+ const check = useAtomCommand(deviceEnvironment.easAccount, { reportFailure: false });
166
+ const [draft, setDraft] = useState(props.host);
167
+ const tokenId = useId();
168
+ // A saved token arrives redacted; only a replacement or a clear changes it.
169
+ const [token, setToken] = useState<
170
+ { kind: "saved" } | { kind: "new"; value: string } | { kind: "cleared" }
171
+ >(props.host.accessToken ? { kind: "saved" } : { kind: "cleared" });
172
+ const [account, setAccount] = useState<
173
+ | { status: "idle" }
174
+ | { status: "checking" }
175
+ | { status: "signed-in"; account: DeviceEasAccount }
176
+ | { status: "failed"; error: string }
177
+ // The editor checks the account as it opens.
178
+ >({ status: "checking" });
179
+ const next: EasDeviceHostConfig = {
180
+ ...draft,
181
+ label: draft.label.trim(),
182
+ accessToken:
183
+ token.kind === "saved" ? props.host.accessToken : token.kind === "new" ? token.value : "",
184
+ };
185
+ const valid = Option.isSome(parseEasDeviceHostDraft(next));
186
+ // Why Save is off, for the limits the fields' ranges do not show.
187
+ const problem = valid
188
+ ? null
189
+ : draft.maxSessionMinutes > 0 && draft.idleMinutes >= draft.maxSessionMinutes
190
+ ? "Idle minutes must be smaller than session minutes."
191
+ : "Give the host a label and limits within the ranges shown.";
192
+ const apps = account.status === "signed-in" ? account.account.apps : [];
193
+
194
+ // A check answers for the credential it was asked about: a later check or a
195
+ // token edit makes an earlier answer stale.
196
+ const latestCheck = useRef(0);
197
+ const resetAccount = () => {
198
+ latestCheck.current++;
199
+ setAccount({ status: "idle" });
200
+ };
201
+ const requestCheck = async () => {
202
+ const run = ++latestCheck.current;
203
+ const result = await check({
204
+ environmentId: props.environmentId,
205
+ input: {
206
+ ...(token.kind === "saved" && !props.isNew ? { hostId: props.host.id } : {}),
207
+ // A cleared token is sent as empty, so the check does not fall back to
208
+ // the saved one that Save is about to drop.
209
+ ...(token.kind === "new"
210
+ ? { accessToken: token.value }
211
+ : token.kind === "cleared"
212
+ ? { accessToken: "" }
213
+ : {}),
214
+ },
215
+ });
216
+ if (run !== latestCheck.current) return;
217
+ setAccount(
218
+ result._tag === "Success"
219
+ ? { status: "signed-in", account: result.value }
220
+ : { status: "failed", error: failureMessage(result.cause) },
221
+ );
222
+ };
223
+ const checkAccount = () => {
224
+ setAccount({ status: "checking" });
225
+ void requestCheck();
226
+ };
227
+
228
+ // Checking on open names the saved project and shows a rejected credential
229
+ // before anything is changed.
230
+ const checkOnOpen = useEffectEvent(() => void requestCheck());
231
+ useEffect(() => {
232
+ checkOnOpen();
233
+ }, []);
234
+
235
+ const limit = (
236
+ field: "maxSessionMinutes" | "idleMinutes" | "maxConcurrentSessions",
237
+ label: string,
238
+ max: number,
239
+ ) => (
240
+ <label className="block space-y-1.5">
241
+ <span>{label}</span>
242
+ <Input
243
+ type="number"
244
+ min={1}
245
+ max={max}
246
+ value={draft[field]}
247
+ disabled={props.busy}
248
+ onChange={(event) => {
249
+ const value = Number(event.target.value);
250
+ setDraft((current) => ({ ...current, [field]: value }));
251
+ }}
252
+ />
253
+ </label>
254
+ );
255
+
256
+ return (
257
+ <Dialog
258
+ open
259
+ onOpenChange={(open) => {
260
+ if (!open && !props.busy) props.onClose();
261
+ }}
262
+ >
263
+ <DialogPopup showCloseButton={!props.busy}>
264
+ <form
265
+ className="flex min-h-0 flex-col"
266
+ onSubmit={(event) => {
267
+ event.preventDefault();
268
+ if (valid && !props.busy) props.onSave(next);
269
+ }}
270
+ >
271
+ <DialogHeader>
272
+ <DialogTitle>{props.isNew ? "Add EAS host" : "Edit EAS host"}</DialogTitle>
273
+ <DialogDescription>
274
+ The environment's server signs in to Expo and starts the sessions. Without a token
275
+ here it uses EXPO_TOKEN, then its eas login.
276
+ </DialogDescription>
277
+ </DialogHeader>
278
+ <DialogPanel>
279
+ <label className="block space-y-1.5 text-sm">
280
+ <span>Name</span>
281
+ <Input
282
+ autoFocus
283
+ required
284
+ value={draft.label}
285
+ disabled={props.busy}
286
+ onChange={(event) => {
287
+ const label = event.target.value;
288
+ setDraft((current) => ({ ...current, label }));
289
+ }}
290
+ />
291
+ </label>
292
+ <div className="space-y-1.5 text-sm">
293
+ <label htmlFor={tokenId} className="block">
294
+ Expo access token
295
+ </label>
296
+ <div className="flex items-center gap-2">
297
+ <SecretInput
298
+ id={tokenId}
299
+ className="min-w-0 flex-1"
300
+ configured={token.kind === "saved"}
301
+ value={token.kind === "new" ? token.value : ""}
302
+ disabled={props.busy}
303
+ placeholder="Optional"
304
+ onChange={(event) => {
305
+ const value = event.target.value;
306
+ // Emptying the field is not clearing the saved token; the
307
+ // Clear button is, so a saved token comes back here.
308
+ setToken(
309
+ value
310
+ ? { kind: "new", value }
311
+ : props.host.accessToken
312
+ ? { kind: "saved" }
313
+ : { kind: "cleared" },
314
+ );
315
+ resetAccount();
316
+ }}
317
+ />
318
+ {token.kind !== "cleared" ? (
319
+ <Button
320
+ type="button"
321
+ size="icon-sm"
322
+ variant="ghost-destructive"
323
+ aria-label="Clear access token"
324
+ onClick={() => {
325
+ setToken({ kind: "cleared" });
326
+ resetAccount();
327
+ }}
328
+ >
329
+ <XIcon className="size-3.5" />
330
+ </Button>
331
+ ) : null}
332
+ </div>
333
+ </div>
334
+ <div className="flex items-center justify-between gap-3 rounded-lg border border-border/60 px-3 py-2.5">
335
+ <p role="status" className="min-w-0 text-xs text-muted-foreground">
336
+ {account.status === "signed-in"
337
+ ? `Signed in as ${account.account.signedInAs} with ${CREDENTIAL_SOURCES[account.account.credentialSource]}.`
338
+ : account.status === "failed"
339
+ ? account.error
340
+ : account.status === "checking"
341
+ ? "Checking the Expo account…"
342
+ : "Check the Expo account before choosing a project."}
343
+ </p>
344
+ <Button
345
+ type="button"
346
+ size="sm"
347
+ variant="outline"
348
+ disabled={props.busy || account.status === "checking"}
349
+ onClick={() => void checkAccount()}
350
+ >
351
+ {account.status === "checking" ? <Spinner size="xs" /> : null} Check account
352
+ </Button>
353
+ </div>
354
+ <div className="space-y-1.5 text-sm">
355
+ <span>EAS project</span>
356
+ <Select
357
+ value={draft.appId ?? FROM_THREAD_PROJECT}
358
+ disabled={props.busy}
359
+ onValueChange={(value) => {
360
+ if (typeof value !== "string") return;
361
+ setDraft((current) => {
362
+ const { appId: _, ...rest } = current;
363
+ return value === FROM_THREAD_PROJECT ? rest : { ...rest, appId: value };
364
+ });
365
+ }}
366
+ >
367
+ <SelectTrigger size="sm" aria-label="EAS project">
368
+ <SelectValue>
369
+ {(value: string) =>
370
+ value === FROM_THREAD_PROJECT
371
+ ? "From the thread's project"
372
+ : (apps.find((app) => app.id === value)?.fullName ?? value)
373
+ }
374
+ </SelectValue>
375
+ </SelectTrigger>
376
+ <SelectPopup>
377
+ <SelectItem value={FROM_THREAD_PROJECT}>From the thread's project</SelectItem>
378
+ {draft.appId && !apps.some((app) => app.id === draft.appId) ? (
379
+ <SelectItem value={draft.appId}>{draft.appId}</SelectItem>
380
+ ) : null}
381
+ {apps.map((app) => (
382
+ <SelectItem key={app.id} value={app.id}>
383
+ {app.fullName}
384
+ </SelectItem>
385
+ ))}
386
+ </SelectPopup>
387
+ </Select>
388
+ <p className="text-xs text-muted-foreground">
389
+ Sessions bill the project's Expo account. "From the thread's project" reads
390
+ extra.eas.projectId from the project's app config.
391
+ </p>
392
+ </div>
393
+ <div className="grid grid-cols-3 gap-3 text-sm">
394
+ {limit("maxConcurrentSessions", "Sessions at once", 20)}
395
+ {limit("maxSessionMinutes", "Session minutes", 115)}
396
+ {limit("idleMinutes", "Idle minutes", 60)}
397
+ </div>
398
+ <p className="text-xs text-muted-foreground">
399
+ Expo allows sessions of up to 40 minutes on free accounts and 115 on paid ones, and
400
+ ends one after the idle minutes without activity, so idle minutes must be smaller than
401
+ session minutes.
402
+ {props.isNew ? null : " Saving restarts this host, which stops its running sessions."}
403
+ </p>
404
+ {problem === null ? null : (
405
+ <p className="text-xs text-destructive" role="alert">
406
+ {problem}
407
+ </p>
408
+ )}
409
+ </DialogPanel>
410
+ <DialogFooter>
411
+ <Button type="button" variant="ghost" disabled={props.busy} onClick={props.onClose}>
412
+ Cancel
413
+ </Button>
414
+ <Button type="submit" disabled={props.busy || !valid}>
415
+ {props.busy ? <Spinner size="xs" /> : null} Save host
416
+ </Button>
417
+ </DialogFooter>
418
+ </form>
419
+ </DialogPopup>
420
+ </Dialog>
421
+ );
422
+}
apps/web/src/components/settings/IntegrationsSettings.tsx
+2
@@ -3,6 +3,7 @@ import { DeviceToolVersions } from "../device/DeviceToolVersions";
3
import { useScopedSettings, useUpdateScopedSettings } from "./useScopedSettings";
4
import { ScopedSwitch } from "./ScopedSwitch";
5
import { DeviceHostsSettings } from "./DeviceHostsSettings";
6
+import { EasDeviceHostsSettings } from "./EasDeviceHostsSettings";
7
import {
8
AuthSettingsWriteScope,
9
BrowserImportFailureReason,
@@ -1068,6 +1069,7 @@ export function DeviceIntegrationControls({
1069
/>
1070
) : null}
1071
<DeviceHostsSettings environmentId={environmentId} />
1072
+ {state.supportsEasHosts ? <EasDeviceHostsSettings environmentId={environmentId} /> : null}
1073
</>
1074
);
1075
}
apps/web/src/components/settings/easDeviceHostsSettings.logic.test.ts
new
+42
@@ -0,0 +1,42 @@
1
+import { describe, expect, it } from "vite-plus/test";
2
+import * as Option from "effect/Option";
3
+
4
+import {
5
+ easSessionLimits,
6
+ newEasDeviceHost,
7
+ parseEasDeviceHostDraft,
8
+ updateEasDeviceHosts,
9
+} from "./easDeviceHostsSettings.logic";
10
+
11
+describe("EAS device host settings", () => {
12
+ it("adds, edits, and removes one EAS host without touching the others", () => {
13
+ const other = newEasDeviceHost("eas-0");
14
+ const eas = newEasDeviceHost("eas-1");
15
+ const added = updateEasDeviceHosts([other], eas, false);
16
+ expect(added).toEqual([other, eas]);
17
+ const edited = { ...eas, label: "Cloud iPhone", maxConcurrentSessions: 1 };
18
+ expect(updateEasDeviceHosts(added, edited, false)).toEqual([other, edited]);
19
+ expect(updateEasDeviceHosts(added, eas, true)).toEqual([other]);
20
+ });
21
+
22
+ it("rejects limits EAS does not allow", () => {
23
+ expect(Option.isSome(parseEasDeviceHostDraft(newEasDeviceHost("eas")))).toBe(true);
24
+ expect(
25
+ Option.isNone(parseEasDeviceHostDraft({ ...newEasDeviceHost("eas"), maxSessionMinutes: 10 })),
26
+ ).toBe(true);
27
+ expect(
28
+ Option.isNone(
29
+ parseEasDeviceHostDraft({ ...newEasDeviceHost("eas"), maxSessionMinutes: 600 }),
30
+ ),
31
+ ).toBe(true);
32
+ expect(Option.isNone(parseEasDeviceHostDraft({ ...newEasDeviceHost("eas"), label: " " }))).toBe(
33
+ true,
34
+ );
35
+ });
36
+
37
+ it("describes a host's bounds in one line", () => {
38
+ expect(easSessionLimits({ ...newEasDeviceHost("eas"), maxConcurrentSessions: 1 })).toBe(
39
+ "Up to 1 session at once, each stopped after 30 min or 10 idle min",
40
+ );
41
+ });
42
+});
apps/web/src/components/settings/easDeviceHostsSettings.logic.ts
new
+35
@@ -0,0 +1,35 @@
1
+import {
2
+ EasDeviceHostConfig,
3
+ type EasDeviceHostConfig as EasDeviceHostConfigType,
4
+} from "@t3tools/contracts";
5
+import * as Schema from "effect/Schema";
6
+
7
+export const parseEasDeviceHostDraft = Schema.decodeUnknownOption(EasDeviceHostConfig);
8
+
9
+export const newEasDeviceHost = (id: string): EasDeviceHostConfigType => ({
10
+ kind: "eas",
11
+ id,
12
+ label: "EAS Simulator",
13
+ accessToken: "",
14
+ maxSessionMinutes: 30,
15
+ idleMinutes: 10,
16
+ maxConcurrentSessions: 2,
17
+});
18
+
19
+/** Adds, replaces, or removes one EAS host. */
20
+export function updateEasDeviceHosts(
21
+ hosts: ReadonlyArray<EasDeviceHostConfigType>,
22
+ host: EasDeviceHostConfigType,
23
+ remove: boolean,
24
+): ReadonlyArray<EasDeviceHostConfigType> {
25
+ if (remove) return hosts.filter((candidate) => candidate.id !== host.id);
26
+ return hosts.some((candidate) => candidate.id === host.id)
27
+ ? hosts.map((candidate) => (candidate.id === host.id ? host : candidate))
28
+ : [...hosts, host];
29
+}
30
+
31
+export function easSessionLimits(host: EasDeviceHostConfigType) {
32
+ const sessions =
33
+ host.maxConcurrentSessions === 1 ? "1 session" : `${host.maxConcurrentSessions} sessions`;
34
+ return `Up to ${sessions} at once, each stopped after ${host.maxSessionMinutes} min or ${host.idleMinutes} idle min`;
35
+}
packages/client-runtime/src/state/device.ts
+4
@@ -50,6 +50,10 @@ export function createDeviceEnvironmentAtoms<R, E>(
50
label: "environment-data:device:test-host",
51
tag: WS_METHODS.deviceTestHost,
52
}),
53
+ easAccount: createEnvironmentRpcCommand(runtime, {
54
+ label: "environment-data:device:eas-account",
55
+ tag: WS_METHODS.deviceEasAccount,
56
+ }),
57
list: createEnvironmentRpcCommand(runtime, {
58
label: "environment-data:device:list",
59
tag: WS_METHODS.deviceList,
packages/contracts/src/device.ts
+27
@@ -85,6 +85,31 @@ export const SshDeviceHostConfigs = Schema.Array(SshDeviceHostConfig).check(uniq
85
*/
86
export const EasDeviceHostConfigs = Schema.Array(EasDeviceHostConfig).check(uniqueHostIds);
87
88
+export const DeviceEasAccountInput = Schema.Struct({
89
+ /** A saved EAS host whose stored token is checked when no new token is given. */
90
+ hostId: Schema.optional(DeviceHostId),
91
+ accessToken: Schema.optional(TrimmedString),
92
+});
93
+export type DeviceEasAccountInput = typeof DeviceEasAccountInput.Type;
94
+
95
+export const DeviceEasAccount = Schema.Struct({
96
+ signedInAs: Schema.String,
97
+ credentialSource: Schema.Literals(["settings", "env", "eas-login"]),
98
+ apps: Schema.Array(Schema.Struct({ id: Schema.String, fullName: Schema.String })),
99
+});
100
+export type DeviceEasAccount = typeof DeviceEasAccount.Type;
101
+
102
+/** Checking an Expo credential failed; no device host is involved yet. */
103
+export class DeviceEasAccountError extends Schema.TaggedError<DeviceEasAccountError>()(
104
+ "DeviceEasAccountError",
105
+ // No cause: this error reaches the browser, and the reason already says what Expo answered.
106
+ { reason: Schema.String },
107
+) {
108
+ override get message(): string {
109
+ return this.reason;
110
+ }
111
+}
112
+
113
export const DeviceId = TrimmedNonEmptyString.check(Schema.isMaxLength(256));
114
export type DeviceId = typeof DeviceId.Type;
115
@@ -171,6 +196,8 @@ const deviceServiceStateFields = {
196
supportsHostRetry: Schema.optional(Schema.Boolean),
197
supportsToolUpdate: Schema.optional(Schema.Boolean),
198
supportsToolInspection: Schema.optional(Schema.Boolean),
199
+ /** Servers from before EAS hosts ignore `easDeviceHosts`, so clients offer them only when set. */
200
+ supportsEasHosts: Schema.optional(Schema.Boolean),
201
hostStatus: DeviceHostStatus,
202
hostStatusDetail: Schema.optional(Schema.String),
203
hostStatuses: DeviceHostStatuses,
packages/contracts/src/rpc.ts
+11
@@ -282,6 +282,9 @@ import {
282
DeviceError,
283
DeviceListInput,
284
SshDeviceHostConfig,
285
+ DeviceEasAccount,
286
+ DeviceEasAccountError,
287
+ DeviceEasAccountInput,
288
DeviceHostSummary,
289
DeviceOpenInput,
290
DeviceServiceState,
@@ -459,6 +462,7 @@ export const WS_METHODS = {
462
deviceConfigure: "device.configure",
463
deviceList: "device.list",
464
deviceTestHost: "device.testHost",
465
+ deviceEasAccount: "device.easAccount",
466
deviceOpen: "device.open",
467
deviceClose: "device.close",
468
deviceShutdown: "device.shutdown",
@@ -1555,6 +1559,12 @@ const WsDeviceTestHostRpc = Rpc.make(WS_METHODS.deviceTestHost, {
1559
error: Schema.Union([DeviceError, EnvironmentAuthorizationError]),
1560
});
1561
1562
+const WsDeviceEasAccountRpc = Rpc.make(WS_METHODS.deviceEasAccount, {
1563
+ payload: DeviceEasAccountInput,
1564
+ success: DeviceEasAccount,
1565
+ error: Schema.Union([DeviceEasAccountError, EnvironmentAuthorizationError]),
1566
+});
1567
+
1568
const WsDeviceListRpc = Rpc.make(WS_METHODS.deviceList, {
1569
payload: DeviceListInput,
1570
success: DeviceServiceState,
@@ -2031,6 +2041,7 @@ export const WsRpcGroup = RpcGroup.make(
2041
WsDeviceConfigureRpc,
2042
WsDeviceListRpc,
2043
WsDeviceTestHostRpc,
2044
+ WsDeviceEasAccountRpc,
2045
WsDeviceOpenRpc,
2046
WsDeviceCloseRpc,
2047
WsDeviceShutdownRpc,