@@ -75,7 +75,11 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
7575
7676 const makeExecutable = Effect . fn ( "AntigravityDriverTest.makeExecutable" ) ( function * (
7777 name : string ,
78- loginRequired = false ,
78+ options : {
79+ readonly loginRequired ?: boolean ;
80+ /** `data` of the agent's "Internal error" response to `session/new`. */
81+ readonly newSessionErrorData ?: unknown ;
82+ } = { } ,
7983 ) {
8084 const directory = path . join ( root , name ) ;
8185 const executablePath = path . join ( directory , "agy_acp_server.par" ) ;
@@ -87,9 +91,14 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
8791 executablePath ,
8892 [
8993 "#!/bin/sh" ,
90- ...( loginRequired
94+ ...( options . loginRequired
9195 ? [ `printf '%s\\n' ${ shellQuote ( ANTIGRAVITY_AUTH_STDOUT_PREFIX + authorizationUrl ) } ` ]
9296 : [ ] ) ,
97+ ...( options . newSessionErrorData === undefined
98+ ? [ ]
99+ : [
100+ `export T3_ACP_NEW_SESSION_ERROR_DATA=${ shellQuote ( JSON . stringify ( options . newSessionErrorData ) ) } ` ,
101+ ] ) ,
93102 `exec ${ shellQuote ( nodePath ) } ${ shellQuote ( mockAgentPath ) } "$@"` ,
94103 "" ,
95104 ] . join ( "\n" ) ,
@@ -108,7 +117,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
108117
109118 const first = yield * makeExecutable ( "runtime 'one" ) ;
110119 const second = yield * makeExecutable ( "runtime two" ) ;
111- const signedOut = yield * makeExecutable ( "runtime signed-out" , true ) ;
120+ const signedOut = yield * makeExecutable ( "runtime signed-out" , { loginRequired : true } ) ;
112121 const controls = { selected : first , failResolution : false , beforeAcquire : Effect . void } ;
113122 const acquisitions : Array < { binaryPath : string | undefined ; path : string | undefined } > = [ ] ;
114123 const releases : Array < string | null > = [ ] ;
@@ -226,6 +235,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
226235 return {
227236 instance,
228237 refresh,
238+ makeExecutable,
229239 fs,
230240 path,
231241 profileDirectory,
@@ -482,6 +492,58 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
482492 } ) . pipe ( Effect . scoped ) ,
483493 ) ;
484494
495+ it . effect . skipIf ( windowsHost ) (
496+ "shows the agent's error details when session creation fails and keeps the catalog" ,
497+ ( ) =>
498+ Effect . gen ( function * ( ) {
499+ const h = yield * makeHarness ( ) ;
500+ yield * h . refresh ( ) ;
501+ const before = yield * h . instance . snapshot . getSnapshot ;
502+ h . controls . selected = yield * h . makeExecutable ( "runtime socks" , {
503+ newSessionErrorData : { details : "python-socks is required to use a SOCKS proxy" } ,
504+ } ) ;
505+ const error = yield * h . refresh ( ) . pipe ( Effect . flip ) ;
506+ expect ( error . detail ) . toBe (
507+ "Could not refresh Antigravity models. The previous model list is unchanged. Antigravity reported: python-socks is required to use a SOCKS proxy" ,
508+ ) ;
509+ const after = yield * h . instance . snapshot . getSnapshot ;
510+ expect ( after . models ) . toEqual ( before . models ) ;
511+ expect ( after . auth ) . toEqual ( before . auth ) ;
512+ yield * h . assertClosed ;
513+ } ) . pipe ( Effect . scoped ) ,
514+ ) ;
515+
516+ it . effect . skipIf ( windowsHost ) (
517+ "bounds agent error details to one line and ignores details that are not text" ,
518+ ( ) =>
519+ Effect . gen ( function * ( ) {
520+ const h = yield * makeHarness ( ) ;
521+ const generic =
522+ "Could not refresh Antigravity models. The previous model list is unchanged." ;
523+ h . controls . selected = yield * h . makeExecutable ( "runtime traceback" , {
524+ newSessionErrorData : {
525+ details : `Traceback (most recent call last):\n File "agent.py"\n${ "x" . repeat ( 2_000 ) } ` ,
526+ } ,
527+ } ) ;
528+ const bounded = yield * h . refresh ( ) . pipe ( Effect . flip ) ;
529+ expect ( bounded . detail . startsWith ( `${ generic } Antigravity reported: Traceback` ) ) . toBe ( true ) ;
530+ expect ( bounded . detail ) . not . toContain ( "\n" ) ;
531+ expect ( bounded . detail . length ) . toBeLessThanOrEqual ( generic . length + 330 ) ;
532+ expect ( bounded . detail . endsWith ( "…" ) ) . toBe ( true ) ;
533+
534+ for ( const [ name , data ] of [
535+ [ "runtime object details" , { details : { stack : "secret frame" , env : { HOME : "/" } } } ] ,
536+ [ "runtime blank details" , { details : " \n " } ] ,
537+ [ "runtime no details" , [ "python-socks" ] ] ,
538+ ] as const ) {
539+ h . controls . selected = yield * h . makeExecutable ( name , { newSessionErrorData : data } ) ;
540+ const error = yield * h . refresh ( ) . pipe ( Effect . flip ) ;
541+ expect ( error . detail ) . toBe ( generic ) ;
542+ }
543+ yield * h . assertClosed ;
544+ } ) . pipe ( Effect . scoped ) ,
545+ ) ;
546+
485547 it . effect . skipIf ( windowsHost ) (
486548 "gives each process its own temp directory and removes it when the process closes" ,
487549 ( ) =>
0 commit comments