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: destroy+recreate webview after wake instead of silent eval reload
Louis Beaumont37df1961f777
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex fd6d71077..cb3529e1f 100755--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -1512,7 +1512,7 @@ async fn main() {}});- // Reload webviews after system wake to fix black screen (WKWebView content process dies during sleep)+ // Recover webviews after system wake (WKWebView content process dies during sleep)#[cfg(target_os = "macos")]{let app_handle_wake = app_handle.clone();@@ -1522,14 +1522,70 @@ async fn main() {tokio::time::sleep(std::time::Duration::from_secs(2)).await;let woke = screenpipe_engine::sleep_monitor::recently_woke_from_sleep();if woke && !was_asleep {- // System just woke — wait a moment for display to stabilize, then reload+ // System just woke — wait for display to stabilizetokio::time::sleep(std::time::Duration::from_secs(3)).await;- for label in &["main", "home", "chat"] {++ // For main/main-window: try JS reload first, destroy+recreate if dead+ for label in &["main", "main-window"] {+ if let Some(window) = app_handle_wake.get_webview_window(label) {+ // Probe whether the WKWebView JS runtime is still alive+ match window.eval("void(0)") {+ Ok(_) => {+ // JS runtime alive — simple reload suffices+ let _ = window.eval("window.location.reload()");+ tracing::info!("reloaded webview '{}' after wake (JS alive)", label);+ }+ Err(_) => {+ // JS runtime dead — content process was killed.+ // Destroy the window so show() creates a fresh one.+ tracing::warn!(+ "webview '{}' JS runtime dead after wake — destroying for recreation",+ label+ );+ let _ = window.destroy();+ }+ }+ }+ }++ // Recreate main window if it was destroyed+ if app_handle_wake.get_webview_window("main").is_none()+ && app_handle_wake.get_webview_window("main-window").is_none()+ {+ // Small delay to let destroy() finish cleanup+ tokio::time::sleep(std::time::Duration::from_millis(500)).await;+ match ShowRewindWindow::Main.show(&app_handle_wake) {+ Ok(_) => tracing::info!("recreated main window after wake"),+ Err(e) => tracing::error!("failed to recreate main window after wake: {}", e),+ }+ }++ // For home/chat: try JS reload (these are simpler windows)+ for label in &["home", "chat"] {if let Some(window) = app_handle_wake.get_webview_window(label) {- if let Err(e) = window.eval("window.location.reload()") {- tracing::warn!("failed to reload webview '{}' after wake: {}", label, e);- } else {- tracing::info!("reloaded webview '{}' after wake", label);+ match window.eval("void(0)") {+ Ok(_) => {+ let _ = window.eval("window.location.reload()");+ tracing::info!("reloaded webview '{}' after wake", label);+ }+ Err(_) => {+ tracing::warn!(+ "webview '{}' JS runtime dead after wake — destroying for recreation",+ label+ );+ let _ = window.destroy();+ // Recreate home/chat+ tokio::time::sleep(std::time::Duration::from_millis(300)).await;+ let variant = match label {+ &"home" => ShowRewindWindow::Home { page: None },+ &"chat" => ShowRewindWindow::Chat,+ _ => continue,+ };+ match variant.show(&app_handle_wake) {+ Ok(_) => tracing::info!("recreated '{}' window after wake", label),+ Err(e) => tracing::error!("failed to recreate '{}' after wake: {}", label, e),+ }+ }}}}