@devries-cameron20 / t3code Mirror · read-only / commits / 10db5e493f
Fork 0

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 23, 03:00 UTC

fix(client-runtime): Update clears the block on a host that is already compatible (#18563)

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Co-authored-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>

Pujitha Paladugu committed Oct 18, 2026 at 12:51 UTC 10db5e493f24962c651ee62e4f5729a7830d3e6f
2 files changed +97 -8
packages/client-runtime/src/connection/outdatedHostUpdate.test.ts
+78
@@ -204,6 +204,84 @@ describe("updateOutdatedHost", () => {
204 }),
205 );
206
207 + it.effect("switches a host that is already compatible back on without opening a socket", () =>
208 + Effect.gen(function* () {
209 + const calls: Array<string> = [];
210 + let opened = false;
211 + const prepared = {
212 + environmentId: TARGET.environmentId,
213 + label: TARGET.label,
214 + httpBaseUrl: TARGET.httpBaseUrl,
215 + socketUrl: "wss://build.example.test/ws",
216 + httpAuthorization: null,
217 + target: TARGET,
218 + };
219 + const result = yield* updateOutdatedHost(
220 + TARGET.environmentId,
221 + { targetVersion: "0.0.46" },
222 + () => Effect.void,
223 + ).pipe(
224 + Effect.provide(
225 + Layer.mergeAll(
226 + Layer.succeed(
227 + EnvironmentRegistry.EnvironmentRegistry,
228 + EnvironmentRegistry.EnvironmentRegistry.of({
229 + entries: yield* SubscriptionRef.make<
230 + ReadonlyMap<EnvironmentId, ConnectionCatalogEntry>
231 + >(
232 + new Map([
233 + [
234 + TARGET.environmentId,
235 + { target: TARGET, profile: Option.none(), enabled: false },
236 + ],
237 + ]),
238 + ),
239 + setCompatibility: (_environmentId: EnvironmentId, error: unknown) =>
240 + Effect.sync(() =>
241 + calls.push(`compatibility:${error === null ? "clear" : "block"}`),
242 + ),
243 + setEnabled: (_environmentId: EnvironmentId, enabled: boolean) =>
244 + Effect.sync(() => calls.push(`enabled:${enabled}`)),
245 + } as unknown as EnvironmentRegistry.EnvironmentRegistry["Service"]),
246 + ),
247 + Layer.succeed(
248 + ConnectionResolver.ConnectionResolver,
249 + ConnectionResolver.ConnectionResolver.of({
250 + prepare: () => Effect.die(new Error("unused")),
251 + prepareForUpdate: () =>
252 + Effect.succeed({
253 + descriptor: descriptor(ORCHESTRATION_PROTOCOL_VERSION, "0.0.46"),
254 + prepared,
255 + }),
256 + }),
257 + ),
258 + Layer.succeed(
259 + RelayEnvironmentDiscovery.RelayEnvironmentDiscovery,
260 + RelayEnvironmentDiscovery.RelayEnvironmentDiscovery.of({
261 + state: yield* SubscriptionRef.make(
262 + RelayEnvironmentDiscovery.EMPTY_RELAY_ENVIRONMENT_DISCOVERY_STATE,
263 + ),
264 + refresh: Effect.void,
265 + }),
266 + ),
267 + Layer.succeed(
268 + HttpClient.HttpClient,
269 + HttpClient.make(() => Effect.die(new Error("unused"))),
270 + ),
271 + // A v2 host answers a bare socket with 426, so opening one fails.
272 + Layer.succeed(Socket.WebSocketConstructor, () => {
273 + opened = true;
274 + throw new Error("unused");
275 + }),
276 + ),
277 + ),
278 + );
279 + expect(opened).toBe(false);
280 + expect(result.targetVersion).toBe("0.0.46");
281 + expect(calls).toEqual(["compatibility:clear", "enabled:true"]);
282 + }),
283 + );
284 +
285 it.effect("refuses a host that cannot update itself without opening a socket", () =>
286 Effect.gen(function* () {
287 const manual = {
packages/client-runtime/src/connection/outdatedHostUpdate.ts
+19 -8
@@ -70,6 +70,24 @@ export const updateOutdatedHost = Effect.fn("clientRuntime.connection.updateOutd
70 const { prepared, descriptor } = yield* Effect.firstSuccessOf(
71 usableRoutes(entry).map((route) => resolver.prepareForUpdate(routeEntry(entry, route))),
72 );
73 + // Discovery still holds the old relay descriptor and would re-block the
74 + // environment from it, so replace that before clearing the block.
75 + const switchBackOn = Effect.gen(function* () {
76 + if (hasRelayRoute(entry)) {
77 + const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery;
78 + yield* discovery.refresh;
79 + }
80 + yield* registry.setCompatibility(environmentId, null);
81 + yield* registry.setEnabled(environmentId, true);
82 + });
83 +
84 + // A host updated by hand is already compatible, and a bare socket would be
85 + // rejected with 426, so there is nothing to update.
86 + if (isCompatibleDescriptor(descriptor)) {
87 + yield* switchBackOn;
88 + return { targetVersion: descriptor.serverVersion };
89 + }
90 +
91 const capabilities = descriptor.capabilities;
92 if (
93 capabilities.serverSelfUpdate === undefined ||
@@ -192,14 +210,7 @@ export const updateOutdatedHost = Effect.fn("clientRuntime.connection.updateOutd
210 });
211 }
212
195 - // Discovery still holds the old relay descriptor and would re-block the
196 - // environment from it, so replace that before clearing the block.
197 - if (hasRelayRoute(entry)) {
198 - const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery;
199 - yield* discovery.refresh;
200 - }
201 - yield* registry.setCompatibility(environmentId, null);
202 - yield* registry.setEnabled(environmentId, true);
213 + yield* switchBackOn;
214 return { ...result, targetVersion: resumed.value.serverVersion };
215 },
216 );