@@ -31,11 +31,15 @@ import {
3131import type { ProviderAuthController } from "./ProviderAuthService.ts" ;
3232
3333const AUTH_TIMEOUT_MS = 300_000 ;
34- // Once initialized, a healthy agent shows the Google link or finishes within seconds. Its bundled
35- // Python has no IPv4 fallback race, so a host with broken IPv6 waits about two minutes per Google
36- // request. The hint is timed from initialize, not spawn: the one-file runtime unpacks itself on
37- // every launch, which can take about a minute on Windows before it answers at all.
34+ // Once initialized, a healthy agent shows the Google link within seconds; its bundled Python has no
35+ // IPv4 fallback, so broken IPv6 stalls each Google request. Startup is timed separately: the
36+ // one-file runtime unpacks on every launch (about a minute on Windows) before it answers initialize.
3837const NO_RESPONSE_HINT_MS = 30_000 ;
38+ const STARTUP_HINT_MS = 90_000 ;
39+ const NOT_STARTED_MESSAGE =
40+ "Antigravity has not started after 90 seconds. Its runtime may be stuck starting on this machine." ;
41+ const NOT_RESPONDING_MESSAGE =
42+ "Antigravity did not respond. Its runtime may not run on this machine." ;
3943const NO_RESPONSE_MESSAGE =
4044 "Antigravity has not reached Google after 30 seconds. Check this machine's network connection. Broken IPv6 is a common cause." ;
4145const UNREACHABLE_MESSAGE =
@@ -55,6 +59,7 @@ interface AuthFlow {
5559 readonly expiresAtMillis : number ;
5660 state : ProviderAuthState ;
5761 pending : AntigravityAuthorizationUrl | undefined ;
62+ initialized : boolean ;
5863 callbackSent : boolean ;
5964 fiber : Fiber . Fiber < void > | undefined ;
6065 forwarding : Fiber . Fiber < void , ProviderSetupError > | undefined ;
@@ -270,25 +275,31 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
270275 ) ,
271276 ) ;
272277
278+ const publishStartingHint = ( flow : AuthFlow , delayMs : number , message : string ) =>
279+ Effect . sleep ( delayMs ) . pipe (
280+ Effect . andThen (
281+ lock . withPermits ( 1 ) (
282+ Effect . gen ( function * ( ) {
283+ if ( activeFlow !== flow || flow . state . phase !== "starting" ) return ;
284+ yield * publishFlow ( flow , { ...flow . state , message } ) ;
285+ } ) ,
286+ ) ,
287+ ) ,
288+ Effect . forkScoped ,
289+ ) ;
290+
273291 const runSignIn = Effect . fn ( "AntigravityAuth.runSignIn" ) (
274292 function * ( flow : AuthFlow , stopSessions : Effect . Effect < void , ProviderSetupError > ) {
275293 yield * stopSessions . pipe ( Effect . ensuring ( stopOwnedProcesses ) ) ;
276294 const runtime = yield * options . makeRuntime ( {
277295 onAuthorizationUrl : ( url ) => receiveAuthorizationUrl ( flow , url ) ,
278296 } ) ;
297+ const startupHint = yield * publishStartingHint ( flow , STARTUP_HINT_MS , NOT_STARTED_MESSAGE ) ;
279298 // `start` reuses this memoized handshake.
280299 yield * runtime . initialize ( ) ;
281- yield * Effect . sleep ( NO_RESPONSE_HINT_MS ) . pipe (
282- Effect . andThen (
283- lock . withPermits ( 1 ) (
284- Effect . gen ( function * ( ) {
285- if ( activeFlow !== flow || flow . state . phase !== "starting" ) return ;
286- yield * publishFlow ( flow , { ...flow . state , message : NO_RESPONSE_MESSAGE } ) ;
287- } ) ,
288- ) ,
289- ) ,
290- Effect . forkScoped ,
291- ) ;
300+ flow . initialized = true ;
301+ yield * Fiber . interrupt ( startupHint ) ;
302+ yield * publishStartingHint ( flow , NO_RESPONSE_HINT_MS , NO_RESPONSE_MESSAGE ) ;
292303 const started = yield * runtime . start ( ) ;
293304 yield * lock . withPermits ( 1 ) (
294305 Effect . gen ( function * ( ) {
@@ -313,9 +324,11 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
313324 Effect . fail (
314325 setupError (
315326 "start" ,
316- flow . state . phase === "starting"
317- ? UNREACHABLE_MESSAGE
318- : "Google sign-in expired. Start sign-in again." ,
327+ flow . state . phase !== "starting"
328+ ? "Google sign-in expired. Start sign-in again."
329+ : flow . initialized
330+ ? UNREACHABLE_MESSAGE
331+ : NOT_RESPONDING_MESSAGE ,
319332 ) ,
320333 ) ,
321334 } ) ,
@@ -402,6 +415,7 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
402415 expiresAtMillis,
403416 state,
404417 pending : undefined ,
418+ initialized : false ,
405419 callbackSent : false ,
406420 fiber : undefined ,
407421 forwarding : undefined ,
0 commit comments