@@ -65,6 +65,7 @@ pub(crate) fn fixture_with_models(
6565 ) ) ) ;
6666 let app = mock_builder ( )
6767 . manage ( host. clone ( ) )
68+ . manage ( crate :: harness_setup:: HarnessSetup :: default ( ) )
6869 . manage ( model_host)
6970 . invoke_handler ( crate :: commands ( ) )
7071 . build ( crate :: app_context ( ) )
@@ -164,6 +165,10 @@ fn real_ipc_snapshot_save_cas_stop_and_launch_gate() {
164165 )
165166 ) ;
166167 assert_eq ! ( before[ "harnessOptions" ] [ 1 ] [ "label" ] , "Goose" ) ;
168+ assert_eq ! (
169+ before[ "harnessOptions" ] [ 1 ] [ "installSupported" ] ,
170+ cfg!( any( target_os = "macos" , target_os = "linux" ) )
171+ ) ;
167172 assert_eq ! ( before[ "harnessOptions" ] [ 1 ] [ "defaultArgs" ] , json!( [ "acp" ] ) ) ;
168173 assert_eq ! (
169174 before[ "harnessOptions" ] [ 1 ] [ "status" ] ,
@@ -333,7 +338,7 @@ fn queued_restore_skips_agent_stopped_after_launch() {
333338 . unwrap ( ) ;
334339 assert_eq ! ( stopped[ "agents" ] [ 0 ] [ "startOnAppLaunch" ] , true ) ;
335340 let restored =
336- tauri:: async_runtime:: block_on ( start ( host. clone ( ) , id, Action :: Start , true , None ) ) ;
341+ tauri:: async_runtime:: block_on ( start ( host. clone ( ) , id, Action :: Start , true , None , false ) ) ;
337342 assert_eq ! (
338343 restored. err( ) . as_deref( ) ,
339344 Some ( "Agent disabled before restore" )
@@ -570,6 +575,85 @@ mod overlap {
570575 }
571576 fresh. shutdown ( ) . unwrap ( ) ;
572577 }
578+
579+ // A genuinely eligible agent: its Start failed on the missing Goose CLI.
580+ // Stop during the download must win over the install's late restart.
581+ #[ test]
582+ fn goose_install_restart_does_not_reenable_an_agent_stopped_during_download ( ) {
583+ const KEY : & str = "0000000000000000000000000000000000000000000000000000000000000001" ;
584+ const PUB : & str = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" ;
585+ struct Stored ;
586+ impl Credentials for Stored {
587+ fn delete ( & self , _: & str , _: & str ) -> Result < ( ) , String > {
588+ panic ! ( "not a deletion" )
589+ }
590+ fn read_legacy ( & self , _: LegacySource , _: & str ) -> Result < Secret , String > {
591+ panic ! ( "not an import" )
592+ }
593+ fn add ( & self , _: & str , _: & Secret ) -> Result < ( ) , String > {
594+ panic ! ( "not a write" )
595+ }
596+ fn read ( & self , _: & str , pubkey : & str ) -> Result < Option < Secret > , String > {
597+ Secret :: parse ( KEY , pubkey) . map ( Some )
598+ }
599+ }
600+ let ( dir, host, _app, view) = fixture ( ) ;
601+ let id = seed ( dir. path ( ) ) ;
602+ let path = dir. path ( ) . join ( "store/agents.json" ) ;
603+ let mut saved: Value = serde_json:: from_slice ( & std:: fs:: read ( & path) . unwrap ( ) ) . unwrap ( ) ;
604+ let id = id. replacen ( & "ab" . repeat ( 32 ) , PUB , 1 ) ;
605+ saved[ "agents" ] [ 0 ] [ "id" ] = json ! ( id) ;
606+ saved[ "agents" ] [ 0 ] [ "pubkey" ] = json ! ( PUB ) ;
607+ saved[ "agents" ] [ 0 ] [ "credentialId" ] = json ! ( id) ;
608+ saved[ "agents" ] [ 0 ] [ "harness" ] [ "command" ] = json ! ( dir. path( ) . join( "missing/goose" ) ) ;
609+ saved[ "agents" ] [ 0 ] [ "harness" ] [ "args" ] = json ! ( [ "acp" ] ) ;
610+ std:: fs:: write ( & path, serde_json:: to_vec ( & saved) . unwrap ( ) ) . unwrap ( ) ;
611+ let credentials: Arc < dyn Credentials > = Arc :: new ( Stored ) ;
612+ host. with ( |h| {
613+ h. controller = Controller :: new (
614+ Store :: open ( dir. path ( ) . join ( "replacement" ) ) ?,
615+ credentials. clone ( ) ,
616+ Err ( "placeholder" . into ( ) ) ,
617+ dir. path ( ) . join ( "ownership" ) ,
618+ ) ;
619+ h. controller = Controller :: new (
620+ Store :: open ( dir. path ( ) . join ( "store" ) ) ?,
621+ credentials. clone ( ) ,
622+ Ok ( synthetic_bundle ( & dir. path ( ) . join ( "tools" ) ) ) ,
623+ dir. path ( ) . join ( "ownership" ) ,
624+ ) ;
625+ h. credentials = credentials;
626+ h. legacy_check = || Ok ( ( ) ) ;
627+ Ok ( ( ) )
628+ } )
629+ . unwrap ( ) ;
630+ let started = tauri:: async_runtime:: block_on ( start (
631+ host. clone ( ) ,
632+ id. clone ( ) ,
633+ Action :: Start ,
634+ false ,
635+ None ,
636+ false ,
637+ ) )
638+ . unwrap ( ) ;
639+ assert_eq ! (
640+ started. data. agents[ 0 ] . error. as_deref( ) ,
641+ Some ( "Required runtime executable is missing" )
642+ ) ;
643+ assert_eq ! ( host. waiting_for_goose( ) . unwrap( ) , vec![ id. clone( ) ] ) ;
644+ invoke (
645+ & view,
646+ "agent_control_action" ,
647+ json ! ( { "id" : id, "action" : "stop" } ) ,
648+ )
649+ . unwrap ( ) ;
650+ assert ! ( host. waiting_for_goose( ) . unwrap( ) . is_empty( ) ) ;
651+ let result =
652+ tauri:: async_runtime:: block_on ( start ( host, id, Action :: Restart , false , None , true ) ) ;
653+ assert_eq ! ( result. err( ) . as_deref( ) , Some ( NOT_WAITING_FOR_GOOSE ) ) ;
654+ let saved: Value = serde_json:: from_slice ( & std:: fs:: read ( path) . unwrap ( ) ) . unwrap ( ) ;
655+ assert_eq ! ( saved[ "agents" ] [ 0 ] [ "enabled" ] , false ) ;
656+ }
573657}
574658
575659#[ cfg( unix) ]
@@ -782,7 +866,7 @@ async fn native_start_restore_disconnect_stop_and_quit_fence_late_credentials()
782866 owner. restore ( ) . await ;
783867 Err ( "restore completed" . into ( ) )
784868 } else {
785- start ( owner, agent_id, Action :: Start , false , None ) . await
869+ start ( owner, agent_id, Action :: Start , false , None , false ) . await
786870 }
787871 } ) ;
788872 tokio:: task:: spawn_blocking ( {
0 commit comments