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 most tests
Louis Beaumont15d74ab591e5
diff --git a/screenpipe-server/src/db.rs b/screenpipe-server/src/db.rsindex 55040f9c6..b2202880b 100644--- a/screenpipe-server/src/db.rs+++ b/screenpipe-server/src/db.rs@@ -984,8 +984,8 @@ impl DatabaseManager {AND (?3 IS NULL OR frames.timestamp <= ?3)AND (?4 IS NULL OR ocr_text.app_name LIKE '%' || ?4 || '%')AND (?5 IS NULL OR ocr_text.window_name LIKE '%' || ?5 || '%')- AND (?6 IS NULL OR COALESCE(ocr_text.text_length or LENGTH(ocr_text.text)) >= ?6)- AND (?7 IS NULL OR COALESCE(ocr_text.text_length or LENGTH(ocr_text.text)) <= ?7)+ AND (?6 IS NULL OR COALESCE(ocr_text.text_length, LENGTH(ocr_text.text)) >= ?6)+ AND (?7 IS NULL OR COALESCE(ocr_text.text_length, LENGTH(ocr_text.text)) <= ?7)AND (?8 IS NULL OR frames.name LIKE '%' || ?8 || '%' COLLATE NOCASE)"#,table = if query.is_empty() {@@ -1001,28 +1001,27 @@ impl DatabaseManager {)}ContentType::Audio => {- let table = if query.is_empty() {- "audio_transcriptions"- } else {- "audio_transcriptions_fts JOIN audio_transcriptions ON audio_transcriptions_fts.audio_chunk_id = audio_transcriptions.audio_chunk_id"- };- let match_condition = if query.is_empty() {- "1=1"- } else {- "audio_transcriptions_fts MATCH ?1"- };format!(r#"SELECT COUNT(DISTINCT audio_transcriptions.audio_chunk_id || '_' || COALESCE(audio_transcriptions.start_time, '') || '_' || COALESCE(audio_transcriptions.end_time, ''))- FROM {}- WHERE {}+ FROM {table}+ WHERE {match_condition}AND (?2 IS NULL OR audio_transcriptions.timestamp >= ?2)AND (?3 IS NULL OR audio_transcriptions.timestamp <= ?3)AND (?6 IS NULL OR COALESCE(audio_transcriptions.text_length, LENGTH(audio_transcriptions.transcription)) >= ?6)AND (?7 IS NULL OR COALESCE(audio_transcriptions.text_length, LENGTH(audio_transcriptions.transcription)) <= ?7)AND (json_array_length(?8) = 0 OR audio_transcriptions.speaker_id IN (SELECT value FROM json_each(?8)))"#,- table, match_condition+ table = if query.is_empty() {+ "audio_transcriptions"+ } else {+ "audio_transcriptions_fts JOIN audio_transcriptions ON audio_transcriptions_fts.audio_chunk_id = audio_transcriptions.audio_chunk_id"+ },+ match_condition = if query.is_empty() {+ "1=1"+ } else {+ "audio_transcriptions_fts MATCH ?1"+ })}ContentType::UI => {@@ -1035,8 +1034,8 @@ impl DatabaseManager {AND (?3 IS NULL OR ui_monitoring.timestamp <= ?3)AND (?4 IS NULL OR ui_monitoring.app LIKE '%' || ?4 || '%')AND (?5 IS NULL OR ui_monitoring.window LIKE '%' || ?5 || '%')- AND (?6 IS NULL OR COALESCE(ui_monitoring.text_length or LENGTH(ui_monitoring.text_output)) >= ?6)- AND (?7 IS NULL OR COALESCE(ui_monitoring.text_length or LENGTH(ui_monitoring.text_output)) <= ?7)+ AND (?6 IS NULL OR COALESCE(ui_monitoring.text_length, LENGTH(ui_monitoring.text_output)) >= ?6)+ AND (?7 IS NULL OR COALESCE(ui_monitoring.text_length, LENGTH(ui_monitoring.text_output)) <= ?7)"#,table = if query.is_empty() {"ui_monitoring"@@ -1063,8 +1062,8 @@ impl DatabaseManager {AND (?3 IS NULL OR frames.timestamp <= ?3)AND (?4 IS NULL OR ocr_text.app_name LIKE '%' || ?4 || '%')AND (?5 IS NULL OR ocr_text.window_name LIKE '%' || ?5 || '%')- AND (?6 IS NULL OR ocr_text.text_length >= ?6)- AND (?7 IS NULL OR ocr_text.text_length <= ?7)+ AND (?6 IS NULL OR COALESCE(ocr_text.text_length, LENGTH(ocr_text.text)) >= ?6)+ AND (?7 IS NULL OR COALESCE(ocr_text.text_length, LENGTH(ocr_text.text)) <= ?7)AND (?8 IS NULL OR frames.name LIKE '%' || ?8 || '%' COLLATE NOCASE)AND ocr_text.text != 'No text found'UNION ALL@@ -1074,8 +1073,8 @@ impl DatabaseManager {WHERE {audio_match}AND (?2 IS NULL OR audio_transcriptions.timestamp >= ?2)AND (?3 IS NULL OR audio_transcriptions.timestamp <= ?3)- AND (?6 IS NULL OR audio_transcriptions.text_length >= ?6)- AND (?7 IS NULL OR audio_transcriptions.text_length <= ?7)+ AND (?6 IS NULL OR COALESCE(audio_transcriptions.text_length, LENGTH(audio_transcriptions.transcription)) >= ?6)+ AND (?7 IS NULL OR COALESCE(audio_transcriptions.text_length, LENGTH(audio_transcriptions.transcription)) <= ?7)AND audio_transcriptions.transcription != ''AND (json_array_length(?9) = 0 OR audio_transcriptions.speaker_id IN (SELECT value FROM json_each(?9)))UNION ALL@@ -1087,8 +1086,8 @@ impl DatabaseManager {AND (?3 IS NULL OR ui_monitoring.timestamp <= ?3)AND (?4 IS NULL OR ui_monitoring.app LIKE '%' || ?4 || '%')AND (?5 IS NULL OR ui_monitoring.window LIKE '%' || ?5 || '%')- AND (?6 IS NULL OR ui_monitoring.text_length >= ?6)- AND (?7 IS NULL OR ui_monitoring.text_length <= ?7)+ AND (?6 IS NULL OR COALESCE(ui_monitoring.text_length, LENGTH(ui_monitoring.text_output)) >= ?6)+ AND (?7 IS NULL OR COALESCE(ui_monitoring.text_length, LENGTH(ui_monitoring.text_output)) <= ?7)AND ui_monitoring.text_output != '')"#,ocr_table = if query.is_empty() {diff --git a/screenpipe-server/tests/endpoint_test.rs b/screenpipe-server/tests/endpoint_test.rsindex 44dac7f23..54380c4e7 100644--- a/screenpipe-server/tests/endpoint_test.rs+++ b/screenpipe-server/tests/endpoint_test.rs@@ -531,7 +531,7 @@ mod tests {).await.unwrap();- assert_eq!(audio_count, 1);+ assert_eq!(audio_count, 1); // TODO fail here ?}#[tokio::test]@@ -654,11 +654,16 @@ mod tests {async fn test_recent_tasks_no_bleeding_production_db() {// Get home directory safelylet home = std::env::var("HOME").expect("HOME environment variable not set");- let db_path = format!("{}/.screenpipe/db.sqlite", home);+ let source_db_path = format!("{}/.screenpipe/db.sqlite", home);- // Open database in read-only mode for safety+ // Create temporary directory and copy database+ let temp_dir = tempfile::tempdir().unwrap();+ let temp_db_path = temp_dir.path().join("temp_db.sqlite");+ std::fs::copy(&source_db_path, &temp_db_path).unwrap();++ // Open temporary database copylet db = Arc::new(- DatabaseManager::new(&format!("sqlite:{}?mode=ro", db_path))+ DatabaseManager::new(&format!("sqlite:{}", temp_db_path.display())).await.unwrap(),);diff --git a/screenpipe-vision/examples/websocket.rs b/screenpipe-vision/examples/websocket.rsindex 455953728..e34f017d8 100644--- a/screenpipe-vision/examples/websocket.rs+++ b/screenpipe-vision/examples/websocket.rs@@ -8,7 +8,7 @@ use screenpipe_vision::{continuous_capture, monitor::get_default_monitor, CaptureResult, OcrEngine,};use serde::Serialize;-use std::collections::HashMap;+use serde_json;use std::sync::Arc;use std::time::Duration;use tokio::net::{TcpListener, TcpStream};@@ -24,11 +24,10 @@ struct SimplifiedResult {#[derive(Clone, Serialize)]pub struct SimplifiedWindowResult {- // pub image: String,pub window_name: String,pub app_name: String,pub text: String,- pub text_json: Vec<HashMap<String, String>>, // Change this line+ pub text_json: Vec<serde_json::Value>,pub focused: bool,pub confidence: f64,}@@ -148,11 +147,10 @@ async fn run_websocket_server(let _base64_image = general_purpose::STANDARD.encode(buffer);SimplifiedWindowResult {- // image: base64_image,window_name: window.window_name,app_name: window.app_name,text: window.text,- text_json: window.text_json, // Add this line+ text_json: window.text_json,focused: window.focused,confidence: window.confidence,}