@devries-cameron20 / t3code Mirror · read-only / commits / 895354e9fb
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, 13:00 UTC

fix(server): Antigravity installs on Windows ARM (#18472)

Max Weinbach committed Oct 15, 2026 at 13:39 UTC 895354e9fbf5be90cda4fdcd710dac96496181c4
2 files changed +174 -40
apps/server/src/provider/AntigravityInstallation.test.ts
+140 -36
@@ -16,6 +16,7 @@ import * as Schema from "effect/Schema";
16 import * as Scope from "effect/Scope";
17 import * as Sink from "effect/Sink";
18 import * as Stream from "effect/Stream";
19 +import * as TestClock from "effect/testing/TestClock";
20 import { HttpClient, HttpClientResponse } from "effect/http";
21 import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
22
@@ -127,6 +128,7 @@ interface HarnessOptions {
128 readonly contentLength?: number;
129 readonly contentEncoding?: string;
130 readonly platform?: NodeJS.Platform;
131 + readonly arch?: NodeJS.Architecture;
132 readonly path?: string;
133 readonly previous?: boolean;
134 readonly fileSystem?: FileSystem.FileSystem;
@@ -142,10 +144,11 @@ const makeHarness = Effect.fn("test.makeAntigravityInstallation")(function* (
144 const baseDir =
145 options.baseDir ?? (yield* fs.makeTempDirectoryScoped({ prefix: "t3-agy-test-" }));
146 const platform = options.platform ?? hostPlatform;
147 + const arch = options.arch ?? "x64";
148 const archive = options.archive ?? completeArchive;
149 const asset =
150 options.asset === undefined ? yield* releaseAsset(archive, platform) : options.asset;
148 - const managedDirectory = path.join(baseDir, "tools", "antigravity-acp", `${platform}-x64`);
151 + const managedDirectory = path.join(baseDir, "tools", "antigravity-acp", `${platform}-${arch}`);
152 if (options.previous) {
153 yield* writeRelease(managedDirectory, {
154 ...(yield* releaseAsset(archive, platform)),
@@ -185,7 +188,7 @@ const makeHarness = Effect.fn("test.makeAntigravityInstallation")(function* (
188 }).pipe(
189 Effect.provideService(FileSystem.FileSystem, trackedFs),
190 Effect.provideService(HostProcess.Platform, platform),
188 - Effect.provideService(HostProcess.Architecture, "x64"),
191 + Effect.provideService(HostProcess.Architecture, arch),
192 Effect.provideService(HostProcess.Environment, { PATH: options.path ?? "" }),
193 Effect.provideService(
194 HttpClient.HttpClient,
@@ -305,38 +308,76 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => {
308 }),
309 );
310
308 - it.effect.each([
309 - {
310 - name: "the expected release with protocol 1",
311 - protocolVersion: 1,
312 - agentName: "antigravity-acp",
313 - version: "fixture-new",
314 - valid: true,
315 - },
316 - {
317 - name: "the expected release with protocol 2 and legacy fields",
318 - protocolVersion: 2,
319 - agentName: "antigravity-acp",
320 - version: "fixture-new",
321 - valid: true,
322 - },
323 - {
324 - name: "an unsupported protocol version",
325 - protocolVersion: 3,
326 - agentName: "antigravity-acp",
327 - version: "fixture-new",
328 - valid: false,
329 - },
330 - { name: "a different agent", agentName: "other-agent", version: "fixture-new", valid: false },
331 - {
332 - name: "a different version",
333 - agentName: "antigravity-acp",
334 - version: "other-version",
335 - valid: false,
336 - },
337 - ])("validates $name with initialize only and removes the disposable profile", (testCase) =>
311 + it.effect.each(
312 + [
313 + {
314 + name: "the expected release with protocol 1",
315 + protocolVersion: 1,
316 + agentName: "antigravity-acp",
317 + version: "fixture-new",
318 + valid: true,
319 + },
320 + {
321 + name: "the expected release with protocol 2 and legacy fields",
322 + protocolVersion: 2,
323 + agentName: "antigravity-acp",
324 + version: "fixture-new",
325 + valid: true,
326 + },
327 + {
328 + name: "an unsupported protocol version",
329 + protocolVersion: 3,
330 + agentName: "antigravity-acp",
331 + version: "fixture-new",
332 + valid: false,
333 + },
334 + { name: "a different agent", agentName: "other-agent", version: "fixture-new", valid: false },
335 + {
336 + name: "a different version",
337 + agentName: "antigravity-acp",
338 + version: "other-version",
339 + valid: false,
340 + },
341 + {
342 + name: "the Windows ARM release with locked child processes",
343 + platform: "win32" as const,
344 + arch: "arm64" as const,
345 + agentName: "antigravity-acp",
346 + version: "fixture-new",
347 + valid: true,
348 + },
349 + {
350 + name: "an invalid Windows ARM release with locked child processes",
351 + platform: "win32" as const,
352 + arch: "arm64" as const,
353 + agentName: "antigravity-acp",
354 + version: "other-version",
355 + valid: false,
356 + },
357 + {
358 + name: "a cancelled Windows ARM verification with locked child processes",
359 + platform: "win32" as const,
360 + arch: "arm64" as const,
361 + agentName: "antigravity-acp",
362 + version: "fixture-new",
363 + cancel: true,
364 + valid: false,
365 + },
366 + ].flatMap((testCase) => {
367 + const cleanupErrorTags =
368 + testCase.platform === "win32"
369 + ? (["Unknown", "PermissionDenied", "Busy"] as const)
370 + : (["Unknown"] as const);
371 + return cleanupErrorTags.map((cleanupErrorTag) => ({
372 + ...testCase,
373 + cleanupErrorTag,
374 + name: `${cleanupErrorTag}: ${testCase.name}`,
375 + }));
376 + }),
377 + )("validates $name with initialize only and removes the disposable profile", (testCase) =>
378 Effect.gen(function* () {
379 const fs = yield* FileSystem.FileSystem;
380 + const platform = testCase.platform ?? hostPlatform;
381 const encoder = new TextEncoder();
382 const decodeRequest = Schema.decodeUnknownEffect(
383 Schema.fromJsonString(
@@ -348,6 +389,10 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => {
389 );
390 const methods: string[] = [];
391 const profiles = new Set<string>();
392 + const cleanupRetryStarted = yield* Deferred.make<void>();
393 + const initializationStarted = yield* Deferred.make<void>();
394 + let childProcessesRunning = false;
395 + let profileRemovalAttempts = 0;
396 let closedRuntimes = 0;
397 const spawner = ChildProcessSpawner.make(
398 Effect.fn("test.spawnAntigravityValidator")(function* (command) {
@@ -358,8 +403,16 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => {
403 if (!profile) return yield* Effect.die("Expected a disposable validation profile.");
404 profiles.add(profile);
405 const helper = command.args[0] === "-e";
406 + if (!helper) childProcessesRunning = true;
407 // The runtime unpacks straight into the disposable profile.
362 - if (!helper) expect(command.options.env?.TMPDIR).toBe(profile);
408 + if (!helper) {
409 + if (platform === "win32") {
410 + expect(command.options.env?.TEMP).toBe(profile);
411 + expect(command.options.env?.TMP).toBe(profile);
412 + } else {
413 + expect(command.options.env?.TMPDIR).toBe(profile);
414 + }
415 + }
416 const output = yield* Queue.unbounded<Uint8Array>();
417 const exited = yield* Deferred.make<ChildProcessSpawner.ExitCode>();
418 const terminate = Deferred.succeed(exited, ChildProcessSpawner.ExitCode(0)).pipe(
@@ -381,7 +434,10 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => {
434 ? Effect.succeed(ChildProcessSpawner.ExitCode(0))
435 : Deferred.await(exited),
436 isRunning: Deferred.isDone(exited).pipe(Effect.map((done) => !done)),
384 - kill: () => terminate,
437 + kill: () =>
438 + Effect.sync(() => {
439 + if (!helper) childProcessesRunning = false;
440 + }).pipe(Effect.andThen(terminate)),
441 unref: Effect.succeed(Effect.void),
442 stdin: Sink.forEach((bytes: Uint8Array) =>
443 Effect.gen(function* () {
@@ -389,6 +445,10 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => {
445 Effect.orDie,
446 );
447 methods.push(request.method);
448 + if (testCase.cancel) {
449 + yield* Deferred.succeed(initializationStarted, undefined);
450 + return;
451 + }
452 yield* Queue.offer(
453 output,
454 encoder.encode(
@@ -431,15 +491,59 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => {
491 const { installation, stagingReleased } = yield* makeHarness({
492 previous: true,
493 useDefaultValidation: true,
494 + platform,
495 + ...(testCase.arch ? { arch: testCase.arch } : {}),
496 + archive:
497 + platform === "win32" ? Buffer.from(zipFixtures.windows, "base64") : completeArchive,
498 + fileSystem: FileSystem.FileSystem.of({
499 + ...fs,
500 + remove: (target, options) =>
501 + Effect.suspend(() => {
502 + if (platform === "win32" && profiles.has(target)) {
503 + profileRemovalAttempts += 1;
504 + expect(childProcessesRunning).toBe(false);
505 + // Even after the tree exits, Windows can briefly retain a DLL handle.
506 + if (profileRemovalAttempts === 1) {
507 + return Deferred.succeed(cleanupRetryStarted, undefined).pipe(
508 + Effect.andThen(
509 + Effect.fail(
510 + PlatformError.systemError({
511 + _tag: testCase.cleanupErrorTag,
512 + module: "FileSystem",
513 + method: "remove",
514 + description: "Unpacked DLL is in use",
515 + }),
516 + ),
517 + ),
518 + );
519 + }
520 + }
521 + return fs.remove(target, options);
522 + }),
523 + }),
524 }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner));
435 - yield* installation.start;
525 + const started = yield* installation.start;
526 + const cancellation = testCase.cancel
527 + ? yield* Deferred.await(initializationStarted).pipe(
528 + Effect.andThen(installation.cancel(started.operationId!)),
529 + Effect.forkChild,
530 + )
531 + : undefined;
532 + if (platform === "win32") {
533 + yield* Effect.raceFirst(
534 + Deferred.await(cleanupRetryStarted).pipe(Effect.andThen(TestClock.adjust("100 millis"))),
535 + terminalState(installation),
536 + );
537 + }
538 + if (cancellation) yield* Fiber.join(cancellation);
539 expect((yield* terminalState(installation)).phase).toBe(
437 - testCase.valid ? "succeeded" : "failed",
540 + testCase.cancel ? "cancelled" : testCase.valid ? "succeeded" : "failed",
541 );
542 yield* Deferred.await(stagingReleased);
543 expect(methods).toEqual(["initialize"]);
544 expect(closedRuntimes).toBe(1);
545 expect(profiles.size).toBe(1);
546 + if (platform === "win32") expect(profileRemovalAttempts).toBe(2);
547 for (const profile of profiles) {
548 expect(yield* fs.exists(profile)).toBe(false);
549 }
apps/server/src/provider/AntigravityInstallation.ts
+34 -4
@@ -15,6 +15,7 @@ import * as Layer from "effect/Layer";
15 import * as Option from "effect/Option";
16 import * as Path from "effect/Path";
17 import * as Schema from "effect/Schema";
18 +import * as Schedule from "effect/Schedule";
19 import * as Scope from "effect/Scope";
20 import * as Semaphore from "effect/Semaphore";
21 import * as Stream from "effect/Stream";
@@ -349,9 +350,23 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
350 options.validate ??
351 Effect.fn("AntigravityInstallation.validate")(
352 function* (executable: AntigravityExecutable, expectedVersion: string) {
352 - const profileDirectory = yield* fs.makeTempDirectoryScoped({
353 - prefix: "t3-antigravity-validate-",
354 - });
353 + const validationScope = yield* Effect.scope;
354 + const profileDirectory = yield* Effect.acquireRelease(
355 + fs.makeTempDirectory({ prefix: "t3-antigravity-validate-" }),
356 + (directory) =>
357 + fs.remove(directory, { recursive: true, force: true }).pipe(
358 + // Windows may retain DLL handles briefly after taskkill returns.
359 + Effect.retry({
360 + times: platform === "win32" ? 10 : 0,
361 + schedule: Schedule.spaced("100 millis"),
362 + while: (error) =>
363 + error.reason._tag === "PermissionDenied" ||
364 + error.reason._tag === "Busy" ||
365 + error.reason._tag === "Unknown",
366 + }),
367 + Effect.orDie,
368 + ),
369 + );
370 const profile = yield* prepareAntigravityProfile({
371 profileDirectory,
372 platform,
@@ -368,7 +383,22 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
383 baseEnv: environment,
384 }),
385 cwd: profileDirectory,
371 - childProcessSpawner: spawner,
386 + childProcessSpawner:
387 + platform === "win32"
388 + ? ChildProcessSpawner.make(
389 + Effect.fnUntraced(function* (command) {
390 + const child = yield* spawner.spawn(command);
391 + // Stop PyInstaller's tree before ACP closes its pipes. Once
392 + // the launcher exits, taskkill cannot reach its children,
393 + // which keep the executable and unpacked DLLs locked.
394 + yield* Scope.addFinalizer(
395 + validationScope,
396 + child.kill({ forceKillAfter: "1 second" }).pipe(Effect.orDie),
397 + );
398 + return child;
399 + }),
400 + )
401 + : spawner,
402 clientInfo: { name: "t3-code", version: "0.0.0" },
403 });
404 const initialized = yield* runtime.initialize();