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(browser): MV3 keepalive every 30s + retry owned-browser install
Louis Beaumontc0ba6e6f2580
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex 45979ed58..1c396a149 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -9726,7 +9726,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.4.97"+version = "2.4.98"dependencies = ["anyhow","arboard",@@ -9833,7 +9833,7 @@ dependencies = [[[package]]name = "screenpipe-audio"-version = "0.3.300"+version = "0.3.302"dependencies = ["anyhow","audiopipe",@@ -9889,7 +9889,7 @@ dependencies = [[[package]]name = "screenpipe-config"-version = "0.3.300"+version = "0.3.302"dependencies = ["dirs 6.0.0","serde",@@ -9901,7 +9901,7 @@ dependencies = [[[package]]name = "screenpipe-connect"-version = "0.3.300"+version = "0.3.302"dependencies = ["anyhow","async-trait",@@ -9932,7 +9932,7 @@ dependencies = [[[package]]name = "screenpipe-core"-version = "0.3.300"+version = "0.3.302"dependencies = ["accessibility","accessibility-sys",@@ -9980,7 +9980,7 @@ dependencies = [[[package]]name = "screenpipe-db"-version = "0.3.300"+version = "0.3.302"dependencies = ["anyhow","chrono",@@ -10005,7 +10005,7 @@ dependencies = [[[package]]name = "screenpipe-engine"-version = "0.3.300"+version = "0.3.302"dependencies = ["anyhow","arc-swap",@@ -10070,7 +10070,7 @@ dependencies = [[[package]]name = "screenpipe-events"-version = "0.3.300"+version = "0.3.302"dependencies = ["anyhow","chrono",@@ -10086,7 +10086,7 @@ dependencies = [[[package]]name = "screenpipe-screen"-version = "0.3.300"+version = "0.3.302"dependencies = ["accessibility-sys","anyhow",@@ -10139,7 +10139,7 @@ dependencies = [[[package]]name = "screenpipe-vault"-version = "0.3.300"+version = "0.3.302"dependencies = ["argon2","chacha20poly1305",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 451cf270c..edfaaafab 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.4.97"+version = "2.4.98"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 7f5b7fc94..c12e13831 100755--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -1675,7 +1675,7 @@ async fn main() {let app_for_install = app_for_owned.clone();let data_dir_for_install = config.data_dir.clone();tauri::async_runtime::spawn(async move {- match crate::owned_browser::install(&app_for_install, data_dir_for_install).await {+ match crate::owned_browser::install_with_retry(&app_for_install, data_dir_for_install).await {Ok(handle) => {owned_for_install.attach(handle).await;info!("owned-browser ready");diff --git a/apps/screenpipe-app-tauri/src-tauri/src/owned_browser.rs b/apps/screenpipe-app-tauri/src-tauri/src/owned_browser.rsindex 4f60e5172..1d09a88dc 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/owned_browser.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/owned_browser.rs@@ -142,6 +142,35 @@ impl OwnedWebviewHandle for TauriOwnedHandle {// Install — build the child webview, wire up the result listener, return handle// ---------------------------------------------------------------------------+/// Wait for the main window to exist, then call [`install`]. The server+/// thread can race window creation in `bun tauri dev`, so a single attempt+/// often fails with "parent window 'main' not found"; retrying for a few+/// seconds covers that gap without permanently giving up. After the wait+/// budget the final error is returned and logged at the call site.+pub async fn install_with_retry(+ app: &AppHandle,+ screenpipe_dir: PathBuf,+) -> Result<Arc<dyn OwnedWebviewHandle>, String> {+ const MAX_ATTEMPTS: u32 = 30;+ const BACKOFF: Duration = Duration::from_millis(500);+ let mut last_err = String::from("not attempted");+ for attempt in 1..=MAX_ATTEMPTS {+ match install(app, screenpipe_dir.clone()).await {+ Ok(handle) => return Ok(handle),+ Err(e) => {+ last_err = e;+ tracing::debug!(+ "owned-browser install attempt {attempt}/{MAX_ATTEMPTS} failed: {last_err}"+ );+ tokio::time::sleep(BACKOFF).await;+ }+ }+ }+ Err(format!(+ "owned-browser install gave up after {MAX_ATTEMPTS} attempts: {last_err}"+ ))+}+/// Create the owned-browser child webview if it doesn't exist yet, register/// the result-event listener, and return a ready-to-attach handle. Idempotent.///diff --git a/apps/screenpipe-app-tauri/src-tauri/src/recording.rs b/apps/screenpipe-app-tauri/src-tauri/src/recording.rsindex acec16f95..3df259017 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/recording.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/recording.rs@@ -616,7 +616,9 @@ pub async fn spawn_screenpipe(let owned_for_install = owned_browser.clone();let data_dir_for_install = recording_config.data_dir.clone();tauri::async_runtime::spawn(async move {- match crate::owned_browser::install(&app_for_owned, data_dir_for_install).await {+ match crate::owned_browser::install_with_retry(&app_for_owned, data_dir_for_install)+ .await+ {Ok(handle) => {owned_for_install.attach(handle).await;info!("owned-browser ready");diff --git a/packages/browser-extension/dist/manifest.json b/packages/browser-extension/dist/manifest.jsonindex ef1deb276..b34628aec 100644--- a/packages/browser-extension/dist/manifest.json+++ b/packages/browser-extension/dist/manifest.json@@ -2,7 +2,7 @@"manifest_version": 3,"name": "Screenpipe Browser Bridge","description": "Connects your browser to Screenpipe for AI-powered web automation and data sync.",- "version": "0.3.1",+ "version": "0.3.2","background": {"service_worker": "worker.js","type": "module"diff --git a/packages/browser-extension/dist/worker.js b/packages/browser-extension/dist/worker.jsindex bb12b9177..e35a4cbb4 100644--- a/packages/browser-extension/dist/worker.js+++ b/packages/browser-extension/dist/worker.js@@ -278,10 +278,15 @@ chrome.runtime.onInstalled.addListener(async (details) => {chrome.runtime.openOptionsPage();}});-chrome.alarms.create("screenpipe_keepalive", { periodInMinutes: 1 });+chrome.alarms.create("screenpipe_keepalive", { periodInMinutes: 0.5 });chrome.alarms.onAlarm.addListener((alarm) => {- if (alarm.name === "screenpipe_keepalive")+ if (alarm.name !== "screenpipe_keepalive")+ return;+ if (socket?.readyState === WebSocket.OPEN) {+ send({ type: "ping" });+ } else {connect();+ }});chrome.tabs.onActivated.addListener(() => void connect());chrome.tabs.onUpdated.addListener((_tabId, info) => {diff --git a/packages/browser-extension/package.json b/packages/browser-extension/package.jsonindex ecebab31c..73e89bf83 100644--- a/packages/browser-extension/package.json+++ b/packages/browser-extension/package.json@@ -1,6 +1,6 @@{"name": "@screenpipe/browser-extension",- "version": "0.3.1",+ "version": "0.3.2","private": true,"scripts": {"build": "bun build src/worker.ts src/options.ts src/popup.ts --outdir dist --target browser --format esm",diff --git a/packages/browser-extension/src/worker.ts b/packages/browser-extension/src/worker.tsindex 72f125ebc..6f88bef64 100644--- a/packages/browser-extension/src/worker.ts+++ b/packages/browser-extension/src/worker.ts@@ -415,10 +415,23 @@ chrome.runtime.onInstalled.addListener(async (details) => {}});-/** Keep the service worker warm so the WS doesn't drop after 30s idle. */-chrome.alarms.create("screenpipe_keepalive", { periodInMinutes: 1 });+/** Keep the service worker warm so the WS doesn't drop. Chrome MV3 puts+ * the SW to sleep after ~30s of zero events; the server's READ_IDLE_TIMEOUT+ * is 50s. With a 1-minute alarm the SW spends T+30..T+60 dormant — the+ * setInterval heartbeat pauses and the server kills the WS at T+50.+ * 0.5 min is Chrome's tightest legal period and re-wakes us before the+ * server's idle timer fires. */+chrome.alarms.create("screenpipe_keepalive", { periodInMinutes: 0.5 });chrome.alarms.onAlarm.addListener((alarm) => {- if (alarm.name === "screenpipe_keepalive") void connect();+ if (alarm.name !== "screenpipe_keepalive") return;+ // setInterval may have been killed by SW dormancy. Send a ping directly+ // so the server gets traffic even if the heartbeat loop is gone. If the+ // socket is closed, kick a reconnect.+ if (socket?.readyState === WebSocket.OPEN) {+ send({ type: "ping" });+ } else {+ void connect();+ }});chrome.tabs.onActivated.addListener(() => void connect());