The best way to control Claude Code, Codex and more from any computer or phone
fix(client): guard saved environment routes during SSH onboarding (#37818)
Julius Marminge committed
Nov 16, 2026 at 16:38 UTC
d6a28f4faaf99bdb5e75c2ea4874afe8da6b3f52
2 files changed
+46
-2
packages/client-runtime/src/connection/onboarding.test.ts
+43
-1
@@ -162,6 +162,7 @@ function layerPairingHttp(
162
function layerPairingOnboarding(
163
options?: Parameters<typeof layerPairingHttp>[1],
164
calls: Array<{ readonly url: string; readonly init: RequestInit }> = [],
165
+ provision?: ClientCapabilities.SshEnvironmentGateway["Service"]["provision"],
166
) {
167
const dependencies = Layer.mergeAll(
168
layerClientPresentation,
@@ -180,7 +181,7 @@ function layerPairingOnboarding(
181
get: () => Effect.succeedNone,
182
put: () => Effect.void,
183
}),
183
- Layer.mock(ClientCapabilities.SshEnvironmentGateway)({}),
184
+ Layer.mock(ClientCapabilities.SshEnvironmentGateway)(provision ? { provision } : {}),
185
Layer.succeed(
186
Connectivity.Connectivity,
187
Connectivity.Connectivity.of({ status: Effect.succeed("online"), changes: Stream.never }),
@@ -324,6 +325,47 @@ describe("connection onboarding", () => {
325
}).pipe(Effect.provide(layerPairingOnboarding(undefined, calls)));
326
});
327
328
+ it.effect(
329
+ "refuses to add an SSH route to a saved environment during untargeted onboarding",
330
+ () => {
331
+ const target = {
332
+ alias: "devbox",
333
+ hostname: "devbox.example.test",
334
+ username: "developer",
335
+ port: 22,
336
+ };
337
+ return Effect.gen(function* () {
338
+ const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
339
+ const onboarding = yield* Onboarding.ConnectionOnboarding;
340
+ const before = yield* registerSwitchedOffEnvironment;
341
+
342
+ const result = yield* onboarding.registerSsh({ target }).pipe(Effect.result);
343
+
344
+ expect(result).toMatchObject({
345
+ _tag: "Failure",
346
+ failure: { _tag: "ConnectionBlockedError", reason: "configuration" },
347
+ });
348
+ expect(yield* SubscriptionRef.get(registry.entries)).toEqual(before);
349
+ }).pipe(
350
+ Effect.provide(
351
+ layerPairingOnboarding(undefined, [], () =>
352
+ Effect.succeed({
353
+ environmentId: PAIRED_ENVIRONMENT_ID,
354
+ label: "Remote development box",
355
+ bootstrap: {
356
+ target,
357
+ httpBaseUrl: "http://127.0.0.1:3201",
358
+ wsBaseUrl: "ws://127.0.0.1:3201",
359
+ pairingToken: "pairing-token",
360
+ },
361
+ bearerToken: "bearer-token",
362
+ }),
363
+ ),
364
+ ),
365
+ );
366
+ },
367
+ );
368
+
369
it.effect("refuses a new address when the environment is saved during the exchange", () => {
370
let reached!: () => void;
371
let release!: () => void;
packages/client-runtime/src/connection/onboarding.ts
+3
-1
@@ -293,7 +293,9 @@ const registerSshConnection = Effect.fn(
293
return yield* differentMachineError(registration.target.label);
294
}
295
const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
296
- yield* registry.register(registration);
296
+ yield* registry.register(registration, {
297
+ knownAddressOnly: input.expectedEnvironmentId === undefined,
298
+ });
299
return registration.target.environmentId;
300
});
301