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
chore: test data freshness #19
Louis Beaumont4eee1212f4a7
diff --git a/screenpipe-server/Cargo.toml b/screenpipe-server/Cargo.tomlindex e197ea885..a966ed000 100644--- a/screenpipe-server/Cargo.toml+++ b/screenpipe-server/Cargo.toml@@ -77,6 +77,8 @@ crossbeam = "0.8"[dev-dependencies]tempfile = "3.3.0"+reqwest = { version = "0.11", features = ["json"] }+[features]static-ffmpeg = ["ffmpeg-next/static"]diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rsindex 70e8d634f..78b22ede9 100644--- a/screenpipe-server/src/bin/screenpipe-server.rs+++ b/screenpipe-server/src/bin/screenpipe-server.rs@@ -6,11 +6,11 @@ use std::{};use clap::Parser;-use log::{info, LevelFilter, warn};+use colored::Colorize;+use log::{info, warn, LevelFilter};use screenpipe_audio::{default_input_device, default_output_device, list_audio_devices, parse_device_spec,};-use colored::Colorize;use screenpipe_server::{start_continuous_recording, DatabaseManager, ResourceMonitor, Server}; // Import the list_audio_devices function#[derive(Parser)]@@ -47,6 +47,10 @@ struct Cli {/// List available audio devices#[arg(long)]list_audio_devices: bool,++ /// Data directory+ #[arg(long, default_value_t = String::from("./data"))]+ data_dir: String,}#[tokio::main]@@ -119,7 +123,9 @@ async fn main() -> anyhow::Result<()> {ResourceMonitor::new(cli.memory_threshold, cli.runtime_threshold).start_monitoring(Duration::from_secs(10)); // Log every 10 seconds- let local_data_dir = Arc::new(ensure_local_data_dir()?);+ let local_data_dir = cli.data_dir; // TODO: Use $HOME/.screenpipe/data+ fs::create_dir_all(&local_data_dir)?;+ let local_data_dir = Arc::new(local_data_dir);let local_data_dir_record = local_data_dir.clone();let db = Arc::new(DatabaseManager::new(&format!("{}/db.sqlite", local_data_dir))@@ -163,9 +169,3 @@ async fn main() -> anyhow::Result<()> {tokio::time::sleep(Duration::from_secs(1)).await;}}--fn ensure_local_data_dir() -> anyhow::Result<String> {- let local_data_dir = "./data".to_string(); // TODO: Use $HOME/.screenpipe/data- fs::create_dir_all(&local_data_dir)?;- Ok(local_data_dir)-}diff --git a/screenpipe-server/tests/audio_vision_integration_test.rs b/screenpipe-server/tests/audio_vision_integration_test.rsindex 9f7075ff3..52089bb0b 100644--- a/screenpipe-server/tests/audio_vision_integration_test.rs+++ b/screenpipe-server/tests/audio_vision_integration_test.rs@@ -1,8 +1,61 @@-use std::{sync::mpsc, thread, time::Duration};+use reqwest;+use serde_json::Value;+use std::time::{Duration, Instant};-use screenpipe_server::VideoCapture;+#[tokio::test]+async fn test_screen_capture_to_api_delay() {+ // rm the data directory+ std::fs::remove_dir_all("../data-test").unwrap_or_default();-#[test]-fn test_audio_video_capture() {- assert!(true) // TODO+ println!("Run: ./target/release/screenpipe --data-dir ./data-test");++ let wikipedia_url = "https://en.wikipedia.org/wiki/Rust_(programming_language)";+ println!("Go to this Wikipedia page: {}", wikipedia_url);++ // wait 2 seconds+ tokio::time::sleep(Duration::from_secs(5)).await;++ // Record start time+ let start_time = Instant::now();++ // Initialize client+ let client = reqwest::Client::new();++ // Poll the API until the desired phrase is found+ let mut found = false;+ while !found {+ let response: Value = client+ .get("http://localhost:3030/search?q=Graydon&limit=5&offset=0")+ .send()+ .await+ .expect("Failed to send request")+ .json()+ .await+ .expect("Failed to parse JSON");++ let data: Vec<Value> = response["data"].as_array().unwrap().to_vec();++ found = data+ .iter()+ .filter(|item| item["type"] == "OCR")+ .any(|item| {+ item["content"]["text"]+ .as_str()+ .unwrap()+ .contains("without a garbage collector")+ });++ if !found {+ tokio::time::sleep(Duration::from_secs(1)).await;+ }+ }++ println!("Found the phrase!");+ println!("Time elapsed: {:?}", start_time.elapsed());++ // Mac M3 max: Time elapsed: 33.516971916s+ // Mac M3 max: Time elapsed: 153.62804525s++ // You can add assertions here if needed+ // assert!(elapsed_time < Duration::from_secs(30), "Test took too long");}