@@ -337,6 +337,11 @@ fn handle(rx: Receiver<ModuleMessage>, state: Arc<Mutex<ManagerState>>) {
337337 . show ( |_| { } ) ;
338338 error ! ( "Module {name_clone} crashed and is being restarted" ) ;
339339 } else {
340+ // Prevent further restarts
341+ state
342+ . modules_pending_shutdown
343+ . insert ( name_clone. clone ( ) , true ) ;
344+
340345 let app = & * get_app_handle ( ) . lock ( ) . expect ( "Failed to get app handle" ) ;
341346
342347 app. dialog ( )
@@ -378,6 +383,15 @@ fn start_module_thread(
378383 return ;
379384 }
380385
386+ start_generic_module_thread ( name, path, custom_args, tx) ;
387+ }
388+
389+ fn start_generic_module_thread (
390+ name : String ,
391+ path : PathBuf ,
392+ custom_args : Option < Vec < String > > ,
393+ tx : Sender < ModuleMessage > ,
394+ ) {
381395 thread:: spawn ( move || {
382396 // Start the child process
383397 let mut command = Command :: new ( & path) ;
@@ -463,8 +477,8 @@ fn start_notify_module_thread(
463477 let error_msg = e. to_string ( ) ;
464478 if error_msg. contains ( "No such option: --output-only" ) {
465479 info ! ( "aw-notify module doesn't support --output-only, falling back to default behavior" ) ;
466- // Fallback to default module handler
467- start_module_thread ( name, path, custom_args, tx) ;
480+ // Fallback to generic module handler to avoid recursion
481+ start_generic_module_thread ( name, path, custom_args, tx) ;
468482 return ;
469483 } else {
470484 error ! ( "Failed to start module {name}: {e}" ) ;
0 commit comments