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: Arc-wrap images, fix OCR-disabled frame insertion, Windows accessibility defaults
Louis Beaumontce43260f4797
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex cf52de26d..41e31083c 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -249,6 +249,12 @@ export function createDefaultSettingsObject(): Settings {DEFAULT_SETTINGS.showChatShortcut = p === "windows" ? "Alt+L" : "Control+Super+L";DEFAULT_SETTINGS.searchShortcut = p === "windows" ? "Alt+K" : "Control+Super+K";+ if (p === "windows") {+ DEFAULT_SETTINGS.enableAccessibility = true;+ DEFAULT_SETTINGS.enableInputCapture = true;+ DEFAULT_SETTINGS.disableOcr = true;+ }+return DEFAULT_SETTINGS;} catch (e) {// Fallback if platform detection failsdiff --git a/crates/screenpipe-server/src/core.rs b/crates/screenpipe-server/src/core.rsindex a52c5ace7..835471f5e 100644--- a/crates/screenpipe-server/src/core.rs+++ b/crates/screenpipe-server/src/core.rs@@ -237,7 +237,7 @@ pub async fn record_video(captured_at: chrono::DateTime<chrono::Utc>,offset_index: i64,windows: Vec<FrameWindowData>,- image: image::DynamicImage,+ image: std::sync::Arc<image::DynamicImage>,timestamp: std::time::Instant,window_metadata: Vec<(String,@@ -425,6 +425,11 @@ pub async fn record_video(for (frame_idx, frame_results) in all_results.iter().enumerate() {let pf = &pending_frames[frame_idx];for (frame_id, win_idx) in frame_results {+ // Skip event for bare frames inserted without window data+ // (e.g. OCR disabled + no windows detected)+ if *win_idx >= pf.window_metadata.len() {+ continue;+ }let (ref text, ref sanitized_text_json, _, ref window_result) =pf.window_metadata[*win_idx];let send_event_start = std::time::Instant::now();diff --git a/crates/screenpipe-server/src/video.rs b/crates/screenpipe-server/src/video.rsindex efbe870d9..9a2cbab5c 100644--- a/crates/screenpipe-server/src/video.rs+++ b/crates/screenpipe-server/src/video.rs@@ -8,9 +8,9 @@ use dashmap::DashMap;use image::ImageFormat::{self};use screenpipe_core::{find_ffmpeg_path, Language};use screenpipe_vision::{- capture_screenshot_by_window::WindowFilters, continuous_capture, monitor::get_monitor_by_id,- ocr_cache::WindowOcrCache, process_ocr_task, CaptureResult, OcrEngine, PipelineMetrics,- RawCaptureResult,+ capture_screenshot_by_window::WindowFilters, continuous_capture, core::WindowOcrResult,+ monitor::get_monitor_by_id, ocr_cache::WindowOcrCache, process_ocr_task, CaptureResult,+ OcrEngine, PipelineMetrics, RawCaptureResult,};use std::path::PathBuf;@@ -464,13 +464,30 @@ impl VideoCapture {loop {if let Some(raw_frame) = ocr_work_queue_clone.pop() {if disable_ocr {- // Skip OCR, create result with empty window_ocr_results+ // Skip OCR but still populate window metadata from the raw+ // capture so frames are inserted into the DB. Without this,+ // the timeline is completely empty when OCR is disabled because+ // insert_multi_frames_with_ocr_batch only creates frame rows+ // when window_ocr_results is non-empty.+ let window_ocr_results: Vec<WindowOcrResult> = raw_frame+ .window_images+ .iter()+ .map(|w| WindowOcrResult {+ app_name: w.app_name.clone(),+ window_name: w.window_name.clone(),+ text: String::new(),+ text_json: Vec::new(),+ focused: w.is_focused,+ confidence: 0.0,+ browser_url: w.browser_url.clone(),+ })+ .collect();let capture = CaptureResult {image: raw_frame.image.clone(),frame_number: raw_frame.frame_number,timestamp: raw_frame.timestamp,captured_at: raw_frame.captured_at,- window_ocr_results: Vec::new(),+ window_ocr_results,};push_to_ocr_queue(&ocr_frame_queue_clone, &Arc::new(capture), "OCR-out");} else {@@ -1350,7 +1367,7 @@ mod tests {let make_frame = |n: u64| -> Arc<RawCaptureResult> {Arc::new(RawCaptureResult {- image: DynamicImage::new_rgb8(1, 1),+ image: std::sync::Arc::new(DynamicImage::new_rgb8(1, 1)),window_images: vec![],frame_number: n,timestamp: std::time::Instant::now(),@@ -1403,7 +1420,7 @@ mod tests {// Push a frame into the queueassert!(frame_queue.push(Arc::new(RawCaptureResult {- image: DynamicImage::new_rgb8(64, 64),+ image: std::sync::Arc::new(DynamicImage::new_rgb8(64, 64)),window_images: vec![],frame_number: 0,timestamp: std::time::Instant::now(),diff --git a/crates/screenpipe-vision/src/core.rs b/crates/screenpipe-vision/src/core.rsindex bc76b1952..ab63ca312 100644--- a/crates/screenpipe-vision/src/core.rs+++ b/crates/screenpipe-vision/src/core.rs@@ -37,11 +37,12 @@ use tokio::sync::mpsc::Sender;use tokio::sync::Mutex;use tracing::{debug, error};-fn serialize_image<S>(image: &Option<DynamicImage>, serializer: S) -> Result<S::Ok, S::Error>+fn serialize_image<S>(image: &Option<Arc<DynamicImage>>, serializer: S) -> Result<S::Ok, S::Error>whereS: serde::Serializer,{- if let Some(image) = image {+ if let Some(ref image) = image {+ let image: &DynamicImage = image.as_ref();let mut webp_buffer = Vec::new();let mut cursor = std::io::Cursor::new(&mut webp_buffer);@@ -62,7 +63,7 @@ where}}-fn deserialize_image<'de, D>(deserializer: D) -> Result<Option<DynamicImage>, D::Error>+fn deserialize_image<'de, D>(deserializer: D) -> Result<Option<Arc<DynamicImage>>, D::Error>whereD: serde::Deserializer<'de>,{@@ -84,7 +85,7 @@ where// Decode the JPEG data back into an imagelet image = image::load(cursor, image::ImageFormat::Jpeg).map_err(serde::de::Error::custom)?;- Ok(Some(image))+ Ok(Some(Arc::new(image)))}fn serialize_instant<S>(instant: &Instant, serializer: S) -> Result<S::Ok, S::Error>@@ -106,7 +107,7 @@ where}pub struct CaptureResult {- pub image: DynamicImage,+ pub image: Arc<DynamicImage>,pub frame_number: u64,pub timestamp: Instant,/// Wall-clock timestamp captured atomically with the screenshot@@ -126,7 +127,7 @@ pub struct WindowOcrResult {}pub struct RawCaptureResult {- pub image: DynamicImage,+ pub image: Arc<DynamicImage>,pub window_images: Vec<CapturedWindow>,pub frame_number: u64,pub timestamp: Instant,@@ -324,12 +325,17 @@ pub async fn continuous_capture(// 4b. Capture windows only for frames that passed the change threshold.// This avoids expensive per-window screenshots + CGWindowList enumeration// on unchanged frames (major CPU savings on multi-monitor setups).+ // Note: window capture is still needed even when OCR is disabled because+ // the metadata (app_name, window_name, browser_url, focused) is used by+ // the timeline and DB frame insertion.let window_images =capture_windows(&monitor, &window_filters, capture_unfocused_windows).await;// Send raw capture result (OCR happens in separate worker)+ // Wrap image in Arc to avoid expensive full-bitmap clones downstream.+ // The image is never mutated after capture — all consumers only read it.let raw = RawCaptureResult {- image: image.clone(),+ image: Arc::new(image),window_images,frame_number: frame_counter,timestamp: Instant::now(),@@ -678,7 +684,7 @@ pub struct WindowOcr {serialize_with = "serialize_image",deserialize_with = "deserialize_image")]- pub image: Option<DynamicImage>,+ pub image: Option<Arc<DynamicImage>>,pub window_name: String,pub app_name: String,pub text: String,diff --git a/crates/screenpipe-vision/tests/decoupled_pipeline_test.rs b/crates/screenpipe-vision/tests/decoupled_pipeline_test.rsindex 58b25cf8e..9fcb1a5b3 100644--- a/crates/screenpipe-vision/tests/decoupled_pipeline_test.rs+++ b/crates/screenpipe-vision/tests/decoupled_pipeline_test.rs@@ -18,6 +18,7 @@ use image::{DynamicImage, ImageBuffer, Rgba};use screenpipe_vision::capture_screenshot_by_window::CapturedWindow;use screenpipe_vision::core::RawCaptureResult;use screenpipe_vision::ocr_cache::WindowOcrCache;+use std::sync::Arc;use screenpipe_vision::{process_ocr_task, OcrEngine};use std::sync::Arc;use std::time::{Duration, Instant};@@ -54,7 +55,7 @@ fn create_test_raw_capture(frame_number: u64, num_windows: usize) -> RawCaptureR.collect();RawCaptureResult {- image,+ image: Arc::new(image),window_images,frame_number,timestamp: Instant::now(),diff --git a/crates/screenpipe-vision/tests/windows_vision_test.rs b/crates/screenpipe-vision/tests/windows_vision_test.rsindex a2afde4a4..86e233095 100644--- a/crates/screenpipe-vision/tests/windows_vision_test.rs+++ b/crates/screenpipe-vision/tests/windows_vision_test.rs@@ -43,7 +43,7 @@ mod tests {}];let raw = RawCaptureResult {- image: image.clone(),+ image: std::sync::Arc::new(image.clone()),window_images,frame_number,timestamp,