Skip to content

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

fix: unit test

Louis Beaumont928b16401204
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml
index 7aaeedaf5..40e8c6288 100644
--- a/.github/workflows/release-app.yml
+++ b/.github/workflows/release-app.yml
@@ -364,7 +364,7 @@ jobs:
- name: Copy library for MKL
if: matrix.tauri-args == '--target x86_64-pc-windows-msvc'
- shell: pwsh
+ shell: powershell
run: |
mkdir omp
pip install intel-openmp --target omp
diff --git a/screenpipe-app-tauri/components/dev-mode-settings.tsx b/screenpipe-app-tauri/components/dev-mode-settings.tsx
index 876867154..018e19e37 100644
--- a/screenpipe-app-tauri/components/dev-mode-settings.tsx
+++ b/screenpipe-app-tauri/components/dev-mode-settings.tsx
@@ -262,7 +262,7 @@ export const DevModeSettings = ({ localDataDir }: { localDataDir: string }) => {
</Button>
</TooltipTrigger>
<TooltipContent>
- <p>start screenpipe backend</p>
+ <p>start screenpipe recording</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
@@ -271,7 +271,7 @@ export const DevModeSettings = ({ localDataDir }: { localDataDir: string }) => {
</CardContent>
<CardFooter className="flex flex-col items-center">
<p className="text-sm text-muted-foreground">
- start or stop screenpipe backend
+ start or stop screenpipe recording
</p>
<p className="text-xs text-muted-foreground">
(auto started when dev mode is off)
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lock
index ca0c8e5b8..8ee69b85e 100755
--- a/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -4713,7 +4713,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "0.15.5"
+version = "0.15.6"
dependencies = [
"anyhow",
"axum",
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index 63a32d9d3..1f890da0e 100644
--- a/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "0.15.5"
+version = "0.15.6"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-core/tests/pipes_test.rs b/screenpipe-core/tests/pipes_test.rs
index f4ade4f52..1023152a2 100644
--- a/screenpipe-core/tests/pipes_test.rs
+++ b/screenpipe-core/tests/pipes_test.rs
@@ -1,7 +1,7 @@
#[cfg(feature = "pipes")]
#[cfg(test)]
mod tests {
- use chrono::{DateTime, TimeZone, Utc};
+ use chrono::{TimeZone, Utc};
use reqwest;
use screenpipe_core::{download_pipe, get_last_cron_execution, run_pipe, save_cron_execution};
use serde_json::json;
diff --git a/screenpipe-server/tests/db.rs b/screenpipe-server/tests/db.rs
index ed46e612b..e5af27331 100644
--- a/screenpipe-server/tests/db.rs
+++ b/screenpipe-server/tests/db.rs
@@ -13,11 +13,7 @@ mod tests {
async fn setup_test_db() -> DatabaseManager {
let db = DatabaseManager::new("sqlite::memory:").await.unwrap();
- // Add speaker_id column temporarily for tests
- sqlx::query("ALTER TABLE audio_transcriptions ADD COLUMN speaker_id INTEGER")
- .execute(&db.pool)
- .await
- .unwrap();
+
db
}
diff --git a/screenpipe-server/tests/endpoint_test.rs b/screenpipe-server/tests/endpoint_test.rs
index df7d1810a..c2a24425d 100644
--- a/screenpipe-server/tests/endpoint_test.rs
+++ b/screenpipe-server/tests/endpoint_test.rs
@@ -29,15 +29,9 @@ mod tests {
error: String,
}
async fn setup_test_app() -> (Router, Arc<AppState>) {
- // env_logger::builder()
- // .filter_level(LevelFilter::Debug)
- // .init();
+
let db = Arc::new(DatabaseManager::new("sqlite::memory:").await.unwrap());
- // Add speaker_id column temporarily for tests
- sqlx::query("ALTER TABLE audio_transcriptions ADD COLUMN speaker_id INTEGER")
- .execute(&db.pool)
- .await
- .unwrap();
+
let app_state = Arc::new(AppState {
db: db.clone(),
vision_control: Arc::new(AtomicBool::new(false)),
@@ -491,4 +485,186 @@ mod tests {
.unwrap();
assert_eq!(audio_count, 1);
}
+
+ #[tokio::test]
+ async fn test_recent_tasks_no_bleeding() {
+ let (_, state) = setup_test_app().await;
+ let db = &state.db;
+
+ // Setup test data with different timestamps
+ let now = Utc::now();
+ let old_timestamp = now - Duration::hours(4);
+ let recent_timestamp = now - Duration::seconds(15);
+
+ // Insert old data
+ let _ = db.insert_video_chunk("old_video.mp4", "test_device").await.unwrap();
+ let old_frame_id = db.insert_frame("test_device", None).await.unwrap();
+
+ // Insert recent data
+ let _ = db.insert_video_chunk("recent_video.mp4", "test_device").await.unwrap();
+ let recent_frame_id = db.insert_frame("test_device", None).await.unwrap();
+
+ // Insert OCR data with different timestamps
+ sqlx::query("UPDATE frames SET timestamp = ? WHERE id = ?")
+ .bind(old_timestamp)
+ .bind(old_frame_id)
+ .execute(&db.pool)
+ .await
+ .unwrap();
+
+ sqlx::query("UPDATE frames SET timestamp = ? WHERE id = ?")
+ .bind(recent_timestamp)
+ .bind(recent_frame_id)
+ .execute(&db.pool)
+ .await
+ .unwrap();
+
+ let _ = db
+ .insert_ocr_text(
+ old_frame_id,
+ "old task: write documentation",
+ "",
+ "vscode",
+ "tasks.md",
+ Arc::new(OcrEngine::Tesseract),
+ false,
+ )
+ .await
+ .unwrap();
+
+ let _ = db
+ .insert_ocr_text(
+ recent_frame_id,
+ "current task: fix bug #123",
+ "",
+ "vscode",
+ "tasks.md",
+ Arc::new(OcrEngine::Tesseract),
+ false,
+ )
+ .await
+ .unwrap();
+
+ // Search with 30-second window
+ let results = db
+ .search(
+ "task",
+ ContentType::OCR,
+ 10,
+ 0,
+ Some(now - Duration::seconds(30)),
+ None,
+ None,
+ None,
+ None,
+ None,
+ )
+ .await
+ .unwrap();
+
+ // Should only return the recent task
+ assert_eq!(results.len(), 1);
+ if let SearchResult::OCR(ocr_result) = &results[0] {
+ assert_eq!(ocr_result.ocr_text, "current task: fix bug #123");
+ assert!(ocr_result.timestamp >= now - Duration::seconds(30));
+ } else {
+ panic!("expected ocr result");
+ }
+
+ // Verify old task is not included
+ let old_results = db
+ .search(
+ "task",
+ ContentType::OCR,
+ 10,
+ 0,
+ Some(old_timestamp - Duration::seconds(1)),
+ Some(old_timestamp + Duration::seconds(1)),
+ None,
+ None,
+ None,
+ None,
+ )
+ .await
+ .unwrap();
+
+ assert_eq!(old_results.len(), 1);
+ if let SearchResult::OCR(ocr_result) = &old_results[0] {
+ assert_eq!(ocr_result.ocr_text, "old task: write documentation");
+ }
+ }
+
+ #[tokio::test]
+ async fn test_recent_tasks_no_bleeding_production_db() {
+ // Get home directory safely
+ let home = std::env::var("HOME").expect("HOME environment variable not set");
+ let db_path = format!("{}/.screenpipe/db.sqlite", home);
+
+ // Open database in read-only mode for safety
+ let db = Arc::new(
+ DatabaseManager::new(&format!("sqlite:{}?mode=ro", db_path))
+ .await
+ .unwrap(),
+ );
+
+ // Get current time for reference
+ let now = Utc::now();
+ let thirty_seconds_ago = now - Duration::seconds(30);
+ let four_hours_ago = now - Duration::hours(4);
+
+ // Search for recent content (last 30 seconds)
+ let recent_results = db
+ .search(
+ "", // empty query to get all content
+ ContentType::OCR,
+ 100,
+ 0,
+ Some(thirty_seconds_ago),
+ None,
+ None,
+ None,
+ None,
+ None,
+ )
+ .await
+ .unwrap();
+
+ println!("found {} recent results", recent_results.len());
+
+ // Search for older content (around 4 hours ago)
+ let old_results = db
+ .search(
+ "",
+ ContentType::OCR,
+ 100,
+ 0,
+ Some(four_hours_ago - Duration::minutes(5)),
+ Some(four_hours_ago + Duration::minutes(5)),
+ None,
+ None,
+ None,
+ None,
+ )
+ .await
+ .unwrap();
+
+ println!("found {} old results", old_results.len());
+
+ // Print some sample data for analysis
+ for result in recent_results.iter().take(5) {
+ if let SearchResult::OCR(ocr) = result {
+ println!("recent: {} ({})", ocr.ocr_text, ocr.timestamp);
+ // Verify timestamp is actually recent
+ assert!(ocr.timestamp >= thirty_seconds_ago,
+ "found old data in recent results: {} at {}",
+ ocr.ocr_text, ocr.timestamp);
+ }
+ }
+
+ for result in old_results.iter().take(5) {
+ if let SearchResult::OCR(ocr) = result {
+ println!("old: {} ({})", ocr.ocr_text, ocr.timestamp);
+ }
+ }
+ }
}
diff --git a/screenpipe-server/tests/tags_test.rs b/screenpipe-server/tests/tags_test.rs
index 3f3561f60..463f7c30b 100644
--- a/screenpipe-server/tests/tags_test.rs
+++ b/screenpipe-server/tests/tags_test.rs
@@ -25,10 +25,7 @@ fn init() {
async fn setup_test_app() -> (Router, Arc<AppState>) {
let db = Arc::new(DatabaseManager::new("sqlite::memory:").await.unwrap());
- sqlx::query("ALTER TABLE audio_transcriptions ADD COLUMN speaker_id INTEGER")
- .execute(&db.pool)
- .await
- .unwrap();
+
let app_state = Arc::new(AppState {
db: db.clone(),
vision_disabled: false,
diff --git a/screenpipe-vision/lib/libscreenpipe_arm64.dylib b/screenpipe-vision/lib/libscreenpipe_arm64.dylib
index 16882c124..9fe967adb 100755
Binary files a/screenpipe-vision/lib/libscreenpipe_arm64.dylib and b/screenpipe-vision/lib/libscreenpipe_arm64.dylib differ