From 2dda66390d83c32adcaa36b167cc1801298e2a78 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 23 May 2025 09:34:29 +0700 Subject: [PATCH] fix: close side windows should not kill background processes (#5076) --- src-tauri/src/core/mcp.rs | 2 +- src-tauri/src/lib.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/core/mcp.rs b/src-tauri/src/core/mcp.rs index d544b34dc..d3f9091bd 100644 --- a/src-tauri/src/core/mcp.rs +++ b/src-tauri/src/core/mcp.rs @@ -63,7 +63,7 @@ pub async fn run_mcp_commands( if command.clone() == "uvx" { let bun_x_path = format!("{}/uv", bin_path.display()); cmd = Command::new(bun_x_path); - cmd.arg("tool run"); + cmd.arg("tool"); cmd.arg("run"); } println!("Command: {cmd:#?}"); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index daf3834c7..d4f50fc78 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -102,7 +102,7 @@ pub fn run() { setup_mcp(app); setup_sidecar(app).expect("Failed to setup sidecar"); setup_engine_binaries(app).expect("Failed to setup engine binaries"); - // TODO(any) need to wire up with frontend + // TODO(any) need to wire up with frontend // let handle = app.handle().clone(); // tauri::async_runtime::spawn(async move { // handle_app_update(handle).await.unwrap(); @@ -111,14 +111,16 @@ pub fn run() { }) .on_window_event(|window, event| match event { tauri::WindowEvent::CloseRequested { .. } => { - let client = Client::new(); - let url = "http://127.0.0.1:39291/processManager/destroy"; - let _ = client.delete(url).send(); + if window.label() == "main" { + let client = Client::new(); + let url = "http://127.0.0.1:39291/processManager/destroy"; + let _ = client.delete(url).send(); - window.emit("kill-sidecar", ()).unwrap(); + window.emit("kill-sidecar", ()).unwrap(); + } } _ => {} }) .run(tauri::generate_context!()) .expect("error while running tauri application"); -} \ No newline at end of file +}