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: remove ui-events/adaptive-fps feature flags, add PII removal to capture

Louis Beaumontafab1b5c28b0
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index 210e436f8..20d38ad50 100755
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -8097,7 +8097,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.0.538"
+version = "2.0.539"
dependencies = [
"anyhow",
"arboard",
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index 43a415bb0..2f08a0809 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -108,8 +108,8 @@ md5 = "0.7"
screenpipe-core = { path = "../../../crates/screenpipe-core", features = ["cloud-sync"] }
# Embedded screenpipe server
-screenpipe-server = { path = "../../../crates/screenpipe-server", default-features = false, features = ["ui-events", "adaptive-fps"] }
-screenpipe-vision = { path = "../../../crates/screenpipe-vision", features = ["adaptive-fps"] }
+screenpipe-server = { path = "../../../crates/screenpipe-server", default-features = false }
+screenpipe-vision = { path = "../../../crates/screenpipe-vision" }
screenpipe-accessibility = { path = "../../../crates/screenpipe-accessibility" }
screenpipe-audio = { path = "../../../crates/screenpipe-audio" }
screenpipe-db = { path = "../../../crates/screenpipe-db" }
diff --git a/crates/screenpipe-server/Cargo.toml b/crates/screenpipe-server/Cargo.toml
index 5ea9a1284..4c70d5783 100644
--- a/crates/screenpipe-server/Cargo.toml
+++ b/crates/screenpipe-server/Cargo.toml
@@ -19,7 +19,7 @@ screenpipe-vision = { path = "../screenpipe-vision" }
screenpipe-audio = { path = "../screenpipe-audio" }
screenpipe-core = { path = "../screenpipe-core", features = ["security", "cloud-sync"] }
screenpipe-db = { path = "../screenpipe-db" }
-screenpipe-accessibility = { path = "../screenpipe-accessibility", features = ["db"], optional = true }
+screenpipe-accessibility = { path = "../screenpipe-accessibility", features = ["db"] }
screenpipe-apple-intelligence = { path = "../screenpipe-apple-intelligence", optional = true }
@@ -116,14 +116,12 @@ tokio-tungstenite = "0.24"
criterion = { workspace = true }
[features]
-default = ["ui-events"]
+default = []
metal = ["screenpipe-audio/metal"]
cuda = ["screenpipe-audio/cuda"]
vulkan = ["screenpipe-audio/vulkan"]
debug-console = ["console-subscriber"]
-adaptive-fps = ["screenpipe-vision/adaptive-fps"]
pulseaudio = ["screenpipe-audio/pulseaudio"]
-ui-events = ["screenpipe-accessibility"]
apple-intelligence = ["dep:screenpipe-apple-intelligence"]
[[bin]]
diff --git a/crates/screenpipe-server/src/cli.rs b/crates/screenpipe-server/src/cli.rs
index f60863aaa..c60ae4161 100644
--- a/crates/screenpipe-server/src/cli.rs
+++ b/crates/screenpipe-server/src/cli.rs
@@ -242,7 +242,6 @@ impl Cli {
}
/// Create UI recorder configuration from CLI arguments
- #[cfg(feature = "ui-events")]
pub fn to_ui_recorder_config(&self) -> crate::ui_recorder::UiRecorderConfig {
crate::ui_recorder::UiRecorderConfig {
enabled: self.enable_input_capture || self.enable_accessibility,
@@ -254,11 +253,6 @@ impl Cli {
..Default::default()
}
}
-
- #[cfg(not(feature = "ui-events"))]
- pub fn to_ui_recorder_config(&self) -> crate::ui_recorder::UiRecorderConfig {
- crate::ui_recorder::UiRecorderConfig { enabled: false }
- }
}
// =============================================================================
@@ -490,7 +484,6 @@ impl RecordArgs {
}
/// Create UI recorder configuration from record arguments
- #[cfg(feature = "ui-events")]
pub fn to_ui_recorder_config(&self) -> crate::ui_recorder::UiRecorderConfig {
crate::ui_recorder::UiRecorderConfig {
enabled: self.enable_input_capture || self.enable_accessibility,
@@ -503,11 +496,6 @@ impl RecordArgs {
}
}
- #[cfg(not(feature = "ui-events"))]
- pub fn to_ui_recorder_config(&self) -> crate::ui_recorder::UiRecorderConfig {
- crate::ui_recorder::UiRecorderConfig { enabled: false }
- }
-
/// Convert RecordArgs into a unified RecordingConfig.
pub fn into_recording_config(
self,
diff --git a/crates/screenpipe-server/src/event_driven_capture.rs b/crates/screenpipe-server/src/event_driven_capture.rs
index 67ac80a45..ffb8ce794 100644
--- a/crates/screenpipe-server/src/event_driven_capture.rs
+++ b/crates/screenpipe-server/src/event_driven_capture.rs
@@ -12,6 +12,8 @@ use crate::hot_frame_cache::{HotFrame, HotFrameCache};
use crate::paired_capture::{paired_capture, CaptureContext, PairedCaptureResult};
use anyhow::Result;
use chrono::Utc;
+use screenpipe_accessibility::tree::TreeWalkerConfig;
+use screenpipe_accessibility::ActivityFeed;
use screenpipe_db::DatabaseManager;
use screenpipe_vision::frame_comparison::{FrameComparer, FrameComparisonConfig};
use screenpipe_vision::monitor::SafeMonitor;
@@ -23,11 +25,6 @@ use std::time::{Duration, Instant};
use tokio::sync::broadcast;
use tracing::{debug, error, info, warn};
-#[cfg(feature = "ui-events")]
-use screenpipe_accessibility::tree::TreeWalkerConfig;
-#[cfg(feature = "ui-events")]
-use screenpipe_accessibility::ActivityFeed;
-
/// Types of events that trigger a capture.
#[derive(Debug, Clone, PartialEq)]
pub enum CaptureTrigger {
@@ -152,7 +149,6 @@ impl EventDrivenCapture {
///
/// Call this in a loop at ~50ms intervals. Returns `Some(trigger)` when
/// a state transition is detected that warrants a capture.
- #[cfg(feature = "ui-events")]
pub fn poll_activity(&mut self, feed: &ActivityFeed) -> Option<CaptureTrigger> {
let idle_ms = feed.idle_ms();
let is_typing = feed.is_typing();
@@ -202,7 +198,6 @@ pub fn trigger_channel() -> (TriggerSender, TriggerReceiver) {
/// 2. ActivityFeed state transitions (typing pause, idle) via polling
///
/// Each trigger results in a paired capture (screenshot + accessibility tree walk).
-#[cfg(feature = "ui-events")]
#[allow(clippy::too_many_arguments)]
pub async fn event_driven_capture_loop(
db: Arc<DatabaseManager>,
@@ -217,6 +212,7 @@ pub async fn event_driven_capture_loop(
stop_signal: Arc<AtomicBool>,
vision_metrics: Arc<screenpipe_vision::PipelineMetrics>,
hot_frame_cache: Option<Arc<HotFrameCache>>,
+ use_pii_removal: bool,
) -> Result<()> {
info!(
"event-driven capture started for monitor {} (device: {})",
@@ -252,6 +248,7 @@ pub async fn event_driven_capture_loop(
&snapshot_writer,
&tree_walker_config,
&CaptureTrigger::Manual,
+ use_pii_removal,
)
.await
{
@@ -353,6 +350,7 @@ pub async fn event_driven_capture_loop(
&snapshot_writer,
&tree_walker_config,
&trigger,
+ use_pii_removal,
),
)
.await;
@@ -422,7 +420,6 @@ pub async fn event_driven_capture_loop(
}
/// Push a capture result into the hot frame cache.
-#[cfg(feature = "ui-events")]
async fn push_to_hot_cache(
cache: &HotFrameCache,
result: &PairedCaptureResult,
@@ -452,7 +449,6 @@ async fn push_to_hot_cache(
}
/// Result of do_capture: paired capture result + the screenshot image for comparer reuse.
-#[cfg(feature = "ui-events")]
struct CaptureOutput {
result: PairedCaptureResult,
/// The captured image — reused for frame comparer update to avoid taking
@@ -461,7 +457,6 @@ struct CaptureOutput {
}
/// Perform a single event-driven capture.
-#[cfg(feature = "ui-events")]
async fn do_capture(
db: &DatabaseManager,
monitor: &SafeMonitor,
@@ -470,6 +465,7 @@ async fn do_capture(
snapshot_writer: &SnapshotWriter,
tree_walker_config: &TreeWalkerConfig,
trigger: &CaptureTrigger,
+ use_pii_removal: bool,
) -> Result<CaptureOutput> {
let captured_at = Utc::now();
@@ -509,6 +505,7 @@ async fn do_capture(
browser_url: browser_url_owned.as_deref(),
focused: true, // event-driven captures are always for the focused window
capture_trigger: trigger.as_str(),
+ use_pii_removal,
};
let result = paired_capture(&ctx, tree_snapshot.as_ref()).await?;
diff --git a/crates/screenpipe-server/src/meeting_watcher.rs b/crates/screenpipe-server/src/meeting_watcher.rs
index 4dcd8c915..b5e41ac32 100644
--- a/crates/screenpipe-server/src/meeting_watcher.rs
+++ b/crates/screenpipe-server/src/meeting_watcher.rs
@@ -8,22 +8,16 @@
//! Meeting detection only needs app-switch/window-focus events from the accessibility API
//! and does NOT depend on the `enable_input_capture`/`enable_accessibility` user toggles.
-#[cfg(feature = "ui-events")]
use screenpipe_accessibility::{UiCaptureConfig, UiRecorder};
-#[cfg(feature = "ui-events")]
use screenpipe_audio::meeting_detector::MeetingDetector;
-#[cfg(feature = "ui-events")]
use std::sync::Arc;
-#[cfg(feature = "ui-events")]
use std::time::Duration;
-#[cfg(feature = "ui-events")]
use tracing::{debug, error, info, warn};
/// Start a lightweight accessibility listener that only watches for app switches
/// and feeds them into the `MeetingDetector`. Does not touch the database.
///
/// Returns a `JoinHandle` that runs until the task is aborted.
-#[cfg(feature = "ui-events")]
pub fn start_meeting_watcher(detector: Arc<MeetingDetector>) -> tokio::task::JoinHandle<()> {
tokio::spawn(async move {
// Minimal config: only app_switch and window_focus, everything else off
@@ -103,13 +97,3 @@ pub fn start_meeting_watcher(detector: Arc<MeetingDetector>) -> tokio::task::Joi
}
})
}
-
-/// Stub when ui-events feature is disabled — meeting detection won't work
-/// but compilation succeeds.
-#[cfg(not(feature = "ui-events"))]
-pub fn start_meeting_watcher(
- _detector: std::sync::Arc<screenpipe_audio::meeting_detector::MeetingDetector>,
-) -> tokio::task::JoinHandle<()> {
- tracing::warn!("meeting watcher: ui-events feature disabled, meeting detection unavailable");
- tokio::spawn(async {})
-}
diff --git a/crates/screenpipe-server/src/paired_capture.rs b/crates/screenpipe-server/src/paired_capture.rs
index e7db83c34..d86e02482 100644
--- a/crates/screenpipe-server/src/paired_capture.rs
+++ b/crates/screenpipe-server/src/paired_capture.rs
@@ -14,15 +14,14 @@
use anyhow::Result;
use chrono::{DateTime, Utc};
use image::DynamicImage;
+use screenpipe_accessibility::tree::{create_tree_walker, TreeSnapshot, TreeWalkerConfig};
+use screenpipe_core::pii_removal::remove_pii;
use screenpipe_db::DatabaseManager;
use screenpipe_vision::snapshot_writer::SnapshotWriter;
use std::sync::Arc;
use std::time::Instant;
use tracing::{debug, warn};
-#[cfg(feature = "ui-events")]
-use screenpipe_accessibility::tree::{create_tree_walker, TreeSnapshot, TreeWalkerConfig};
-
/// Context for a paired capture operation — replaces positional arguments.
pub struct CaptureContext<'a> {
pub db: &'a DatabaseManager,
@@ -36,6 +35,7 @@ pub struct CaptureContext<'a> {
pub browser_url: Option<&'a str>,
pub focused: bool,
pub capture_trigger: &'a str,
+ pub use_pii_removal: bool,
}
/// Result of a paired capture operation.
@@ -69,8 +69,7 @@ pub struct PairedCaptureResult {
/// Accepts an optional `TreeSnapshot` with structured node data.
pub async fn paired_capture(
ctx: &CaptureContext<'_>,
- #[cfg(feature = "ui-events")] tree_snapshot: Option<&TreeSnapshot>,
- #[cfg(not(feature = "ui-events"))] _tree_snapshot: Option<&()>,
+ tree_snapshot: Option<&TreeSnapshot>,
) -> Result<PairedCaptureResult> {
let start = Instant::now();
@@ -91,12 +90,9 @@ pub async fn paired_capture(
// ~50-200ms of Apple Vision CPU work per capture AND prevents cloning
// the Arc<DynamicImage> into the spawn_blocking closure (which would
// make Arc::try_unwrap fail later, forcing a full image copy).
- #[cfg(feature = "ui-events")]
let has_accessibility_text = tree_snapshot
.map(|s| !s.text_content.is_empty())
.unwrap_or(false);
- #[cfg(not(feature = "ui-events"))]
- let has_accessibility_text = false;
// Only run OCR when accessibility tree returned no text (games, terminals, etc.)
let (ocr_text, ocr_text_json) = if !has_accessibility_text {
@@ -122,7 +118,6 @@ pub async fn paired_capture(
};
// --- Extract data from tree snapshot, fall back to OCR text ---
- #[cfg(feature = "ui-events")]
let (accessibility_text, tree_json, content_hash, simhash) = match tree_snapshot {
Some(snap) if !snap.text_content.is_empty() => {
let json = serde_json::to_string(&snap.nodes).ok();
@@ -143,18 +138,6 @@ pub async fn paired_capture(
}
};
- #[cfg(not(feature = "ui-events"))]
- let (accessibility_text, tree_json, content_hash, simhash): (
- Option<String>,
- Option<String>,
- Option<i64>,
- Option<i64>,
- ) = if ocr_text.is_empty() {
- (None, None, None, None)
- } else {
- (Some(ocr_text.clone()), None, None, None)
- };
-
// Determine text source: "accessibility" when tree nodes were available, "ocr" for fallback
let (final_text, text_source) = if let Some(ref text) = accessibility_text {
if text.is_empty() {
@@ -169,9 +152,32 @@ pub async fn paired_capture(
(None, None)
};
+ // Apply PII removal to text before DB insertion (if enabled).
+ // This sanitizes emails, API keys, credit cards, SSNs, etc. from OCR/accessibility text
+ // so pipes (like obsidian-sync) never see raw PII in search results.
+ let sanitized_text = if ctx.use_pii_removal {
+ final_text.map(|t| remove_pii(t))
+ } else {
+ final_text.map(|t| t.to_string())
+ };
+ let sanitized_ocr_text = if ctx.use_pii_removal && !ocr_text.is_empty() {
+ remove_pii(&ocr_text)
+ } else {
+ ocr_text.clone()
+ };
+ let sanitized_ocr_json = if ctx.use_pii_removal && !ocr_text.is_empty() {
+ sanitize_ocr_text_json(&ocr_text_json)
+ } else {
+ ocr_text_json.clone()
+ };
+
// Insert snapshot frame + OCR text positions in a single transaction.
- let ocr_data = if !ocr_text.is_empty() {
- Some((ocr_text.as_str(), ocr_text_json.as_str(), "AppleNative"))
+ let ocr_data = if !sanitized_ocr_text.is_empty() {
+ Some((
+ sanitized_ocr_text.as_str(),
+ sanitized_ocr_json.as_str(),
+ "AppleNative",
+ ))
} else {
None
};
@@ -187,7 +193,7 @@ pub async fn paired_capture(
ctx.browser_url,
ctx.focused,
Some(ctx.capture_trigger),
- final_text,
+ sanitized_text.as_deref(),
text_source,
tree_json.as_deref(),
content_hash,
@@ -220,7 +226,6 @@ pub async fn paired_capture(
/// Returns the text content and app/window metadata.
///
/// This is a blocking operation that should be spawned on a blocking thread.
-#[cfg(feature = "ui-events")]
pub fn walk_accessibility_tree(config: &TreeWalkerConfig) -> Option<TreeSnapshot> {
let walker = create_tree_walker(config.clone());
match walker.walk_focused_window() {
@@ -247,10 +252,22 @@ pub fn walk_accessibility_tree(config: &TreeWalkerConfig) -> Option<TreeSnapshot
}
}
+/// Sanitize PII from OCR text_json (a JSON string of bounding-box entries).
+/// Parses the JSON array, applies `remove_pii` to each "text" field,
+/// and serializes back. Returns the original string on parse failure.
+fn sanitize_ocr_text_json(text_json: &str) -> String {
+ let Ok(entries) = serde_json::from_str::<Vec<std::collections::HashMap<String, String>>>(text_json) else {
+ return text_json.to_string();
+ };
+ let sanitized = screenpipe_core::pii_removal::remove_pii_from_text_json(&entries);
+ serde_json::to_string(&sanitized).unwrap_or_else(|_| text_json.to_string())
+}
+
#[cfg(test)]
mod tests {
use super::*;
use image::{DynamicImage, RgbImage};
+ use screenpipe_accessibility::tree::AccessibilityTreeNode;
use tempfile::TempDir;
fn test_image() -> Arc<DynamicImage> {
@@ -278,11 +295,9 @@ mod tests {
browser_url: None,
focused: true,
capture_trigger: "click",
+ use_pii_removal: false,
};
- #[cfg(feature = "ui-events")]
- let result = paired_capture(&ctx, None).await.unwrap();
- #[cfg(not(feature = "ui-events"))]
let result = paired_capture(&ctx, None).await.unwrap();
assert!(result.frame_id > 0);
@@ -313,44 +328,36 @@ mod tests {
browser_url: Some("https://example.com"),
focused: true,
capture_trigger: "app_switch",
+ use_pii_removal: false,
};
- #[cfg(feature = "ui-events")]
- let result = {
- use screenpipe_accessibility::tree::AccessibilityTreeNode;
- let snap = TreeSnapshot {
- app_name: "Safari".to_string(),
- window_name: "Example Page".to_string(),
- text_content: "Hello World - Example Page".to_string(),
- nodes: vec![AccessibilityTreeNode {
- role: "AXStaticText".to_string(),
- text: "Hello World - Example Page".to_string(),
- depth: 0,
- }],
- browser_url: Some("https://example.com".to_string()),
- timestamp: now,
- node_count: 1,
- walk_duration: std::time::Duration::from_millis(5),
- content_hash: 12345,
- simhash: 67890,
- truncated: false,
- truncation_reason: screenpipe_accessibility::tree::TruncationReason::None,
- max_depth_reached: 0,
- };
- paired_capture(&ctx, Some(&snap)).await.unwrap()
+ let snap = TreeSnapshot {
+ app_name: "Safari".to_string(),
+ window_name: "Example Page".to_string(),
+ text_content: "Hello World - Example Page".to_string(),
+ nodes: vec![AccessibilityTreeNode {
+ role: "AXStaticText".to_string(),
+ text: "Hello World - Example Page".to_string(),
+ depth: 0,
+ }],
+ browser_url: Some("https://example.com".to_string()),
+ timestamp: now,
+ node_count: 1,
+ walk_duration: std::time::Duration::from_millis(5),
+ content_hash: 12345,
+ simhash: 67890,
+ truncated: false,
+ truncation_reason: screenpipe_accessibility::tree::TruncationReason::None,
+ max_depth_reached: 0,
};
- #[cfg(not(feature = "ui-events"))]
- let result = paired_capture(&ctx, None).await.unwrap();
+ let result = paired_capture(&ctx, Some(&snap)).await.unwrap();
assert!(result.frame_id > 0);
- #[cfg(feature = "ui-events")]
- {
- assert_eq!(result.text_source.as_deref(), Some("accessibility"));
- assert_eq!(
- result.accessibility_text.as_deref(),
- Some("Hello World - Example Page")
- );
- }
+ assert_eq!(result.text_source.as_deref(), Some("accessibility"));
+ assert_eq!(
+ result.accessibility_text.as_deref(),
+ Some("Hello World - Example Page")
+ );
assert_eq!(result.capture_trigger, "app_switch");
}
@@ -375,33 +382,84 @@ mod tests {
browser_url: None,
focused: true,
capture_trigger: "idle",
+ use_pii_removal: false,
};
// Empty accessibility text should be treated as no text
- #[cfg(feature = "ui-events")]
- let result = {
- let snap = TreeSnapshot {
- app_name: "TestApp".to_string(),
- window_name: String::new(),
- text_content: String::new(),
- nodes: vec![],
- browser_url: None,
- timestamp: now,
- node_count: 0,
- walk_duration: std::time::Duration::from_millis(1),
- content_hash: 0,
- simhash: 0,
- truncated: false,
- truncation_reason: screenpipe_accessibility::tree::TruncationReason::None,
- max_depth_reached: 0,
- };
- paired_capture(&ctx, Some(&snap)).await.unwrap()
+ let snap = TreeSnapshot {
+ app_name: "TestApp".to_string(),
+ window_name: String::new(),
+ text_content: String::new(),
+ nodes: vec![],
+ browser_url: None,
+ timestamp: now,
+ node_count: 0,
+ walk_duration: std::time::Duration::from_millis(1),
+ content_hash: 0,
+ simhash: 0,
+ truncated: false,
+ truncation_reason: screenpipe_accessibility::tree::TruncationReason::None,
+ max_depth_reached: 0,
};
- #[cfg(not(feature = "ui-events"))]
- let result = paired_capture(&ctx, None).await.unwrap();
+ let result = paired_capture(&ctx, Some(&snap)).await.unwrap();
assert!(result.frame_id > 0);
// Empty string → treated as no text source
assert!(result.text_source.is_none());
}
+
+ #[test]
+ fn test_sanitize_ocr_text_json_removes_emails() {
+ let json = r#"[{"text":"contact [email protected] for info","x":"10","y":"20"}]"#;
+ let result = sanitize_ocr_text_json(json);
+ assert!(!result.contains("[email protected]"), "email should be redacted");
+ assert!(result.contains("[EMAIL]"), "email should be replaced with [EMAIL]");
+ }
+
+ #[test]
+ fn test_sanitize_ocr_text_json_preserves_non_pii() {
+ let json = r#"[{"text":"hello world","x":"10","y":"20"}]"#;
+ let result = sanitize_ocr_text_json(json);
+ assert!(result.contains("hello world"));
+ }
+
+ #[test]
+ fn test_sanitize_ocr_text_json_invalid_json_passthrough() {
+ let bad_json = "not json at all";
+ let result = sanitize_ocr_text_json(bad_json);
+ assert_eq!(result, bad_json, "invalid JSON should pass through unchanged");
+ }
+
+ #[test]
+ fn test_sanitize_ocr_text_json_multiple_entries() {
+ let json = r#"[{"text":"[email protected]","x":"0","y":"0"},{"text":"safe text","x":"1","y":"1"},{"text":"key: sk-1234567890abcdef1234567890abcdef","x":"2","y":"2"}]"#;
+ let result = sanitize_ocr_text_json(json);
+ assert!(!result.contains("[email protected]"), "email should be redacted");
+ assert!(result.contains("safe text"), "non-PII text should be preserved");
+ }
+
+ #[test]
+ fn test_pii_removal_on_text() {
+ // Verify remove_pii works on plain text with emails
+ let text = "Contact [email protected] or [email protected] for support";
+ let sanitized = remove_pii(text);
+ assert!(!sanitized.contains("[email protected]"), "email 1 should be redacted");
+ assert!(!sanitized.contains("[email protected]"), "email 2 should be redacted");
+ assert!(sanitized.contains("[EMAIL]"), "emails should be replaced with [EMAIL]");
+ }
+
+ #[test]
+ fn test_pii_removal_credit_card() {
+ let text = "Card: 4111-1111-1111-1111 expires 12/25";
+ let sanitized = remove_pii(text);
+ assert!(!sanitized.contains("4111-1111-1111-1111"), "credit card should be redacted");
+ }
+
+ #[test]
+ fn test_pii_removal_disabled() {
+ // When use_pii_removal is false, text should pass through unchanged
+ let text = "[email protected]";
+ let sanitized_text: Option<String> = Some(text).map(|t| t.to_string());
+ assert_eq!(sanitized_text.as_deref(), Some("[email protected]"));
+ }
}
diff --git a/crates/screenpipe-server/src/recording_config.rs b/crates/screenpipe-server/src/recording_config.rs
index 51712fb89..19930816f 100644
--- a/crates/screenpipe-server/src/recording_config.rs
+++ b/crates/screenpipe-server/src/recording_config.rs
@@ -69,7 +69,6 @@ pub struct RecordingConfig {
impl RecordingConfig {
/// Build a `UiRecorderConfig` from this recording config.
- #[cfg(feature = "ui-events")]
pub fn to_ui_recorder_config(&self) -> crate::ui_recorder::UiRecorderConfig {
crate::ui_recorder::UiRecorderConfig {
enabled: self.enable_input_capture || self.enable_accessibility,
@@ -82,11 +81,6 @@ impl RecordingConfig {
}
}
- #[cfg(not(feature = "ui-events"))]
- pub fn to_ui_recorder_config(&self) -> crate::ui_recorder::UiRecorderConfig {
- crate::ui_recorder::UiRecorderConfig { enabled: false }
- }
-
/// Build an `AudioManagerBuilder` pre-configured from this config.
/// The caller can chain additional builder methods (e.g. `.realtime()`, `.meeting_detector()`)
/// before calling `.build(db)`.
@@ -120,6 +114,7 @@ impl RecordingConfig {
ignored_windows: self.ignored_windows.clone(),
included_windows: self.included_windows.clone(),
vision_metrics,
+ use_pii_removal: self.use_pii_removal,
}
}
}
diff --git a/crates/screenpipe-server/src/ui_recorder.rs b/crates/screenpipe-server/src/ui_recorder.rs
index 1158a6584..79d904f2b 100644
--- a/crates/screenpipe-server/src/ui_recorder.rs
+++ b/crates/screenpipe-server/src/ui_recorder.rs
@@ -6,33 +6,22 @@
//!
//! Integrates screenpipe-accessibility capture with the server's recording loop.
-#[cfg(feature = "ui-events")]
use anyhow::Result;
-#[cfg(feature = "ui-events")]
use screenpipe_accessibility::tree::{
cache::TreeCache, create_tree_walker, TreeWalkerConfig, TruncationReason,
};
-#[cfg(feature = "ui-events")]
use screenpipe_accessibility::{UiCaptureConfig, UiRecorder};
-#[cfg(feature = "ui-events")]
use screenpipe_db::{DatabaseManager, InsertUiEvent};
-#[cfg(feature = "ui-events")]
use std::sync::atomic::{AtomicBool, Ordering};
-#[cfg(feature = "ui-events")]
use std::sync::{Arc, Condvar, Mutex};
-#[cfg(feature = "ui-events")]
use std::time::Duration;
-#[cfg(feature = "ui-events")]
use tracing::{debug, error, info, warn};
-#[cfg(feature = "ui-events")]
use uuid::Uuid;
/// Shared signal to wake the tree walker thread immediately on app/window switch.
-#[cfg(feature = "ui-events")]
type WakeSignal = Arc<(Mutex<bool>, Condvar)>;
/// Configuration for UI event capture
-#[cfg(feature = "ui-events")]
#[derive(Debug, Clone)]
pub struct UiRecorderConfig {
/// Enable UI event capture
@@ -77,7 +66,6 @@ pub struct UiRecorderConfig {
pub record_input_events: bool,
}
-#[cfg(feature = "ui-events")]
impl Default for UiRecorderConfig {
fn default() -> Self {
Self {
@@ -105,7 +93,6 @@ impl Default for UiRecorderConfig {
}
}
-#[cfg(feature = "ui-events")]
impl UiRecorderConfig {
/// Convert to screenpipe-ui config
pub fn to_ui_config(&self) -> UiCaptureConfig {
@@ -172,14 +159,12 @@ pub fn tree_walker_snapshot() -> TreeWalkerSnapshot {
}
/// Handle for managing the UI recorder
-#[cfg(feature = "ui-events")]
pub struct UiRecorderHandle {
stop_flag: Arc<AtomicBool>,
task_handle: Option<tokio::task::JoinHandle<()>>,
tree_walker_handle: Option<tokio::task::JoinHandle<()>>,
}
-#[cfg(feature = "ui-events")]
impl UiRecorderHandle {
/// Stop the UI recorder
pub fn stop(&self) {
@@ -206,7 +191,6 @@ impl UiRecorderHandle {
///
/// If `capture_trigger_tx` is provided, relevant UI events (app switch, window focus,
/// click, clipboard) will also be sent as capture triggers for event-driven capture.
-#[cfg(feature = "ui-events")]
pub async fn start_ui_recording(
db: Arc<DatabaseManager>,
config: UiRecorderConfig,
@@ -452,7 +436,6 @@ pub async fn start_ui_recording(
}
/// Metrics for the tree walker — logged periodically for quantified measurement.
-#[cfg(feature = "ui-events")]
struct TreeWalkerMetrics {
walks_total: u64,
walks_stored: u64,
@@ -471,7 +454,6 @@ struct TreeWalkerMetrics {
last_report: std::time::Instant,
}
-#[cfg(feature = "ui-events")]
impl TreeWalkerMetrics {
fn new() -> Self {
Self {
@@ -534,17 +516,14 @@ impl TreeWalkerMetrics {
}
/// Minimum interval between walks to prevent storms during rapid app switching.
-#[cfg(feature = "ui-events")]
const MIN_WALK_COOLDOWN: Duration = Duration::from_millis(500);
/// Delay after wake signal to let the new window settle before walking.
-#[cfg(feature = "ui-events")]
const WAKE_SETTLE_DELAY: Duration = Duration::from_millis(300);
/// Run the accessibility tree walker loop (blocking — runs in a dedicated thread).
/// Walks the focused window's AX tree periodically and stores text in the accessibility table.
/// Wakes immediately on app/window switch via the condvar signal, with a 500ms cooldown.
-#[cfg(feature = "ui-events")]
fn run_tree_walker(
db: Arc<DatabaseManager>,
stop: Arc<AtomicBool>,
@@ -667,7 +646,6 @@ fn run_tree_walker(
info!("AX tree walker stopped");
}
-#[cfg(feature = "ui-events")]
async fn flush_batch(
db: &Arc<DatabaseManager>,
batch: &mut Vec<InsertUiEvent>,
@@ -697,39 +675,3 @@ async fn flush_batch(
}
batch.clear();
}
-
-// Stub implementations when ui-events feature is disabled
-#[cfg(not(feature = "ui-events"))]
-pub struct UiRecorderConfig {
- pub enabled: bool,
-}
-
-#[cfg(not(feature = "ui-events"))]
-impl Default for UiRecorderConfig {
- fn default() -> Self {
- Self { enabled: false }
- }
-}
-
-#[cfg(not(feature = "ui-events"))]
-pub struct UiRecorderHandle;
-
-#[cfg(not(feature = "ui-events"))]
-impl UiRecorderHandle {
- pub fn stop(&self) {}
- pub fn is_running(&self) -> bool {
- false
- }
- pub async fn join(self) {}
-}
-
-#[cfg(not(feature = "ui-events"))]
-pub async fn start_ui_recording(
- _db: std::sync::Arc<screenpipe_db::DatabaseManager>,
- _config: UiRecorderConfig,
- _capture_trigger_tx: Option<
- tokio::sync::broadcast::Sender<crate::event_driven_capture::CaptureTrigger>,
- >,
-) -> anyhow::Result<UiRecorderHandle> {
- Ok(UiRecorderHandle)
-}
diff --git a/crates/screenpipe-server/src/vision_manager/manager.rs b/crates/screenpipe-server/src/vision_manager/manager.rs
index b9efda00f..d961b779d 100644
--- a/crates/screenpipe-server/src/vision_manager/manager.rs
+++ b/crates/screenpipe-server/src/vision_manager/manager.rs
@@ -26,6 +26,7 @@ pub struct VisionManagerConfig {
pub ignored_windows: Vec<String>,
pub included_windows: Vec<String>,
pub vision_metrics: Arc<PipelineMetrics>,
+ pub use_pii_removal: bool,
}
/// Status of the VisionManager
@@ -176,7 +177,6 @@ impl VisionManager {
}
/// Start event-driven capture for a specific monitor.
- #[cfg(feature = "ui-events")]
async fn start_event_driven_monitor(
&self,
monitor_id: u32,
@@ -215,6 +215,7 @@ impl VisionManager {
let monitor = Arc::new(monitor);
let vision_metrics = self.config.vision_metrics.clone();
let hot_frame_cache = self.hot_frame_cache.clone();
+ let use_pii_removal = self.config.use_pii_removal;
info!(
"Starting event-driven capture for monitor {} (device: {})",
@@ -237,6 +238,7 @@ impl VisionManager {
stop_signal,
vision_metrics,
hot_frame_cache,
+ use_pii_removal,
)
.await
{
@@ -251,19 +253,6 @@ impl VisionManager {
Ok(handle)
}
- /// Fallback for when ui-events feature is disabled.
- #[cfg(not(feature = "ui-events"))]
- async fn start_event_driven_monitor(
- &self,
- monitor_id: u32,
- _monitor: screenpipe_vision::monitor::SafeMonitor,
- ) -> Result<JoinHandle<()>> {
- anyhow::bail!(
- "Event-driven capture requires the 'ui-events' feature (monitor {})",
- monitor_id
- )
- }
-
/// Stop recording on a specific monitor
pub async fn stop_monitor(&self, monitor_id: u32) -> Result<()> {
if let Some((_, handle)) = self.recording_tasks.remove(&monitor_id) {
diff --git a/crates/screenpipe-vision/Cargo.toml b/crates/screenpipe-vision/Cargo.toml
index 9e1f1d212..11da96b3c 100644
--- a/crates/screenpipe-vision/Cargo.toml
+++ b/crates/screenpipe-vision/Cargo.toml
@@ -12,13 +12,9 @@ edition = { workspace = true }
[features]
default = []
-# Adaptive FPS based on input activity (requires screenpipe-accessibility)
-# Only supported on macOS and Windows
-adaptive-fps = ["screenpipe-accessibility"]
[dependencies]
-# Activity feed for adaptive FPS (optional, macOS/Windows only)
-screenpipe-accessibility = { path = "../screenpipe-accessibility", optional = true }
+screenpipe-accessibility = { path = "../screenpipe-accessibility" }
serde_json = "1.0"
chrono = { version = "0.4.31", features = ["serde"] }
diff --git a/crates/screenpipe-vision/src/core.rs b/crates/screenpipe-vision/src/core.rs
index ab63ca312..e4d079445 100644
--- a/crates/screenpipe-vision/src/core.rs
+++ b/crates/screenpipe-vision/src/core.rs
@@ -148,13 +148,9 @@ impl std::fmt::Display for ContinuousCaptureError {
}
}
-/// Activity feed for adaptive FPS (optional, from screenpipe-accessibility)
-#[cfg(feature = "adaptive-fps")]
+/// Activity feed for adaptive FPS (from screenpipe-accessibility)
pub type ActivityFeedOption = Option<screenpipe_accessibility::ActivityFeed>;
-#[cfg(not(feature = "adaptive-fps"))]
-pub type ActivityFeedOption = Option<()>;
-
pub async fn continuous_capture(
result_tx: Sender<RawCaptureResult>,
interval: Duration,
@@ -181,7 +177,6 @@ pub async fn continuous_capture(
let max_skip_duration = Duration::from_secs(10);
let mut last_capture_time = Instant::now();
- #[cfg(feature = "adaptive-fps")]
if activity_feed.is_some() {
debug!("Adaptive FPS enabled - will adjust capture rate based on input activity");
}
@@ -202,10 +197,6 @@ pub async fn continuous_capture(
const MAX_CAPTURE_RETRIES: u32 = 3;
const MAX_CONSECUTIVE_FAILURES: u32 = 30;
- // Suppress unused variable warning when feature is disabled
- #[cfg(not(feature = "adaptive-fps"))]
- let _ = activity_feed;
-
loop {
// 3. Capture monitor screenshot and wall-clock time atomically.
// Window capture is deferred until after frame comparison to skip
@@ -282,13 +273,10 @@ pub async fn continuous_capture(
let current_diff = frame_comparer.compare(&image);
// Get skip threshold from adaptive FPS or use default
- #[cfg(feature = "adaptive-fps")]
let skip_threshold = activity_feed
.as_ref()
.map(|f| f.get_capture_params().skip_threshold)
.unwrap_or(0.02);
- #[cfg(not(feature = "adaptive-fps"))]
- let skip_threshold = 0.02;
let time_since_last = last_capture_time.elapsed();
let force_capture = time_since_last >= max_skip_duration;
@@ -311,13 +299,10 @@ pub async fn continuous_capture(
);
frame_counter += 1;
// Use adaptive interval if enabled, otherwise use base interval
- #[cfg(feature = "adaptive-fps")]
let sleep_interval = activity_feed
.as_ref()
.map(|f| f.get_capture_params().interval)
.unwrap_or(interval);
- #[cfg(not(feature = "adaptive-fps"))]
- let sleep_interval = interval;
tokio::time::sleep(sleep_interval).await;
continue;
}
@@ -361,13 +346,10 @@ pub async fn continuous_capture(
frame_counter += 1;
// Use adaptive interval if enabled, otherwise use base interval
- #[cfg(feature = "adaptive-fps")]
let sleep_interval = activity_feed
.as_ref()
.map(|f| f.get_capture_params().interval)
.unwrap_or(interval);
- #[cfg(not(feature = "adaptive-fps"))]
- let sleep_interval = interval;
tokio::time::sleep(sleep_interval).await;
}
}