@@ -69,13 +69,17 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
6969 let receiveAuthorizationUrl :
7070 | ( ( url : string ) => Effect . Effect < void , AcpErrors . AcpError > )
7171 | undefined ;
72+ let logRequest :
73+ | ( ( event : AcpSessionRuntime . AcpSessionRequestLogEvent ) => Effect . Effect < void > )
74+ | undefined ;
7275 let forwarded = 0 ;
7376 let catalog = [ "previous-account-model" ] ;
7477 const auth = yield * makeAntigravityAuth ( {
7578 instanceId,
7679 makeRuntime : ( input ) =>
7780 Effect . gen ( function * ( ) {
7881 receiveAuthorizationUrl = input . onAuthorizationUrl ;
82+ logRequest = input . requestLogger ;
7983 events . push ( "process-open" ) ;
8084 yield * Effect . addFinalizer ( ( ) =>
8185 Effect . gen ( function * ( ) {
@@ -95,6 +99,13 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
9599 start : ( ) =>
96100 Effect . gen ( function * ( ) {
97101 events . push ( "authenticate" ) ;
102+ yield * (
103+ input . requestLogger ?.( {
104+ method : "authenticate" ,
105+ payload : { methodId : "oauth-personal" } ,
106+ status : "started" ,
107+ } ) ?? Effect . void
108+ ) ;
98109 yield * Deferred . succeed ( authenticateCalled , undefined ) ;
99110 if ( options . interactive !== false && input . onAuthorizationUrl ) {
100111 for ( const url of options . authorizationUrls ?? [ authorizationUrl ] ) {
@@ -153,6 +164,10 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
153164 ? receiveAuthorizationUrl ( url )
154165 : Effect . die ( "Authorization URL receiver is not ready." ) ,
155166 ) ,
167+ logRequest : ( event : AcpSessionRuntime . AcpSessionRequestLogEvent ) =>
168+ Effect . suspend ( ( ) =>
169+ logRequest ? logRequest ( event ) : Effect . die ( "Request logger is not ready." ) ,
170+ ) ,
156171 } ;
157172} ) ;
158173
@@ -347,6 +362,29 @@ it.layer(NodeServices.layer)("AntigravityAuth", (it) => {
347362 } ) ,
348363 ) ;
349364
365+ it . effect ( "shows the new Google link when the agent authenticates again" , ( ) =>
366+ Effect . gen ( function * ( ) {
367+ const harness = yield * makeHarness ( ) ;
368+ yield * harness . auth . controller . start ( owner ) ;
369+ yield * phase ( harness . auth , "waiting" ) ;
370+ yield * Deferred . succeed ( harness . authenticated , undefined ) ;
371+ yield * Deferred . await ( harness . sessionRequested ) ;
372+
373+ const retryUrl = authorizationUrl . replace ( "state=test-state" , "state=retry-state" ) ;
374+ yield * harness . logRequest ( {
375+ method : "authenticate" ,
376+ payload : { methodId : "oauth-personal" } ,
377+ status : "started" ,
378+ } ) ;
379+ yield * harness . receiveAuthorizationUrl ( retryUrl ) ;
380+ const current = yield * harness . auth . controller
381+ . subscribe ( owner )
382+ . pipe ( Stream . runHead , Effect . map ( Option . getOrThrow ) ) ;
383+ assert . equal ( current . phase , "waiting" ) ;
384+ assert . equal ( current . authorizationUrl , retryUrl ) ;
385+ } ) ,
386+ ) ;
387+
350388 it . effect ( "does not call a completed Google sign-in expired when no session opens" , ( ) =>
351389 Effect . gen ( function * ( ) {
352390 const harness = yield * makeHarness ( ) ;
0 commit comments