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

feat: add browser_url to api results

Louis Beaumontd729e93d115b
diff --git a/data/2024-07-12_01-14-14.mp4 b/data/2024-07-12_01-14-14.mp4
deleted file mode 100644
index 2dc807b37..000000000
Binary files a/data/2024-07-12_01-14-14.mp4 and /dev/null differ
diff --git a/data/Display 1 (output)_2024-07-12_01-14-11.mp3 b/data/Display 1 (output)_2024-07-12_01-14-11.mp3
deleted file mode 100644
index ccda752a0..000000000
Binary files a/data/Display 1 (output)_2024-07-12_01-14-11.mp3 and /dev/null differ
diff --git a/data/db.sqlite b/data/db.sqlite
deleted file mode 100644
index 30027696e..000000000
Binary files a/data/db.sqlite and /dev/null differ
diff --git a/screenpipe-audio/examples/stt.rs b/screenpipe-audio/examples/stt.rs
index be53a6199..9c73e6716 100644
--- a/screenpipe-audio/examples/stt.rs
+++ b/screenpipe-audio/examples/stt.rs
@@ -89,7 +89,7 @@ async fn main() {
device: Arc::new(screenpipe_audio::default_input_device().unwrap()),
};
- let mut segments = prepare_segments(
+ let (mut segments, _) = prepare_segments(
&audio_input.data,
vad_engine.clone(),
&segmentation_model_path,
diff --git a/screenpipe-audio/tests/accuracy_test.rs b/screenpipe-audio/tests/accuracy_test.rs
index 5dae1c491..dacf3335f 100644
--- a/screenpipe-audio/tests/accuracy_test.rs
+++ b/screenpipe-audio/tests/accuracy_test.rs
@@ -106,7 +106,7 @@ async fn test_transcription_accuracy() {
audio_input.data.as_ref().to_vec()
};
- let mut segments = prepare_segments(
+ let (mut segments, _) = prepare_segments(
&audio_data,
vad_engine.clone(),
&segmentation_model_path,
diff --git a/screenpipe-audio/tests/core_tests.rs b/screenpipe-audio/tests/core_tests.rs
index ac698fefb..f6fd445db 100644
--- a/screenpipe-audio/tests/core_tests.rs
+++ b/screenpipe-audio/tests/core_tests.rs
@@ -330,7 +330,7 @@ mod tests {
));
let embedding_manager = EmbeddingManager::new(usize::MAX);
- let mut segments = prepare_segments(
+ let (mut segments, _) = prepare_segments(
&audio_input.data,
vad_engine.clone(),
&segmentation_model_path,
@@ -426,7 +426,7 @@ mod tests {
// Measure transcription time
let start_time = Instant::now();
- let mut segments = prepare_segments(
+ let (mut segments, _) = prepare_segments(
&audio_input.data,
vad_engine.clone(),
&segmentation_model_path,
diff --git a/screenpipe-server/src/db.rs b/screenpipe-server/src/db.rs
index ef9e9e08c..4ada8bb11 100644
--- a/screenpipe-server/src/db.rs
+++ b/screenpipe-server/src/db.rs
@@ -753,7 +753,8 @@ impl DatabaseManager {
ocr_text.app_name,
ocr_text.ocr_engine,
ocr_text.window_name,
- GROUP_CONCAT(tags.name, ',') as tags
+ GROUP_CONCAT(tags.name, ',') as tags,
+ frames.browser_url
FROM {}
JOIN frames ON ocr_text.frame_id = frames.id
JOIN video_chunks ON frames.video_chunk_id = video_chunks.id
@@ -805,6 +806,7 @@ impl DatabaseManager {
.tags
.map(|t| t.split(',').map(String::from).collect())
.unwrap_or_default(),
+ browser_url: raw.browser_url,
})
.collect())
}
@@ -1550,7 +1552,8 @@ impl DatabaseManager {
ui_monitoring.window,
ui_monitoring.initial_traversal_at,
video_chunks.file_path,
- frames.offset_index
+ frames.offset_index,
+ frames.browser_url
FROM {}
LEFT JOIN frames ON
frames.timestamp BETWEEN
@@ -1989,7 +1992,8 @@ impl DatabaseManager {
ocr_text.app_name,
ocr_text.ocr_engine,
ocr_text.window_name,
- GROUP_CONCAT(tags.name, ',') as tags
+ GROUP_CONCAT(tags.name, ',') as tags,
+ frames.browser_url
FROM embedding_matches
JOIN ocr_text ON embedding_matches.frame_id = ocr_text.frame_id
JOIN frames ON ocr_text.frame_id = frames.id
@@ -2026,6 +2030,7 @@ impl DatabaseManager {
.tags
.map(|t| t.split(',').map(String::from).collect())
.unwrap_or_default(),
+ browser_url: raw.browser_url,
})
.collect())
}
diff --git a/screenpipe-server/src/db_types.rs b/screenpipe-server/src/db_types.rs
index 6a1275c88..912d1990f 100644
--- a/screenpipe-server/src/db_types.rs
+++ b/screenpipe-server/src/db_types.rs
@@ -36,6 +36,7 @@ pub struct OCRResultRaw {
pub ocr_engine: String,
pub window_name: String,
pub tags: Option<String>,
+ pub browser_url: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
@@ -51,6 +52,7 @@ pub struct OCRResult {
pub ocr_engine: String,
pub window_name: String,
pub tags: Vec<String>,
+ pub browser_url: Option<String>,
}
#[derive(Debug, Deserialize, PartialEq, Default, Clone)]
@@ -132,6 +134,7 @@ pub struct UiContent {
pub file_path: String,
pub offset_index: i64,
pub frame_name: Option<String>,
+ pub browser_url: Option<String>,
}
#[derive(Debug, Clone)]
diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rs
index 36eba297f..8dc748e91 100644
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@ -38,7 +38,7 @@ use screenpipe_audio::{
};
use tracing::{debug, error, info};
-use screenpipe_vision::monitor::{list_monitors, get_monitor_by_id};
+use screenpipe_vision::monitor::{get_monitor_by_id, list_monitors};
use screenpipe_vision::OcrEngine;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::{json, Value};
@@ -189,6 +189,7 @@ pub struct OCRContent {
pub tags: Vec<String>,
pub frame: Option<String>,
pub frame_name: Option<String>,
+ pub browser_url: Option<String>,
}
#[derive(Serialize, Deserialize, Debug)]
@@ -217,6 +218,7 @@ pub struct UiContent {
pub file_path: String,
pub offset_index: i64,
pub frame_name: Option<String>,
+ pub browser_url: Option<String>,
}
#[derive(Serialize)]
@@ -352,6 +354,7 @@ pub(crate) async fn search(
tags: ocr.tags.clone(),
frame: None,
frame_name: Some(ocr.frame_name.clone()),
+ browser_url: ocr.browser_url.clone(),
}),
SearchResult::Audio(audio) => ContentItem::Audio(AudioContent {
chunk_id: audio.audio_chunk_id,
@@ -376,6 +379,7 @@ pub(crate) async fn search(
file_path: ui.file_path.clone(),
offset_index: ui.offset_index,
frame_name: ui.frame_name.clone(),
+ browser_url: ui.browser_url.clone(),
}),
})
.collect();
@@ -1106,7 +1110,11 @@ async fn add_frame_to_db(
let db = &state.db;
let frame_id = db
- .insert_frame(device_name, Some(frame.timestamp.unwrap_or_else(Utc::now)), None)
+ .insert_frame(
+ device_name,
+ Some(frame.timestamp.unwrap_or_else(Utc::now)),
+ None,
+ )
.await?;
if let Some(ocr_results) = &frame.ocr_results {
@@ -2532,4 +2540,3 @@ pub struct RestartVisionDevicesResponse {
// restarted_devices,
// }))
// }
-
diff --git a/screenpipe-server/tests/db.rs b/screenpipe-server/tests/db.rs
index 9ae3dd810..bd2610fcc 100644
--- a/screenpipe-server/tests/db.rs
+++ b/screenpipe-server/tests/db.rs
@@ -11,7 +11,15 @@ mod tests {
use screenpipe_vision::OcrEngine;
async fn setup_test_db() -> DatabaseManager {
- DatabaseManager::new("sqlite::memory:").await.unwrap()
+ let db = DatabaseManager::new("sqlite::memory:").await.unwrap();
+
+ // Run all migrations
+ sqlx::migrate!("./src/migrations")
+ .run(&db.pool)
+ .await
+ .unwrap();
+
+ db
}
#[tokio::test]
diff --git a/screenpipe-server/tests/video_utils_test.rs b/screenpipe-server/tests/video_utils_test.rs
index b33db5b3a..c1a43e3ee 100644
--- a/screenpipe-server/tests/video_utils_test.rs
+++ b/screenpipe-server/tests/video_utils_test.rs
@@ -8,10 +8,10 @@ use tokio::fs;
use tracing::info;
async fn setup_test_env() -> Result<()> {
- // enable tracing logging
- tracing_subscriber::fmt()
+ // Only initialize if not already set
+ let _ = tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
- .init();
+ .try_init();
Ok(())
}
@@ -127,6 +127,7 @@ async fn test_extract_frames_and_ocr() -> Result<()> {
window_name: "test_window".to_string(),
app_name: "test_app".to_string(),
is_focused: true,
+ process_id: 1234,
};
// perform ocr using apple native (macos only)