@devries-cameron20 / t3code Mirror · read-only / commits / 385851d7fe
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 22, 02:00 UTC

fix(server): allow slow Antigravity browser preflights (#25211)

Co-authored-by: Lars Nieuwenhuis <35393046+lnieuwenhuis@users.noreply.github.com>

maria committed Nov 8, 2026 at 21:57 UTC 385851d7fedc645d3ecf6363135c3c8c35c32b2d
2 files changed +93 -1
apps/server/src/provider/antigravityAuthSupport.test.ts
+92
@@ -1,3 +1,8 @@
1 +import * as Sink from "effect/Sink";
2 +import * as Deferred from "effect/Deferred";
3 +import * as Fiber from "effect/Fiber";
4 +import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
5 +import * as TestClock from "effect/testing/TestClock";
6 import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
7 import * as NodePath from "@effect/platform-node/NodePath";
8 import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -671,6 +676,93 @@ it.layer(NodeServices.layer)("Antigravity profile preparation", (it) => {
676 }),
677 );
678
679 + const preflightHelper = (exitDelay: Effect.Effect<void>) => {
680 + const spawns = { count: 0 };
681 + const started = Deferred.makeUnsafe<void>();
682 + const spawner = ChildProcessSpawner.make(() =>
683 + Effect.sync(() => {
684 + spawns.count += 1;
685 + return ChildProcessSpawner.makeHandle({
686 + pid: ChildProcessSpawner.ProcessId(1),
687 + exitCode: Deferred.succeed(started, undefined).pipe(
688 + Effect.andThen(exitDelay),
689 + Effect.as(ChildProcessSpawner.ExitCode(0)),
690 + ),
691 + isRunning: Effect.succeed(false),
692 + kill: () => Effect.void,
693 + unref: Effect.succeed(Effect.void),
694 + stdin: Sink.drain,
695 + stdout: Stream.empty,
696 + stderr: Stream.encodeText(
697 + Stream.make(
698 + `${ANTIGRAVITY_AUTH_BROWSER_MARKER}"https://example.invalid/t3-antigravity-browser-preflight"\n`,
699 + ),
700 + ),
701 + all: Stream.empty,
702 + getInputFd: () => Sink.drain,
703 + getOutputFd: () => Stream.empty,
704 + });
705 + }),
706 + );
707 + return { spawner, spawns, started };
708 + };
709 +
710 + const prepareWithHelper = Effect.fn("prepareWithHelper")(function* (
711 + runtimeExecutablePath: string,
712 + spawner: ChildProcessSpawner.ChildProcessSpawner["Service"],
713 + ) {
714 + const fs = yield* FileSystem.FileSystem;
715 + const path = yield* Path.Path;
716 + const directory = yield* fs.makeTempDirectoryScoped();
717 + return yield* prepareAntigravityProfile({
718 + profileDirectory: path.join(directory, "profile"),
719 + userHome: path.join(directory, "home"),
720 + runtimeExecutablePath,
721 + platform: "linux",
722 + baseEnv: {},
723 + }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner));
724 + });
725 +
726 + it.effect("allows a browser preflight that takes longer than five seconds", () =>
727 + Effect.gen(function* () {
728 + const helper = preflightHelper(Effect.sleep("20 seconds"));
729 + const fiber = yield* prepareWithHelper("/fake/slow-node", helper.spawner).pipe(
730 + Effect.forkChild,
731 + );
732 + yield* Deferred.await(helper.started);
733 + yield* TestClock.adjust("20 seconds");
734 + yield* Fiber.join(fiber);
735 +
736 + expect(helper.spawns.count).toBe(1);
737 + }),
738 + );
739 +
740 + it.effect("fails a hung preflight after 30 seconds and verifies again on the next open", () =>
741 + Effect.gen(function* () {
742 + const hung = preflightHelper(Effect.never);
743 + const fiber = yield* prepareWithHelper("/fake/hung-node", hung.spawner).pipe(
744 + Effect.result,
745 + Effect.forkChild,
746 + );
747 + yield* Deferred.await(hung.started);
748 + yield* TestClock.adjust("29 seconds");
749 + expect(fiber.pollUnsafe()).toBeUndefined();
750 + yield* TestClock.adjust("1 second");
751 + const result = yield* Fiber.join(fiber);
752 + expect(Result.isFailure(result)).toBe(true);
753 + if (Result.isFailure(result)) {
754 + expect(result.failure).toMatchObject({
755 + _tag: "AcpTransportError",
756 + detail: "Antigravity browser suppression verification timed out.",
757 + });
758 + }
759 +
760 + const recovered = preflightHelper(Effect.void);
761 + yield* prepareWithHelper("/fake/hung-node", recovered.spawner);
762 + expect(recovered.spawns.count).toBe(1);
763 + }),
764 + );
765 +
766 it.effect("rejects Python BROWSER delimiter collisions before starting a helper", () =>
767 Effect.gen(function* () {
768 const fs = yield* FileSystem.FileSystem;
apps/server/src/provider/antigravityAuthSupport.ts
+1 -1
@@ -409,7 +409,7 @@ export const prepareAntigravityProfile = Effect.fn("prepareAntigravityProfile")(
409 }).pipe(
410 Effect.scoped,
411 Effect.timeoutOrElse({
412 - duration: "5 seconds",
412 + duration: "30 seconds",
413 orElse: () =>
414 Effect.fail(authSupportError("Antigravity browser suppression verification timed out.")),
415 }),