Skip to content

Commit 22e016b

Browse files
t3dotggclaude
andcommitted
fix(antigravity): say when sign-in cannot reach Google
Sign-in sat on "Starting sign-in…" for up to five minutes when the agent could not reach Google, for example on a host with broken IPv6. After 30 seconds without a Google link, show a network hint. If the 5-minute limit passes before the link appears, say Antigravity could not reach Google instead of "sign-in expired". Web now shows the server message while sign-in starts, as mobile already does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 62eb35b commit 22e016b

3 files changed

Lines changed: 63 additions & 2 deletions

File tree

‎apps/server/src/provider/AntigravityAuth.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as Fiber from "effect/Fiber";
88
import * as Option from "effect/Option";
99
import * as Scope from "effect/Scope";
1010
import * as Stream from "effect/Stream";
11+
import * as TestClock from "effect/testing/TestClock";
1112
import * as AcpErrors from "effect-acp/errors";
1213
import type * as AcpSchema from "effect-acp/compat";
1314

@@ -62,6 +63,7 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
6263
const authenticated = yield* Deferred.make<void, AcpErrors.AcpError>();
6364
const discovered = yield* Deferred.make<void, AcpErrors.AcpError>();
6465
const closed = yield* Deferred.make<void>();
66+
const authenticateCalled = yield* Deferred.make<void>();
6567
const events: string[] = [];
6668
let receiveAuthorizationUrl:
6769
| ((url: string) => Effect.Effect<void, AcpErrors.AcpError>)
@@ -92,6 +94,7 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
9294
start: () =>
9395
Effect.gen(function* () {
9496
events.push("authenticate");
97+
yield* Deferred.succeed(authenticateCalled, undefined);
9598
if (options.interactive !== false && input.onAuthorizationUrl) {
9699
for (const url of options.authorizationUrls ?? [authorizationUrl]) {
97100
yield* input.onAuthorizationUrl(url);
@@ -129,6 +132,7 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
129132
authenticated,
130133
discovered,
131134
closed,
135+
authenticateCalled,
132136
events,
133137
catalog: () => catalog,
134138
forwarded: () => forwarded,
@@ -254,6 +258,38 @@ it.layer(NodeServices.layer)("AntigravityAuth", (it) => {
254258
}),
255259
);
256260

261+
it.effect("tells the user when the agent cannot reach Google", () =>
262+
Effect.gen(function* () {
263+
const harness = yield* makeHarness({ interactive: false });
264+
yield* harness.auth.controller.start(owner);
265+
yield* Deferred.await(harness.authenticateCalled);
266+
267+
yield* TestClock.adjust("30 seconds");
268+
const stalled = yield* harness.auth.controller.subscribe(owner).pipe(
269+
Stream.filter((state) => state.message?.includes("Broken IPv6") === true),
270+
Stream.runHead,
271+
Effect.map(Option.getOrThrow),
272+
);
273+
assert.equal(stalled.phase, "starting");
274+
275+
yield* TestClock.adjust("270 seconds");
276+
const failed = yield* phase(harness.auth, "failed");
277+
assert.include(failed.message ?? "", "could not reach Google");
278+
}),
279+
);
280+
281+
it.effect("keeps the expired message once the Google link was shown", () =>
282+
Effect.gen(function* () {
283+
const harness = yield* makeHarness();
284+
yield* harness.auth.controller.start(owner);
285+
yield* phase(harness.auth, "waiting");
286+
287+
yield* TestClock.adjust("300 seconds");
288+
const failed = yield* phase(harness.auth, "failed");
289+
assert.equal(failed.message, "Google sign-in expired. Start sign-in again.");
290+
}),
291+
);
292+
257293
it.effect("accepts direct local or cached completion without a callback RPC", () =>
258294
Effect.gen(function* () {
259295
const harness = yield* makeHarness({ interactive: false });

‎apps/server/src/provider/AntigravityAuth.ts‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ import {
3131
import type { ProviderAuthController } from "./ProviderAuthService.ts";
3232

3333
const AUTH_TIMEOUT_MS = 300_000;
34+
// A healthy agent shows the Google link or finishes within seconds. Its bundled Python has no
35+
// IPv4 fallback race, so a host with broken IPv6 waits about two minutes per Google request.
36+
const NO_RESPONSE_HINT_MS = 30_000;
37+
const NO_RESPONSE_MESSAGE =
38+
"Antigravity has not reached Google after 30 seconds. Check this machine's network connection. Broken IPv6 is a common cause.";
39+
const UNREACHABLE_MESSAGE =
40+
"Antigravity could not reach Google. Check this machine's network connection, then start sign-in again.";
3441
const FORWARDING_FAILED_MESSAGE = "Could not deliver the sign-in response. Start sign-in again.";
3542
const isSetupError = Schema.is(ProviderSetupError);
3643
const isAcpRequestError = Schema.is(AcpErrors.AcpRequestError);
@@ -264,6 +271,17 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
264271
const runSignIn = Effect.fn("AntigravityAuth.runSignIn")(
265272
function* (flow: AuthFlow, stopSessions: Effect.Effect<void, ProviderSetupError>) {
266273
yield* stopSessions.pipe(Effect.ensuring(stopOwnedProcesses));
274+
yield* Effect.sleep(NO_RESPONSE_HINT_MS).pipe(
275+
Effect.andThen(
276+
lock.withPermits(1)(
277+
Effect.gen(function* () {
278+
if (activeFlow !== flow || flow.state.phase !== "starting") return;
279+
yield* publishFlow(flow, { ...flow.state, message: NO_RESPONSE_MESSAGE });
280+
}),
281+
),
282+
),
283+
Effect.forkScoped,
284+
);
267285
const runtime = yield* options.makeRuntime({
268286
onAuthorizationUrl: (url) => receiveAuthorizationUrl(flow, url),
269287
});
@@ -288,7 +306,14 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
288306
Effect.timeoutOrElse({
289307
duration: AUTH_TIMEOUT_MS,
290308
orElse: () =>
291-
Effect.fail(setupError("start", "Google sign-in expired. Start sign-in again.")),
309+
Effect.fail(
310+
setupError(
311+
"start",
312+
flow.state.phase === "starting"
313+
? UNREACHABLE_MESSAGE
314+
: "Google sign-in expired. Start sign-in again.",
315+
),
316+
),
292317
}),
293318
Effect.exit,
294319
Effect.flatMap((result) => finishFlow(flow, result)),

‎apps/web/src/components/settings/ProviderAuthenticationSection.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function ProviderAuthenticationSection({
7575
(provider.driver === "acpRegistry" && auth?.methods?.length === 0));
7676
const accountDescription = active
7777
? auth?.phase === "starting"
78-
? "Starting sign-in…"
78+
? (auth.message ?? "Starting sign-in…")
7979
: auth?.phase === "verifying"
8080
? "Checking your account…"
8181
: interaction?.type === "terminal"

0 commit comments

Comments
 (0)