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 21, 13:30 UTC
fix(server): let Expo decide EAS Simulator access (#29490)
Co-authored-by: Hirbod Mirjavadi <hirbod@expo.dev> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Hirbod committed
Nov 15, 2026 at 00:15 UTC
0bdf566607b6d27a0cb1233b89440ccbea81ca0b
8 files changed
+104
-167
apps/server/graphql.config.ts
-4
@@ -6,8 +6,4 @@ import { defineConfig } from "@effect/graphql-generator/Config";
6
export default defineConfig({
7
schema: "./schema/expo.graphql",
8
documents: ["src/device/**/*.graphql"],
9
- scalars: {
10
- // Feature gates arrive as an object of gate name to boolean.
11
- JSONObject: "effect/Schema#Json",
12
- },
9
});
apps/server/schema/expo.graphql.ts
-3
@@ -5,9 +5,6 @@ export const Int = Schema.Number.check(Schema.isInt32())
5
6
export const ID = Schema.String
7
8
-/** The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */
9
-export const JSONObject = Schema.Json
10
-
8
/**
9
* - `ANDROID`
10
* - `IOS`
apps/server/src/device/EasDeviceHost.test.ts
+89
-61
@@ -131,7 +131,15 @@ const fakeExpo = (
131
if (options.rejectCreate)
132
return HttpClientResponse.fromWeb(
133
request,
134
- Response.json({ errors: [{ message: "Not allowed" }] }),
134
+ Response.json({
135
+ errors: [
136
+ {
137
+ message: "Device run sessions are not enabled for this account.",
138
+ extensions: { errorType: "USER" },
139
+ },
140
+ ],
141
+ data: null,
142
+ }),
143
);
144
}
145
if (operation === "T3StopEasSimulatorSession" && options.failStop?.()) {
@@ -140,6 +148,24 @@ const fakeExpo = (
148
if (operation === "T3ActiveEasSimulatorSessions" && options.failList?.()) {
149
return HttpClientResponse.fromWeb(request, new Response("bad gateway", { status: 502 }));
150
}
151
+ // The account's feature gate is off, as for an Expo admin whom the create still admits.
152
+ if (body.query.includes("accountFeatureGates")) {
153
+ return HttpClientResponse.fromWeb(
154
+ request,
155
+ Response.json({
156
+ data: {
157
+ app: {
158
+ byId: {
159
+ ownerAccount: {
160
+ name: "pingdotgg",
161
+ accountFeatureGates: { "device-run-sessions": false },
162
+ },
163
+ },
164
+ },
165
+ },
166
+ }),
167
+ );
168
+ }
169
const sessionGate =
170
operation === "T3EasSimulatorSession" ? options.sessionGate?.() : undefined;
171
if (sessionGate && !sessionGated) {
@@ -148,73 +174,62 @@ const fakeExpo = (
174
yield* Deferred.await(sessionGate.release);
175
}
176
const data =
151
- operation === "T3EasSimulatorAvailability"
152
- ? {
153
- app: {
154
- byId: {
155
- ownerAccount: {
156
- name: "pingdotgg",
157
- accountFeatureGates: { "device-run-sessions": true },
177
+ operation === "T3CreateEasSimulatorSession"
178
+ ? { deviceRunSession: { createDeviceRunSession: { id: `session-${++created}` } } }
179
+ : operation === "T3ActiveEasSimulatorSessions"
180
+ ? {
181
+ app: {
182
+ byId: {
183
+ deviceRunSessionsPaginated: {
184
+ edges: [
185
+ ...(options.omitCreatedFromActive
186
+ ? []
187
+ : [{ node: { id: "orphan", status: "NEW", name: createdName } }]),
188
+ {
189
+ node: {
190
+ id: "someone-else",
191
+ status: "IN_PROGRESS",
192
+ name: "T3 Code · Expo Simulators · 000000",
193
+ },
194
+ },
195
+ ...(options.active ?? []).map((node) => ({ node })),
196
+ ...(options.activeIncludesCreated && created > 0
197
+ ? [
198
+ {
199
+ node: {
200
+ id: `session-${created}`,
201
+ status: "STARTING",
202
+ name: createdName,
203
+ },
204
+ },
205
+ ]
206
+ : []),
207
+ ],
208
+ },
209
},
210
},
160
- },
161
- }
162
- : operation === "T3CreateEasSimulatorSession"
163
- ? { deviceRunSession: { createDeviceRunSession: { id: `session-${++created}` } } }
164
- : operation === "T3ActiveEasSimulatorSessions"
211
+ }
212
+ : operation === "T3EasSimulatorSession"
213
? {
166
- app: {
214
+ deviceRunSessions: {
215
byId: {
168
- deviceRunSessionsPaginated: {
169
- edges: [
170
- ...(options.omitCreatedFromActive
171
- ? []
172
- : [{ node: { id: "orphan", status: "NEW", name: createdName } }]),
173
- {
174
- node: {
175
- id: "someone-else",
176
- status: "IN_PROGRESS",
177
- name: "T3 Code · Expo Simulators · 000000",
178
- },
179
- },
180
- ...(options.active ?? []).map((node) => ({ node })),
181
- ...(options.activeIncludesCreated && created > 0
182
- ? [
183
- {
184
- node: {
185
- id: `session-${created}`,
186
- status: "STARTING",
187
- name: createdName,
188
- },
189
- },
190
- ]
191
- : []),
192
- ],
216
+ id: body.variables.id,
217
+ status: options.status?.() ?? "IN_PROGRESS",
218
+ remoteConfig: {
219
+ __typename: "AgentDeviceRunSessionRemoteConfig",
220
+ agentDeviceRemoteSessionUrl: "https://agent.test",
221
+ agentDeviceRemoteSessionToken: "agent-token",
222
+ webPreviewToken: "preview-token",
223
+ previewApiUrl: "https://preview.test?token=preview-token",
224
},
225
},
226
},
227
}
197
- : operation === "T3EasSimulatorSession"
198
- ? {
199
- deviceRunSessions: {
200
- byId: {
201
- id: body.variables.id,
202
- status: options.status?.() ?? "IN_PROGRESS",
203
- remoteConfig: {
204
- __typename: "AgentDeviceRunSessionRemoteConfig",
205
- agentDeviceRemoteSessionUrl: "https://agent.test",
206
- agentDeviceRemoteSessionToken: "agent-token",
207
- webPreviewToken: "preview-token",
208
- previewApiUrl: "https://preview.test?token=preview-token",
209
- },
210
- },
211
- },
212
- }
213
- : {
214
- deviceRunSession: {
215
- ensureDeviceRunSessionStopped: { id: body.variables.id, status: "STOPPED" },
216
- },
217
- };
228
+ : {
229
+ deviceRunSession: {
230
+ ensureDeviceRunSessionStopped: { id: body.variables.id, status: "STOPPED" },
231
+ },
232
+ };
233
return HttpClientResponse.fromWeb(request, Response.json({ data }));
234
}),
235
);
@@ -535,6 +550,17 @@ describe("Expo Simulators host", () => {
550
}).pipe(Effect.scoped, Effect.provide(layer)),
551
);
552
553
+ it.effect("leaves admission to Expo's create although the account's gate is off", () =>
554
+ Effect.gen(function* () {
555
+ const expo = fakeExpo();
556
+ const host = yield* makeHost(expo, config(), yield* Scope.make());
557
+ const ready = yield* host.ensureReady(() => Effect.void);
558
+ const [catalogDevice] = (yield* ready.devices.list).devices;
559
+ expect(yield* ready.devices.boot(catalogDevice!)).toBe("session-1");
560
+ expect(expo.named("T3CreateEasSimulatorSession")).toHaveLength(1);
561
+ }).pipe(Effect.scoped, Effect.provide(layer)),
562
+ );
563
+
564
it.effect("stops the session a refused create made anyway", () =>
565
Effect.gen(function* () {
566
// Expo refuses the create but lists a session by its name.
@@ -543,7 +569,9 @@ describe("Expo Simulators host", () => {
569
const ready = yield* host.ensureReady(() => Effect.void);
570
const [catalogDevice] = (yield* ready.devices.list).devices;
571
const failure = yield* ready.devices.boot(catalogDevice!).pipe(Effect.flip);
546
- expect(failure.message).toContain("Not allowed");
572
+ expect(failure.message).toBe(
573
+ "Expo Simulators is unavailable: Expo could not start a simulator session: Device run sessions are not enabled for this account.",
574
+ );
575
expect(expo.stopped()).toEqual(["orphan"]);
576
}).pipe(Effect.scoped, Effect.provide(layer)),
577
);
apps/server/src/device/EasDeviceHost.ts
-8
@@ -509,14 +509,6 @@ export const make = Effect.fn("EasDeviceHost.make")(function* (config: EasDevice
509
"No Expo project to run the session under. Choose one for this host in Settings, or open the device from a thread whose project names extra.eas.projectId in app.json or its app config.",
510
);
511
}
512
- const access = yield* expo
513
- .availability(appId)
514
- .pipe(Effect.mapError((error) => unavailable(error.message, error)));
515
- if (!access.available) {
516
- return yield* unavailable(
517
- `Expo Simulators is not enabled for the ${access.account} Expo account.`,
518
- );
519
- }
512
const entry = { name, appId, recordedAt: yield* Clock.currentTimeMillis };
513
// Recorded first: a session the ledger cannot hold is never started.
514
yield* writeLedger((entries) => [...entries, entry]);
apps/server/src/device/ExpoApi.graphql
-11
@@ -21,17 +21,6 @@ query T3ExpoViewer {
21
}
22
}
23
24
-query T3EasSimulatorAvailability($appId: String!, $filter: [String!]) {
25
- app {
26
- byId(appId: $appId) {
27
- ownerAccount {
28
- name
29
- accountFeatureGates(filter: $filter)
30
- }
31
- }
32
- }
33
-}
34
-
24
mutation T3CreateEasSimulatorSession($input: CreateDeviceRunSessionInput!) {
25
deviceRunSession {
26
createDeviceRunSession(deviceRunSessionInput: $input) {
apps/server/src/device/ExpoApi.graphql.ts
+13
-61
@@ -24,18 +24,18 @@ export interface AccountAppsConnection extends Schema.Struct.Type<typeof Account
24
* An account is a container owning projects, credentials, billing and other organization
25
* data and settings. Actors may own and be members of accounts.
26
*/
27
-export const AccountsAccount = Schema.Struct({
27
+export const Account = Schema.Struct({
28
name: Schema.String,
29
/** Paginated list of apps associated with this account. By default sorted by name. Use filter to adjust the sorting order. */
30
appsPaginated: AccountAppsConnection
31
})
32
-export interface AccountsAccount extends Schema.Struct.Type<typeof AccountsAccount.fields> {}
32
+export interface Account extends Schema.Struct.Type<typeof Account.fields> {}
33
34
/** Represents a human SSO (not robot) actor. */
35
export const SSOUser = Schema.Struct({
36
__typename: Schema.Literal("SSOUser"),
37
username: Schema.String,
38
- accounts: Schema.Array(AccountsAccount)
38
+ accounts: Schema.Array(Account)
39
})
40
export interface SSOUser extends Schema.Struct.Type<typeof SSOUser.fields> {}
41
@@ -43,7 +43,7 @@ export interface SSOUser extends Schema.Struct.Type<typeof SSOUser.fields> {}
43
export const User = Schema.Struct({
44
__typename: Schema.Literal("User"),
45
username: Schema.String,
46
- accounts: Schema.Array(AccountsAccount)
46
+ accounts: Schema.Array(Account)
47
})
48
export interface User extends Schema.Struct.Type<typeof User.fields> {}
49
@@ -52,7 +52,7 @@ export const Robot = Schema.Struct({
52
__typename: Schema.Literal("Robot"),
53
firstName: Schema.NullOr(Schema.String),
54
/** Associated accounts */
55
- accounts: Schema.Array(AccountsAccount)
55
+ accounts: Schema.Array(Account)
56
})
57
export interface Robot extends Schema.Struct.Type<typeof Robot.fields> {}
58
@@ -60,7 +60,7 @@ export interface Robot extends Schema.Struct.Type<typeof Robot.fields> {}
60
export const ActorOther = Schema.Struct({
61
__typename: GraphQL.otherTypename<Shared.Typename.Actor>()(["SSOUser", "User", "Robot"]),
62
/** Associated accounts */
63
- accounts: Schema.Array(AccountsAccount)
63
+ accounts: Schema.Array(Account)
64
})
65
export interface ActorOther extends Schema.Struct.Type<typeof ActorOther.fields> {}
66
@@ -91,54 +91,6 @@ export declare namespace T3ExpoViewer {
91
export type Result = typeof T3ExpoViewer.result.Type
92
}
93
94
-/**
95
- * An account is a container owning projects, credentials, billing and other organization
96
- * data and settings. Actors may own and be members of accounts.
97
- */
98
-export const OwnerAccountAccount = Schema.Struct({
99
- name: Schema.String,
100
- /** Server account feature gate values for this account, optionally filtering by desired gates. */
101
- accountFeatureGates: Shared.JSONObject
102
-})
103
-export interface OwnerAccountAccount extends Schema.Struct.Type<typeof OwnerAccountAccount.fields> {}
104
-
105
-/** Represents an Exponent App (or Experience in legacy terms) */
106
-export const T3EasSimulatorAvailabilityAppByIdApp = Schema.Struct({
107
- ownerAccount: OwnerAccountAccount
108
-})
109
-export interface T3EasSimulatorAvailabilityAppByIdApp extends Schema.Struct.Type<typeof T3EasSimulatorAvailabilityAppByIdApp.fields> {}
110
-
111
-export const T3EasSimulatorAvailabilityAppAppQuery = Schema.Struct({
112
- /** Look up app by app id */
113
- byId: T3EasSimulatorAvailabilityAppByIdApp
114
-})
115
-export interface T3EasSimulatorAvailabilityAppAppQuery extends Schema.Struct.Type<typeof T3EasSimulatorAvailabilityAppAppQuery.fields> {}
116
-
117
-/** `query T3EasSimulatorAvailability` */
118
-export const T3EasSimulatorAvailability = GraphQL.query("T3EasSimulatorAvailability", {
119
- document: {
120
- variables: [
121
- { name: "appId", body: "String!" },
122
- { name: "filter", body: "[String!]" }
123
- ],
124
- selections: [
125
- { name: "app", body: ["{byId(appId:$", "appId", "){ownerAccount{name accountFeatureGates(filter:$", "filter", ")}}}"] }
126
- ],
127
- fragments: []
128
- },
129
- variables: {
130
- appId: Schema.String,
131
- filter: Schema.optional(Schema.NullOr(Schema.Array(Schema.String)))
132
- },
133
- result: Schema.Struct({
134
- app: T3EasSimulatorAvailabilityAppAppQuery
135
- })
136
-})
137
-export declare namespace T3EasSimulatorAvailability {
138
- export type Variables = typeof T3EasSimulatorAvailability.variables.Type
139
- export type Result = typeof T3EasSimulatorAvailability.result.Type
140
-}
141
-
94
export const CreateDeviceRunSessionDeviceRunSession = Schema.Struct({
95
id: Shared.ID
96
})
@@ -250,16 +202,16 @@ export const AppDeviceRunSessionsConnection = Schema.Struct({
202
export interface AppDeviceRunSessionsConnection extends Schema.Struct.Type<typeof AppDeviceRunSessionsConnection.fields> {}
203
204
/** Represents an Exponent App (or Experience in legacy terms) */
253
-export const T3ActiveEasSimulatorSessionsAppByIdApp = Schema.Struct({
205
+export const ByIdApp = Schema.Struct({
206
deviceRunSessionsPaginated: AppDeviceRunSessionsConnection
207
})
256
-export interface T3ActiveEasSimulatorSessionsAppByIdApp extends Schema.Struct.Type<typeof T3ActiveEasSimulatorSessionsAppByIdApp.fields> {}
208
+export interface ByIdApp extends Schema.Struct.Type<typeof ByIdApp.fields> {}
209
258
-export const T3ActiveEasSimulatorSessionsAppAppQuery = Schema.Struct({
210
+export const AppQuery = Schema.Struct({
211
/** Look up app by app id */
260
- byId: T3ActiveEasSimulatorSessionsAppByIdApp
212
+ byId: ByIdApp
213
})
262
-export interface T3ActiveEasSimulatorSessionsAppAppQuery extends Schema.Struct.Type<typeof T3ActiveEasSimulatorSessionsAppAppQuery.fields> {}
214
+export interface AppQuery extends Schema.Struct.Type<typeof AppQuery.fields> {}
215
216
/** `query T3ActiveEasSimulatorSessions` */
217
export const T3ActiveEasSimulatorSessions = GraphQL.query("T3ActiveEasSimulatorSessions", {
@@ -278,7 +230,7 @@ export const T3ActiveEasSimulatorSessions = GraphQL.query("T3ActiveEasSimulatorS
230
filter: Schema.optional(Schema.NullOr(Shared.DeviceRunSessionFilterInput))
231
},
232
result: Schema.Struct({
281
- app: T3ActiveEasSimulatorSessionsAppAppQuery
233
+ app: AppQuery
234
})
235
})
236
export declare namespace T3ActiveEasSimulatorSessions {
@@ -327,4 +279,4 @@ export declare namespace T3StopEasSimulatorSession {
279
}
280
281
/** Every operation in ExpoApi.graphql. */
330
-export const ExpoApiGraphQLGroup = GraphQLGroup.make(T3ExpoViewer, T3EasSimulatorAvailability, T3CreateEasSimulatorSession, T3EasSimulatorSession, T3ActiveEasSimulatorSessions, T3StopEasSimulatorSession)
282
+export const ExpoApiGraphQLGroup = GraphQLGroup.make(T3ExpoViewer, T3CreateEasSimulatorSession, T3EasSimulatorSession, T3ActiveEasSimulatorSessions, T3StopEasSimulatorSession)
apps/server/src/device/ExpoApi.test.ts
+2
-4
@@ -151,11 +151,9 @@ describe("Expo API", () => {
151
respond(Response.json({ errors: [{ message: "Feature not enabled" }] })),
152
credential,
153
)
154
- .availability("app-1")
154
+ .stop("session-1")
155
.pipe(Effect.flip);
156
- expect(graphQl.message).toBe(
157
- "Expo could not check Expo Simulators access: Feature not enabled",
158
- );
156
+ expect(graphQl.message).toBe("Expo could not stop a simulator session: Feature not enabled");
157
const rejected = yield* makeExpoApi(respond(new Response("no", { status: 401 })), credential)
158
.stop("session-1")
159
.pipe(Effect.flip);
apps/server/src/device/ExpoApi.ts
-15
@@ -152,9 +152,6 @@ export interface CreateEasSessionInput {
152
readonly maxIdleTimeMinutes: number;
153
}
154
155
-const DEVICE_RUN_SESSIONS_GATE = "device-run-sessions";
156
-const isFeatureGates = Schema.is(Schema.Record(Schema.String, Schema.Unknown));
157
-
155
/** Sends every operation with the resolved credential. */
156
class ExpoAuth extends GraphQLMiddleware.Service<ExpoAuth>()("t3/server/device/ExpoApi/ExpoAuth") {}
157
@@ -312,18 +309,6 @@ export const makeExpoApi = (http: HttpClient.HttpClient, credential: ExpoCredent
309
}),
310
),
311
),
315
- availability: (appId: string) =>
316
- call("check Expo Simulators access", (expo) =>
317
- expo.T3EasSimulatorAvailability({ appId, filter: [DEVICE_RUN_SESSIONS_GATE] }),
318
- ).pipe(
319
- Effect.map(({ app }) => {
320
- const gates = app.byId.ownerAccount.accountFeatureGates;
321
- return {
322
- account: app.byId.ownerAccount.name,
323
- available: isFeatureGates(gates) && gates[DEVICE_RUN_SESSIONS_GATE] === true,
324
- };
325
- }),
326
- ),
312
create: (input: CreateEasSessionInput) =>
313
call("start a simulator session", (expo) =>
314
expo.T3CreateEasSimulatorSession({