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: remove Vision/UI content types and skip event serialization when no subscribers

Louis Beaumont03de68250f6d
diff --git a/crates/screenpipe-db/src/fts_indexer.rs b/crates/screenpipe-db/src/fts_indexer.rs
index f941be658..f62ac6dfb 100644
--- a/crates/screenpipe-db/src/fts_indexer.rs
+++ b/crates/screenpipe-db/src/fts_indexer.rs
@@ -55,7 +55,7 @@ pub fn start_fts_indexer(db: Arc<DatabaseManager>) -> tokio::task::JoinHandle<()
/// Index all FTS tables, returning total rows indexed.
/// Adds a small delay between tables so frame inserts can interleave.
-async fn index_all_tables(db: &DatabaseManager) -> i64 {
+pub async fn index_all_tables(db: &DatabaseManager) -> i64 {
let mut total = 0;
let t0 = std::time::Instant::now();
diff --git a/crates/screenpipe-db/src/types.rs b/crates/screenpipe-db/src/types.rs
index 8414da76f..960bec496 100644
--- a/crates/screenpipe-db/src/types.rs
+++ b/crates/screenpipe-db/src/types.rs
@@ -580,41 +580,20 @@ mod tests {
use super::*;
#[test]
- fn test_content_type_case_insensitive() {
- // Test lowercase (original behavior)
+ fn test_content_type_deserialization() {
+ assert_eq!(ContentType::All, serde_json::from_str(r#""all""#).unwrap());
+ assert_eq!(ContentType::OCR, serde_json::from_str(r#""ocr""#).unwrap());
assert_eq!(
ContentType::Audio,
serde_json::from_str(r#""audio""#).unwrap()
);
- assert_eq!(
- ContentType::Vision,
- serde_json::from_str(r#""vision""#).unwrap()
- );
assert_eq!(
ContentType::Input,
serde_json::from_str(r#""input""#).unwrap()
);
- assert_eq!(ContentType::All, serde_json::from_str(r#""all""#).unwrap());
-
- // Test uppercase (new behavior with aliases)
- assert_eq!(
- ContentType::Audio,
- serde_json::from_str(r#""Audio""#).unwrap()
- );
assert_eq!(
- ContentType::Vision,
- serde_json::from_str(r#""Vision""#).unwrap()
+ ContentType::Accessibility,
+ serde_json::from_str(r#""accessibility""#).unwrap()
);
- assert_eq!(
- ContentType::Input,
- serde_json::from_str(r#""Input""#).unwrap()
- );
- assert_eq!(ContentType::All, serde_json::from_str(r#""All""#).unwrap());
-
- // Test OCR/UI aliases (both cases)
- assert_eq!(ContentType::OCR, serde_json::from_str(r#""ocr""#).unwrap());
- assert_eq!(ContentType::OCR, serde_json::from_str(r#""OCR""#).unwrap());
- assert_eq!(ContentType::UI, serde_json::from_str(r#""ui""#).unwrap());
- assert_eq!(ContentType::UI, serde_json::from_str(r#""UI""#).unwrap());
}
}
diff --git a/crates/screenpipe-events/src/events_manager.rs b/crates/screenpipe-events/src/events_manager.rs
index a74da7bb3..4c3ed250b 100644
--- a/crates/screenpipe-events/src/events_manager.rs
+++ b/crates/screenpipe-events/src/events_manager.rs
@@ -140,6 +140,11 @@ impl EventManager {
}
pub fn send<T: Serialize + 'static>(&self, event: impl Into<String>, data: T) -> Result<()> {
+ // Skip serialization entirely when nobody is listening
+ if self.sender.receiver_count() == 0 {
+ return Ok(());
+ }
+
let event_name = event.into();
let value = serde_json::to_value(data)?;