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
Bump app to v2.0.447
Louis Beaumont7a22e29d69b1
diff --git a/CLAUDE.md b/CLAUDE.mdindex 93e4032c2..5fef9f9e8 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -37,3 +37,7 @@ Use `#` for Python, `//` for Rust/TS/JS/Swift. Keep it as the first comment in t- Config: `apps/screenpipe-app-tauri/src-tauri/tauri.conf.json` → `bundle.macOS.signingIdentity`- This ensures macOS TCC recognizes the app across rebuilds (permissions persist)- Other devs without the cert will see permission issues - onboarding has "continue anyway" button after 5s++## git usage+- make sure to understand there is always bunch of other agents working on the same codebase in parallel, never delete local code or use git reset or such+diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex f62a8dbdf..7134daab8 100755--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -8687,7 +8687,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.0.445"+version = "2.0.446"dependencies = ["anyhow","async-stream",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 13a9818f8..aa25c5446 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.446"+version = "2.0.447"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/crates/screenpipe-server/src/server.rs b/crates/screenpipe-server/src/server.rsindex 70ab02e13..463c18174 100644--- a/crates/screenpipe-server/src/server.rs+++ b/crates/screenpipe-server/src/server.rs@@ -133,6 +133,9 @@ pub struct AppState {pub vision_metrics: Arc<screenpipe_vision::PipelineMetrics>,/// Audio pipeline metrics (shared across all devices)pub audio_metrics: Arc<screenpipe_audio::metrics::AudioPipelineMetrics>,+ /// Limits concurrent ffmpeg frame extractions to prevent CPU thrashing+ /// when many thumbnails are requested in parallel (e.g., search results).+ pub frame_extraction_semaphore: Arc<tokio::sync::Semaphore>,}// Update the SearchQuery struct@@ -1378,6 +1381,10 @@ impl SCServer {pipe_manager: self.pipe_manager.clone(),vision_metrics: self.vision_metrics.clone(),audio_metrics: self.audio_metrics.clone(),+ // Allow up to 3 concurrent ffmpeg extractions. Beyond this, requests+ // queue rather than thrashing CPU with 15+ parallel ffmpeg processes+ // (typical when search results load all thumbnails at once).+ frame_extraction_semaphore: Arc::new(tokio::sync::Semaphore::new(3)),});let cors = CorsLayer::new()@@ -3142,6 +3149,95 @@ pub struct GetFrameQuery {pub redact_pii: bool,}+/// Try to extract a single frame and optionally cache the result.+/// Returns the served image response on success, or the extraction error on failure.+/// Acquires the frame extraction semaphore to limit concurrent ffmpeg processes.+async fn try_extract_and_serve_frame(+ state: &Arc<AppState>,+ frame_id: i64,+ file_path: &str,+ offset_index: i64,+ redact_pii: bool,+) -> Result<Response<Body>, anyhow::Error> {+ let _permit = state+ .frame_extraction_semaphore+ .acquire()+ .await+ .map_err(|_| anyhow::anyhow!("frame extraction semaphore closed"))?;++ let jpeg_q = crate::video::video_quality_to_jpeg_q(&state.video_quality);+ let frame_path = extract_frame_from_video(file_path, offset_index, jpeg_q).await?;++ if redact_pii {+ return apply_pii_redaction(state, frame_id, &frame_path)+ .await+ .map_err(|(status, _)| anyhow::anyhow!("PII redaction failed: {}", status));+ }++ // Store in cache if enabled+ if let Some(cache) = &state.frame_image_cache {+ if let Ok(mut cache) = cache.try_lock() {+ cache.put(frame_id, (frame_path.clone(), Instant::now()));+ }+ }++ serve_file(&frame_path)+ .await+ .map_err(|(status, _)| anyhow::anyhow!("Failed to serve file: {}", status))+}++/// Find the nearest extractable frame by searching backward then forward.+/// Checks file existence/size before expensive ffmpeg extraction to stay fast.+async fn try_nearest_frame(+ state: &Arc<AppState>,+ frame_id: i64,+ redact_pii: bool,+) -> Option<Response<Body>> {+ // Keep small: each miss spawns ffmpeg (~100-500ms). 3 candidates per+ // direction is enough — the bad frame is almost always at a chunk boundary+ // so the very next frame in the other chunk works.+ const SEARCH_LIMIT: i32 = 3;+ const MIN_VIDEO_SIZE: u64 = 1024; // 1KB — below this the file is certainly corrupt++ // Search backward first (older frames are more likely in finalized chunks)+ let directions: [(bool, &str); 2] = [(false, "backward"), (true, "forward")];+ for (forward, dir_name) in directions {+ let candidates = match state.db.get_frames_near(frame_id, forward, SEARCH_LIMIT).await {+ Ok(c) => c,+ Err(_) => continue,+ };++ for (candidate_id, file_path, offset_index, _timestamp) in candidates {+ // Quick pre-check: skip if file missing or too small (avoids ffmpeg spawn)+ match tokio::fs::metadata(&file_path).await {+ Ok(meta) if meta.len() >= MIN_VIDEO_SIZE => {}+ _ => continue,+ }++ match try_extract_and_serve_frame(+ state,+ candidate_id,+ &file_path,+ offset_index,+ redact_pii,+ )+ .await+ {+ Ok(response) => {+ debug!(+ "Frame {} unavailable, serving nearest frame {} ({})",+ frame_id, candidate_id, dir_name+ );+ return Some(response);+ }+ Err(_) => continue,+ }+ }+ }++ None+}+#[oasgen]pub async fn get_frame_data(State(state): State<Arc<AppState>>,@@ -3183,38 +3279,34 @@ pub async fn get_frame_data(// If not in cache or cache disabled, get from databasematch state.db.get_frame(frame_id).await {Ok(Some((file_path, offset_index))) => {- let jpeg_q = crate::video::video_quality_to_jpeg_q(&state.video_quality);- match extract_frame_from_video(&file_path, offset_index, jpeg_q).await {- Ok(frame_path) => {- // Apply PII redaction if requested- if query.redact_pii {- return apply_pii_redaction(&state, frame_id, &frame_path).await;- }-- // Store in cache if enabled and we can get the lock- if let Some(cache) = &state.frame_image_cache {- if let Ok(mut cache) = cache.try_lock() {- cache.put(frame_id, (frame_path.clone(), Instant::now()));- }- }-+ match try_extract_and_serve_frame(+ &state, frame_id, &file_path, offset_index, query.redact_pii,+ )+ .await+ {+ Ok(response) => {debug!("Frame {} extracted in {:?}", frame_id, start_time.elapsed());- serve_file(&frame_path).await+ Ok(response)}Err(e) => {- let err_str = e.to_string();+ // Extraction failed — try the nearest valid frame as fallback+ debug!(+ "Frame {} extraction failed ({}), trying nearest frame",+ frame_id, e+ );+ if let Some(fallback) =+ try_nearest_frame(&state, frame_id, query.redact_pii).await+ {+ return Ok(fallback);+ }- // Check for corrupted/missing video errors - return 410 Gone- // This tells frontend the frame is permanently unavailable+ // No fallback found either+ let err_str = e.to_string();if err_str.contains("VIDEO_CORRUPTED")|| err_str.contains("VIDEO_NOT_FOUND"){- debug!(- "Frame {} unavailable (corrupted/missing video): {}",- frame_id, e- );- return Err((- StatusCode::GONE, // 410 = permanently unavailable+ Err((+ StatusCode::GONE,JsonResponse(json!({"error": "Frame unavailable - video file corrupted or missing","error_type": "video_corrupted",@@ -3222,18 +3314,18 @@ pub async fn get_frame_data("file_path": file_path,"details": err_str})),- ));+ ))+ } else {+ error!("Failed to extract frame {}: {}", frame_id, e);+ Err((+ StatusCode::INTERNAL_SERVER_ERROR,+ JsonResponse(json!({+ "error": format!("Failed to extract frame: {}", e),+ "frame_id": frame_id,+ "file_path": file_path+ })),+ ))}-- error!("Failed to extract frame {}: {}", frame_id, e);- Err((- StatusCode::INTERNAL_SERVER_ERROR,- JsonResponse(json!({- "error": format!("Failed to extract frame: {}", e),- "frame_id": frame_id,- "file_path": file_path- })),- ))}}}