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 22, 18:15 UTC
fix(web): SSH environments on an older reused remote server explain the version mismatch instead of reconnecting forever (#23647)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 23, 2026 at 20:16 UTC
79e392cbfba99bd2538471c4876d786aae2acd95
3 files changed
+53
-1
apps/desktop/src/ipc/methods/sshEnvironment.ts
+1
@@ -83,6 +83,7 @@ export class DesktopSshEnvironmentRequestError extends Data.TaggedError(
83
readonly cause: DesktopSshEnvironmentRequestCause;
84
readonly sshHttpStatus: number | null;
85
}> {
86
+ // The web client matches "[ssh_http:500]" to explain version-skewed SSH pairing.
87
override get message() {
88
const prefix = this.sshHttpStatus === null ? "" : `[ssh_http:${this.sshHttpStatus}] `;
89
return `${prefix}SSH remote API request failed during ${this.operation}.`;
apps/web/src/connection/platform.test.ts
+36
@@ -28,6 +28,7 @@ import {
28
provisionDesktopSshEnvironment,
29
secondaryRegistrationsToRetainAfterTopologyRead,
30
} from "./platform.ts";
31
+import { APP_VERSION } from "../branding.ts";
32
33
const TARGET: DesktopSshEnvironmentTarget = {
34
alias: "devbox",
@@ -224,6 +225,41 @@ describe("desktop SSH pairing", () => {
225
}),
226
);
227
228
+ const failPairing = (serverVersion: string, message: string) => {
229
+ const bridge = makeBridge([]);
230
+ const fetchDescriptor = bridge.fetchSshEnvironmentDescriptor;
231
+ vi.spyOn(bridge, "fetchSshEnvironmentDescriptor").mockImplementation(async (url) => ({
232
+ ...(await fetchDescriptor(url)),
233
+ serverVersion,
234
+ }));
235
+ vi.spyOn(bridge, "bootstrapSshBearerSession").mockRejectedValue(new Error(message));
236
+ return provisionDesktopSshEnvironment(bridge, TARGET).pipe(Effect.flip);
237
+ };
238
+ const PAIRING_500 =
239
+ "[ssh_http:500] SSH remote API request failed during bootstrap-bearer-session.";
240
+
241
+ it.effect("blocks with both versions when a server on another build rejects pairing", () =>
242
+ Effect.gen(function* () {
243
+ const error = yield* failPairing("0.0.46-nightly.20261004.2652", PAIRING_500);
244
+
245
+ expect(error).toBeInstanceOf(ConnectionBlockedError);
246
+ expect(error.detail).toContain("0.0.46-nightly.20261004.2652");
247
+ expect(error.detail).toContain(APP_VERSION);
248
+ }),
249
+ );
250
+
251
+ it.effect("keeps retrying pairing failures that are not a version mismatch", () =>
252
+ Effect.gen(function* () {
253
+ expect(yield* failPairing(APP_VERSION, PAIRING_500)).toBeInstanceOf(ConnectionTransientError);
254
+ expect(
255
+ yield* failPairing(
256
+ "0.0.46-nightly.20261004.2652",
257
+ "SSH remote API request failed during bootstrap-bearer-session.",
258
+ ),
259
+ ).toBeInstanceOf(ConnectionTransientError);
260
+ }),
261
+ );
262
+
263
it.effect("reconnects with the saved token while it holds every standard scope", () =>
264
Effect.gen(function* () {
265
const calls: string[] = [];
apps/web/src/connection/platform.ts
+16
-1
@@ -238,7 +238,22 @@ export const provisionDesktopSshEnvironment = Effect.fn(
238
}
239
const access = yield* Effect.tryPromise({
240
try: () => bridge.bootstrapSshBearerSession(bootstrap.httpBaseUrl, pairingToken),
241
- catch: sshPreparationError,
241
+ catch: (cause) => {
242
+ const error = sshPreparationError(cause);
243
+ // A reused remote server on another build can fail to decode the grant
244
+ // the desktop's runner just minted, and answers 500 on every retry.
245
+ if (
246
+ error._tag === "ConnectionBlockedError" ||
247
+ descriptor.serverVersion === APP_VERSION ||
248
+ !error.detail.includes("[ssh_http:500]")
249
+ ) {
250
+ return error;
251
+ }
252
+ return new ConnectionBlockedError({
253
+ reason: "configuration",
254
+ detail: `${descriptor.label} runs T3 Code ${descriptor.serverVersion}, but this desktop is ${APP_VERSION}, and that server could not accept its pairing. Restart the T3 server on ${descriptor.label} so it runs ${APP_VERSION}, then retry.`,
255
+ });
256
+ },
257
});
258
return {
259
environmentId: descriptor.environmentId,