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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(recording): don't health-check dying server during restart
Louis Beaumont5c44f56f4273
diff --git a/Cargo.toml b/Cargo.tomlindex 4ca6ec6c2..919f86cbb 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -6,7 +6,7 @@ exclude = ["apps/screenpipe-app-tauri/src-tauri"]resolver = "2"[workspace.package]-version = "0.3.87"+version = "0.3.88"authors = ["louis030195 <[email protected]>"]description = ""repository = "https://github.com/screenpipe/screenpipe"diff --git a/apps/screenpipe-app-tauri/components/text-overlay.tsx b/apps/screenpipe-app-tauri/components/text-overlay.tsxindex d2ec9c095..e1a32af48 100644--- a/apps/screenpipe-app-tauri/components/text-overlay.tsx+++ b/apps/screenpipe-app-tauri/components/text-overlay.tsx@@ -38,7 +38,35 @@ export function isUrl(text: string): boolean {const domainPattern =/^[a-zA-Z][a-zA-Z0-9-]{0,61}[a-zA-Z0-9](\.[a-zA-Z][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])*\.(com|org|net|io|dev|app|ai|edu|gov)(\/[^\s]*)?$/i;- return domainPattern.test(trimmed);+ if (!domainPattern.test(trimmed)) return false;++ // Extract just the hostname (before first /)+ const hostname = trimmed.split("/")[0].toLowerCase();++ // Reject OCR-garbled protocol prefixes (e.g. "httos.atthub.com" = garbled "https://github.com")+ if (/^htto?s?[^p]/i.test(hostname) || /^htt[a-z]/i.test(hostname) && !hostname.startsWith("http")) {+ return false;+ }++ // Reject if any hostname label has 4+ consecutive consonants+ // (real domains rarely do: "hcnsleodian" has "hcnsl", "npmjs" is borderline but short)+ // Only apply to labels longer than 5 chars to allow short acronyms like "npmjs"+ const labels = hostname.split(".");+ const vowels = new Set(["a", "e", "i", "o", "u"]);+ for (const label of labels) {+ if (label.length <= 5) continue;+ let consecutive = 0;+ for (const ch of label) {+ if (/[a-z]/.test(ch) && !vowels.has(ch)) {+ consecutive++;+ if (consecutive >= 4) return false;+ } else {+ consecutive = 0;+ }+ }+ }++ return true;}/**diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex 2c1a9d6e8..7b98ecb40 100755--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -9089,7 +9089,7 @@ dependencies = [[[package]]name = "screenpipe-audio"-version = "0.3.86"+version = "0.3.87"dependencies = ["anyhow","bytemuck",@@ -9137,7 +9137,7 @@ dependencies = [[[package]]name = "screenpipe-core"-version = "0.3.86"+version = "0.3.87"dependencies = ["accessibility","accessibility-sys",@@ -9188,7 +9188,7 @@ dependencies = [[[package]]name = "screenpipe-db"-version = "0.3.86"+version = "0.3.87"dependencies = ["anyhow","chrono",@@ -9212,7 +9212,7 @@ dependencies = [[[package]]name = "screenpipe-events"-version = "0.3.86"+version = "0.3.87"dependencies = ["anyhow","chrono",@@ -9228,7 +9228,7 @@ dependencies = [[[package]]name = "screenpipe-integrations"-version = "0.3.86"+version = "0.3.87"dependencies = ["anyhow","image 0.25.9",@@ -9243,7 +9243,7 @@ dependencies = [[[package]]name = "screenpipe-server"-version = "0.3.86"+version = "0.3.87"dependencies = ["anyhow","async-trait",@@ -9307,7 +9307,7 @@ dependencies = [[[package]]name = "screenpipe-vision"-version = "0.3.86"+version = "0.3.87"dependencies = ["accessibility-sys","anyhow",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 33df36845..684178a2f 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "2.0.293"+version = "2.0.294"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/apps/screenpipe-app-tauri/src-tauri/src/recording.rs b/apps/screenpipe-app-tauri/src-tauri/src/recording.rsindex e1c73a7c4..73d4d99a5 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/recording.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/recording.rs@@ -128,46 +128,62 @@ pub async fn spawn_screenpipe() -> Result<(), String> {info!("Starting screenpipe server");- // Check if already running — first check the port regardless of handle statelet store = SettingsStore::get(&app).ok().flatten().unwrap_or_default();let port = store.port;let health_url = format!("http://localhost:{}/health", port);+ // Stop existing server if any, and decide whether to check for orphans+ let need_orphan_check;{- let handle_guard = state.0.lock().await;-- // Always check if the server port is responding, even without a handle- // (handles the case where server was started externally or by main.rs)- match reqwest::Client::new()- .get(&health_url)- .timeout(std::time::Duration::from_secs(2))- .send()- .await- {- Ok(resp) if resp.status().is_success() => {- info!("Screenpipe server already running and healthy on port {}", port);- return Ok(());- }- _ => {- if handle_guard.is_some() {+ let mut handle_guard = state.0.lock().await;+ if handle_guard.is_some() {+ // We own this server — check if it's healthy before restarting+ match reqwest::Client::new()+ .get(&health_url)+ .timeout(std::time::Duration::from_secs(2))+ .send()+ .await+ {+ Ok(resp) if resp.status().is_success() => {+ info!("Screenpipe server already running and healthy on port {}", port);+ return Ok(());+ }+ _ => {warn!("Server handle exists but not responding, will restart");}}- }- }-- // Stop existing server if any- {- let mut handle_guard = state.0.lock().await;- if let Some(handle) = handle_guard.take() {- handle.shutdown();- // Give it time to release the port- tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;+ // Shut it down — we're restarting intentionally+ if let Some(handle) = handle_guard.take() {+ handle.shutdown();+ tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;+ }+ need_orphan_check = false;+ } else {+ // No handle — cold start. Check if an orphaned process holds the port.+ match reqwest::Client::new()+ .get(&health_url)+ .timeout(std::time::Duration::from_secs(2))+ .send()+ .await+ {+ Ok(resp) if resp.status().is_success() => {+ // Orphan is healthy — reuse it+ info!("Screenpipe server already running and healthy on port {} (no handle, reusing)", port);+ return Ok(());+ }+ _ => {+ // Port may be held by an unhealthy orphan+ need_orphan_check = true;+ }+ }}}// Kill any orphaned process holding our port (crash leftover, CLI run, etc.)- kill_process_on_port(port).await;+ // Only needed on cold start — during intentional restart we already shut down above.+ if need_orphan_check {+ kill_process_on_port(port).await;+ }// Check permissions before startinglet permissions_check = do_permissions_check(false);