Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(app): detect dead sidecar and respawn on Windows

louis0301957995e3ecba03
diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index 8f9624de7..9db584b46 100644
--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -644,10 +644,29 @@ impl SidecarManager {
pub async fn spawn(&mut self, app: &tauri::AppHandle, override_args: Option<Vec<String>>) -> Result<(), String> {
info!("Spawning sidecar with override args: {:?}", override_args);
- // Check if sidecar is already running
+ // Check if sidecar is already running - but verify it's actually alive
if self.child.is_some() {
- info!("Sidecar already running, skipping spawn");
- return Ok(());
+ // Do a quick health check to verify the process is still running
+ let store = app.state::<SettingsStore>();
+ let port = store.port;
+ let health_url = format!("http://localhost:{}/health", port);
+
+ match reqwest::Client::new()
+ .get(&health_url)
+ .timeout(std::time::Duration::from_secs(2))
+ .send()
+ .await
+ {
+ Ok(resp) if resp.status().is_success() => {
+ info!("Sidecar already running and healthy, skipping spawn");
+ return Ok(());
+ }
+ _ => {
+ // Process died but handle still exists - clear it and respawn
+ warn!("Sidecar handle exists but process is not responding, clearing stale state and respawning");
+ self.child = None;
+ }
+ }
}
// Update settings from store first to get audio settings