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 capture exclusions search and updates

Louis Beaumontba4f01c9ffa8
diff --git a/apps/screenpipe-app-tauri/components/rewind/search-modal.tsx b/apps/screenpipe-app-tauri/components/rewind/search-modal.tsx
index 5b9a1eae1..0c2b10729 100644
--- a/apps/screenpipe-app-tauri/components/rewind/search-modal.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/search-modal.tsx
@@ -138,6 +138,20 @@ const CHAT_BUCKET_LABELS: Record<string, string> = {
};
const CHAT_BUCKET_ORDER = ["today", "yesterday", "week", "older"] as const;
+function sanitizeFts5Query(query: string): string {
+ return query
+ .split(/\s+/)
+ .filter(Boolean)
+ .map((token) => token.replace(/[\\"]/g, "").trim())
+ .filter(Boolean)
+ .map((token) => `"${token}"`)
+ .join(" ");
+}
+
+function escapeSqlString(value: string): string {
+ return value.replace(/'/g, "''");
+}
+
function useSuggestions(isOpen: boolean) {
const [suggestions, setSuggestions] = useState<string[]>([]);
const [isLoading, setIsLoading] = useState(false);
@@ -569,8 +583,15 @@ export function SearchModal({ isOpen, onClose, onNavigateToTimestamp, embedded =
setFacetsLoading(true);
let pending = 3;
const onFacetDone = () => { pending--; if (pending === 0 && !cancelled) setFacetsLoading(false); };
- const escaped = q.replace(/"/g, '""');
- const ftsQuery = q.split(/\s+/).map(w => `"${w.replace(/"/g, '""')}"`).join(" OR ");
+ const ftsQuery = sanitizeFts5Query(q);
+ if (!ftsQuery) {
+ setFacetApps([]);
+ setFacetDomains([]);
+ setFacetTimeRanges([]);
+ setFacetsLoading(false);
+ return;
+ }
+ const escapedFtsQuery = escapeSqlString(ftsQuery);
// Fire all three facet queries in parallel
const fetchFacet = async (sql: string) => {
@@ -587,7 +608,7 @@ export function SearchModal({ isOpen, onClose, onNavigateToTimestamp, embedded =
fetchFacet(
`SELECT app_name as app, COUNT(*) as cnt
FROM frames_fts
- WHERE frames_fts MATCH '${escaped}'
+ WHERE frames_fts MATCH '${escapedFtsQuery}'
AND app_name != ''
GROUP BY app_name ORDER BY cnt DESC LIMIT 15`
).then((rows: { app: string; cnt: number }[]) => {
@@ -600,7 +621,7 @@ export function SearchModal({ isOpen, onClose, onNavigateToTimestamp, embedded =
`SELECT f.browser_url as url, COUNT(*) as cnt
FROM frames_fts
JOIN frames f ON f.id = frames_fts.rowid
- WHERE frames_fts MATCH '${escaped}'
+ WHERE frames_fts MATCH '${escapedFtsQuery}'
AND f.browser_url IS NOT NULL AND f.browser_url != ''
GROUP BY f.browser_url ORDER BY cnt DESC LIMIT 200`
).then((rows: { url: string; cnt: number }[]) => {
@@ -621,7 +642,7 @@ export function SearchModal({ isOpen, onClose, onNavigateToTimestamp, embedded =
`SELECT DATE(f.timestamp) as d, MIN(f.timestamp) as ts, COUNT(*) as cnt
FROM frames_fts
JOIN frames f ON f.id = frames_fts.rowid
- WHERE frames_fts MATCH '${escaped}'
+ WHERE frames_fts MATCH '${escapedFtsQuery}'
GROUP BY DATE(f.timestamp)
ORDER BY d DESC LIMIT 30`
).then((rows: { d: string; ts: string; cnt: number }[]) => {
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs b/apps/screenpipe-app-tauri/src-tauri/src/tray.rs
index 60caca2ab..b177b596a 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/tray.rs
@@ -945,8 +945,15 @@ fn handle_menu_event(app_handle: &AppHandle, event: tauri::menu::MenuEvent) {
});
});
} else {
- // For production builds, emit event to trigger update
- let _ = app.emit("update-now-clicked", ());
+ // For production builds, run the authenticated update flow.
+ tauri::async_runtime::spawn(async move {
+ let state = app.state::<std::sync::Arc<crate::updates::UpdatesManager>>();
+ if state.has_update_installed().await {
+ let _ = app.emit("update-now-clicked", ());
+ } else if let Err(e) = state.check_for_updates(true).await {
+ tracing::error!("tray menu: check for updates failed: {}", e);
+ }
+ });
}
});
}
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs b/apps/screenpipe-app-tauri/src-tauri/src/updates.rs
index e55f39054..442a893d9 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/updates.rs
@@ -251,17 +251,15 @@ impl UpdatesManager {
if let Ok(Some(update)) = check_result {
*self.update_available.lock().await = true;
- // Emit "update-downloading" immediately so user sees feedback
- let download_info = serde_json::json!({
- "version": update.version,
- "body": update.body.clone().unwrap_or_default(),
- "stage": "downloading",
- });
- let _ = self.app.emit("update-downloading", download_info);
+ let auto_update = SettingsStore::get(&self.app)
+ .ok()
+ .flatten()
+ .map(|s| s.auto_update)
+ .unwrap_or(true);
if let Some(ref item) = self.update_menu_item {
- item.set_enabled(false)?;
- item.set_text("Downloading latest version of screenpipe")?;
+ item.set_enabled(true)?;
+ item.set_text(&format!("Update available: v{}", update.version))?;
}
{
@@ -294,96 +292,145 @@ impl UpdatesManager {
});
}
- // Download and install on all platforms
+ let should_download_now = if show_dialog {
+ let (tx, rx) = oneshot::channel();
+ let update_dialog = self
+ .app
+ .dialog()
+ .message("update available")
+ .title("screenpipe update")
+ .buttons(MessageDialogButtons::OkCancelCustom(
+ "update now".to_string(),
+ "later".to_string(),
+ ));
+
+ update_dialog.show(move |answer| {
+ let _ = tx.send(answer);
+ });
+
+ rx.await?
+ } else {
+ auto_update
+ };
+
+ if !should_download_now {
+ let app_notif = self.app.clone();
+ let version_str = update.version.clone();
+ // std::thread::spawn (not spawn_blocking) to escape tokio runtime context entirely.
+ // notify_rust on Linux internally calls block_on for D-Bus, which panics
+ // if any tokio runtime exists on the current thread — even blocking threads.
+ std::thread::spawn(move || {
+ if let Err(e) = app_notif
+ .notification()
+ .builder()
+ .title("screenpipe update available")
+ .body(format!(
+ "v{} is ready — update when you choose",
+ version_str
+ ))
+ .show()
+ {
+ error!("failed to send update notification: {}", e);
+ }
+ });
+ return Result::Ok(true);
+ }
+
+ // Emit "update-downloading" only when we are actually downloading.
+ let download_info = serde_json::json!({
+ "version": update.version,
+ "body": update.body.clone().unwrap_or_default(),
+ "stage": "downloading",
+ });
+ let _ = self.app.emit("update-downloading", download_info);
+
+ if let Some(ref item) = self.update_menu_item {
+ item.set_enabled(false)?;
+ item.set_text("Downloading latest version of screenpipe")?;
+ }
+
+ #[cfg(target_os = "windows")]
{
- #[cfg(target_os = "windows")]
+ // Windows: stop screenpipe before replacing the binary
+ if let Err(err) =
+ stop_screenpipe(self.app.state::<RecordingState>(), self.app.clone()).await
{
- // Windows: stop screenpipe before replacing the binary
- if let Err(err) =
- stop_screenpipe(self.app.state::<RecordingState>(), self.app.clone()).await
- {
- error!("Failed to stop recording before update: {}", err);
+ error!("Failed to stop recording before update: {}", err);
+ }
+ }
+
+ let app_handle = self.app.clone();
+ let update_version = update.version.clone();
+ let menu_item = self.update_menu_item.clone();
+ let mut downloaded: u64 = 0;
+ let mut last_pct: u8 = 0;
+ let download_result = update
+ .download_and_install(
+ move |chunk_len, content_len| {
+ downloaded += chunk_len as u64;
+ let pct = content_len
+ .map(|total| ((downloaded as f64 / total as f64) * 100.0) as u8)
+ .unwrap_or(0);
+ // Only emit every 5% to avoid flooding
+ if pct >= last_pct + 5 || pct == 100 {
+ last_pct = pct;
+ let progress = serde_json::json!({
+ "version": update_version,
+ "downloaded": downloaded,
+ "total": content_len,
+ "percent": pct,
+ });
+ let _ = app_handle.emit("update-download-progress", progress);
+ info!("update download: {}%", pct);
+ }
+ if let Some(ref m) = menu_item {
+ let _ = m.set_text(&format!("Downloading update... {}%", pct));
+ }
+ },
+ || {},
+ )
+ .await;
+
+ match download_result {
+ Ok(_) => {
+ *self.update_installed.lock().await = true;
+ if let Some(ref item) = self.update_menu_item {
+ item.set_enabled(true)?;
+ item.set_text("Restart to update")?;
}
}
- let app_handle = self.app.clone();
- let update_version = update.version.clone();
- let menu_item = self.update_menu_item.clone();
- let mut downloaded: u64 = 0;
- let mut last_pct: u8 = 0;
- let download_result = update
- .download_and_install(
- move |chunk_len, content_len| {
- downloaded += chunk_len as u64;
- let pct = content_len
- .map(|total| ((downloaded as f64 / total as f64) * 100.0) as u8)
- .unwrap_or(0);
- // Only emit every 5% to avoid flooding
- if pct >= last_pct + 5 || pct == 100 {
- last_pct = pct;
- let progress = serde_json::json!({
- "version": update_version,
- "downloaded": downloaded,
- "total": content_len,
- "percent": pct,
- });
- let _ = app_handle.emit("update-download-progress", progress);
- info!("update download: {}%", pct);
- }
- if let Some(ref m) = menu_item {
- let _ = m.set_text(&format!("Downloading update... {}%", pct));
- }
- },
- || {},
- )
- .await;
-
- match download_result {
- Ok(_) => {
- *self.update_installed.lock().await = true;
+ Err(e) => {
+ let err_str = e.to_string();
+ if err_str.contains("401")
+ || err_str.contains("403")
+ || err_str.contains("Unauthorized")
+ || err_str.contains("Forbidden")
+ {
+ warn!("update download requires authentication: {}", err_str);
+ let _ = self.app.emit(
+ "update-auth-required",
+ serde_json::json!({
+ "version": update.version,
+ "message": "sign in to get the latest update",
+ }),
+ );
+ let app_notif = self.app.clone();
+ let version_str = update.version.clone();
+ std::thread::spawn(move || {
+ let _ = app_notif
+ .notification()
+ .builder()
+ .title("screenpipe update available")
+ .body(format!("v{} is ready — sign in to download", version_str))
+ .show();
+ });
if let Some(ref item) = self.update_menu_item {
item.set_enabled(true)?;
- item.set_text("Restart to update")?;
- }
- }
- Err(e) => {
- let err_str = e.to_string();
- if err_str.contains("401")
- || err_str.contains("403")
- || err_str.contains("Unauthorized")
- || err_str.contains("Forbidden")
- {
- warn!("update download requires authentication: {}", err_str);
- let _ = self.app.emit(
- "update-auth-required",
- serde_json::json!({
- "version": update.version,
- "message": "sign in to get the latest update",
- }),
- );
- let app_notif = self.app.clone();
- let version_str = update.version.clone();
- // std::thread::spawn (not spawn_blocking) to escape tokio runtime context entirely.
- // notify_rust on Linux internally calls block_on for D-Bus, which panics
- // if any tokio runtime exists on the current thread — even blocking threads.
- let _ = std::thread::spawn(move || {
- let _ = app_notif
- .notification()
- .builder()
- .title("screenpipe update available")
- .body(format!(
- "v{} is ready — sign in to download",
- version_str
- ))
- .show();
- });
- if let Some(ref item) = self.update_menu_item {
- item.set_enabled(true)?;
- item.set_text("Sign in to update")?;
- }
- return Ok(false);
+ item.set_text("Sign in to update")?;
}
- return Err(e.into());
+ return Ok(false);
}
+ return Err(e.into());
}
}
@@ -396,53 +443,44 @@ impl UpdatesManager {
error!("Failed to emit update-available event: {}", e);
}
- // Native OS notification — visible even when window is closed
- let auto_update = SettingsStore::get(&self.app)
- .ok()
- .flatten()
- .map(|s| s.auto_update)
- .unwrap_or(true);
-
- // std::thread::spawn (not spawn_blocking) to escape tokio runtime context entirely.
- // notify_rust on Linux internally calls block_on for D-Bus, which panics
- // if any tokio runtime exists on the current thread — even blocking threads.
let app_notif = self.app.clone();
let version_str = update.version.clone();
+ let restarting_automatically = auto_update && !show_dialog;
std::thread::spawn(move || {
- if auto_update {
- if let Err(e) = app_notif
- .notification()
- .builder()
+ let notification = app_notif.notification().builder();
+ let result = if restarting_automatically {
+ notification
.title("screenpipe updating")
.body(format!("v{} downloaded — restarting now", version_str))
.show()
- {
- error!("failed to send update notification: {}", e);
- }
} else {
- if let Err(e) = app_notif
- .notification()
- .builder()
- .title("screenpipe update available")
- .body(format!(
- "v{} is ready — open screenpipe to update",
- version_str
- ))
+ notification
+ .title("screenpipe update ready")
+ .body(format!("v{} downloaded — restart to update", version_str))
.show()
- {
- error!("failed to send update notification: {}", e);
- }
+ };
+ if let Err(e) = result {
+ error!("failed to send update notification: {}", e);
}
});
- // Auto-update: if enabled and update is downloaded, restart automatically
- // This ensures users get updates even if tray icon is hidden (e.g., behind notch)
- if auto_update && *self.update_installed.lock().await {
+ if show_dialog {
+ save_pre_update_version(&self.app, update.body.clone());
+
+ #[cfg(not(target_os = "windows"))]
+ {
+ if let Err(err) =
+ stop_screenpipe(self.app.state::<RecordingState>(), self.app.clone()).await
+ {
+ error!("Failed to stop recording: {}", err);
+ }
+ }
+ self.update_screenpipe();
+ } else if auto_update && *self.update_installed.lock().await {
info!(
"auto-update enabled, restarting to apply update v{}",
update.version
);
- // Emit event so the frontend can display a countdown/warning
let _ = self.app.emit(
"update-restarting",
serde_json::json!({
@@ -450,99 +488,17 @@ impl UpdatesManager {
"delay_secs": 30,
}),
);
- // Save current version + release notes so next boot can show "what's new"
save_pre_update_version(&self.app, update.body.clone());
- // Give user 30 seconds to finish what they're doing before restarting.
- // Previous 5-second delay was too aggressive and interrupted fullscreen
- // apps (games, presentations) without adequate warning.
tokio::time::sleep(Duration::from_secs(30)).await;
if let Err(err) =
stop_screenpipe(self.app.state::<RecordingState>(), self.app.clone()).await
{
error!("Failed to stop recording before auto-update: {}", err);
}
- // Signal ExitRequested handler to allow clean exit (not prevent_exit)
QUIT_REQUESTED.store(true, Ordering::SeqCst);
self.app.restart();
}
- if show_dialog {
- let (tx, rx) = oneshot::channel();
- let update_dialog = self
- .app
- .dialog()
- .message("update available")
- .title("screenpipe update")
- .buttons(MessageDialogButtons::OkCancelCustom(
- "update now".to_string(),
- "later".to_string(),
- ));
-
- update_dialog.show(move |answer| {
- let _ = tx.send(answer);
- });
-
- if rx.await? {
- #[cfg(target_os = "windows")]
- {
- if let Some(ref item) = self.update_menu_item {
- item.set_enabled(false)?;
- item.set_text("Downloading latest version of screenpipe")?;
- }
-
- if let Err(err) =
- stop_screenpipe(self.app.state::<RecordingState>(), self.app.clone())
- .await
- {
- error!("Failed to stop recording: {}", err);
- }
-
- let menu_item_win = self.update_menu_item.clone();
- let mut dl: u64 = 0;
- let mut lp: u8 = 0;
- update
- .download_and_install(
- move |chunk_len, content_len| {
- dl += chunk_len as u64;
- let pct = content_len
- .map(|t| ((dl as f64 / t as f64) * 100.0) as u8)
- .unwrap_or(0);
- if pct >= lp + 5 || pct == 100 {
- lp = pct;
- if let Some(ref m) = menu_item_win {
- let _ = m.set_text(&format!(
- "Downloading update... {}%",
- pct
- ));
- }
- }
- },
- || {},
- )
- .await?;
- *self.update_installed.lock().await = true;
-
- if let Some(ref item) = self.update_menu_item {
- item.set_enabled(true)?;
- item.set_text("Restart to update")?;
- }
- }
- // Proceed with the update
- save_pre_update_version(&self.app, update.body.clone());
-
- #[cfg(not(target_os = "windows"))]
- {
- if let Err(err) =
- stop_screenpipe(self.app.state::<RecordingState>(), self.app.clone())
- .await
- {
- error!("Failed to stop recording: {}", err);
- }
- }
- self.update_screenpipe();
- }
- }
-
return Result::Ok(true);
}
@@ -566,6 +522,10 @@ impl UpdatesManager {
self.update_menu_item.as_ref()
}
+ pub async fn has_update_installed(&self) -> bool {
+ *self.update_installed.lock().await
+ }
+
pub fn update_screenpipe(&self) -> Option<Error> {
self.app.restart();
}
@@ -619,7 +579,7 @@ impl UpdatesManager {
// Don't show dialog for periodic checks - only for manual checks
if let Err(e) = self.check_for_updates(false).await {
// warn, not error — see updater check() note above.
- warn!("Failed to check for updates: {}", e);
+ warn!("Failed to check for updates: {}", e);
}
}
}
diff --git a/crates/screenpipe-a11y/src/config.rs b/crates/screenpipe-a11y/src/config.rs
index 075348244..78bd0998d 100644
--- a/crates/screenpipe-a11y/src/config.rs
+++ b/crates/screenpipe-a11y/src/config.rs
@@ -88,6 +88,14 @@ pub struct UiCaptureConfig {
/// Raw patterns for serialization
pub excluded_window_pattern_strings: Vec<String>,
+ /// User-configured app/window names to skip (case-insensitive substring match)
+ #[serde(default)]
+ pub ignored_windows: Vec<String>,
+
+ /// Optional user-configured allow-list for app/window names
+ #[serde(default)]
+ pub included_windows: Vec<String>,
+
// === Retention Settings ===
/// Days to keep UI events
pub retention_days: u32,
@@ -149,6 +157,8 @@ impl Default for UiCaptureConfig {
// positives on normal windows (e.g. password manager settings,
// "Secret Santa Planning", AWS Secrets Manager, etc.).
excluded_window_pattern_strings: vec![],
+ ignored_windows: Vec::new(),
+ included_windows: Vec::new(),
// Retention
retention_days: 30,
@@ -178,6 +188,18 @@ impl UiCaptureConfig {
.collect();
}
+ fn matches_user_pattern(patterns: &[String], value: &str) -> bool {
+ if value.is_empty() {
+ return false;
+ }
+
+ let value_lower = value.to_lowercase();
+ patterns.iter().any(|pattern| {
+ let pattern = pattern.trim();
+ !pattern.is_empty() && value_lower.contains(&pattern.to_lowercase())
+ })
+ }
+
/// Check if an app should be captured
pub fn should_capture_app(&self, app_name: &str) -> bool {
if !self.enabled {
@@ -185,10 +207,15 @@ impl UiCaptureConfig {
}
let app_lower = app_name.to_lowercase();
- !self
+ if self
.excluded_apps
.iter()
.any(|excluded| app_lower.contains(&excluded.to_lowercase()))
+ {
+ return false;
+ }
+
+ !Self::matches_user_pattern(&self.ignored_windows, app_name)
}
/// Check if a window should be captured
@@ -197,10 +224,37 @@ impl UiCaptureConfig {
return false;
}
- !self
+ if self
.excluded_window_patterns
.iter()
.any(|pattern| pattern.is_match(window_title))
+ {
+ return false;
+ }
+
+ !Self::matches_user_pattern(&self.ignored_windows, window_title)
+ }
+
+ /// Check a concrete app/window pair against all capture filters.
+ pub fn should_capture_target(&self, app_name: &str, window_title: Option<&str>) -> bool {
+ if !self.should_capture_app(app_name) {
+ return false;
+ }
+
+ if let Some(title) = window_title {
+ if !self.should_capture_window(title) {
+ return false;
+ }
+ }
+
+ if self.included_windows.is_empty() {
+ return true;
+ }
+
+ Self::matches_user_pattern(&self.included_windows, app_name)
+ || window_title
+ .map(|title| Self::matches_user_pattern(&self.included_windows, title))
+ .unwrap_or(false)
}
/// Check if element appears to be a password field
@@ -312,6 +366,24 @@ mod tests {
assert!(config.should_capture_window("GitHub - Chrome"));
}
+ #[test]
+ fn test_user_window_filters() {
+ let mut config = UiCaptureConfig::new();
+ config.ignored_windows = vec!["WhatsApp".to_string()];
+
+ assert!(!config.should_capture_app("WhatsApp"));
+ assert!(!config.should_capture_window("WhatsApp chat"));
+ assert!(!config.should_capture_target("WhatsApp", Some("Inbox")));
+ assert!(config.should_capture_target("Chrome", Some("Docs")));
+
+ config.ignored_windows.clear();
+ config.included_windows = vec!["Chrome".to_string(), "ScreenPipe".to_string()];
+
+ assert!(config.should_capture_target("Chrome", Some("Docs")));
+ assert!(config.should_capture_target("Terminal", Some("ScreenPipe logs")));
+ assert!(!config.should_capture_target("Slack", Some("DM")));
+ }
+
#[test]
fn test_password_field_detection() {
let config = UiCaptureConfig::new();
diff --git a/crates/screenpipe-a11y/src/platform/windows.rs b/crates/screenpipe-a11y/src/platform/windows.rs
index 39739367b..512ed8327 100644
--- a/crates/screenpipe-a11y/src/platform/windows.rs
+++ b/crates/screenpipe-a11y/src/platform/windows.rs
@@ -509,15 +509,11 @@ unsafe extern "system" fn keyboard_hook_proc(code: i32, wparam: WPARAM, lparam:
let window_title = s.current_window.lock().clone();
// Check exclusions
- if let Some(ref app) = app_name {
- if !s.config.should_capture_app(app) {
- return;
- }
- }
- if let Some(ref window) = window_title {
- if !s.config.should_capture_window(window) {
- return;
- }
+ if !s.config.should_capture_target(
+ app_name.as_deref().unwrap_or_default(),
+ window_title.as_deref(),
+ ) {
+ return;
}
// Check for clipboard operations (Ctrl+C, Ctrl+X, Ctrl+V)
@@ -634,15 +630,26 @@ unsafe extern "system" fn mouse_hook_proc(code: i32, wparam: WPARAM, lparam: LPA
let timestamp = Utc::now();
let t = s.start.elapsed().as_millis() as u64;
// Use try_lock to avoid blocking — skip if contended
- let app_name = s.current_app.try_lock().map(|g| g.clone());
- let window_title = s.current_window.try_lock().map(|g| g.clone());
+ let app_name =
+ s.current_app.try_lock().map(|g| g.clone()).unwrap_or(None);
+ let window_title = s
+ .current_window
+ .try_lock()
+ .map(|g| g.clone())
+ .unwrap_or(None);
+ if !s.config.should_capture_target(
+ app_name.as_deref().unwrap_or_default(),
+ window_title.as_deref(),
+ ) {
+ return;
+ }
let event = UiEvent {
id: None,
timestamp,
relative_ms: t,
data: EventData::Move { x, y },
- app_name: app_name.unwrap_or(None),
- window_title: window_title.unwrap_or(None),
+ app_name,
+ window_title,
browser_url: None,
element: None,
frame_id: None,
@@ -661,10 +668,11 @@ unsafe extern "system" fn mouse_hook_proc(code: i32, wparam: WPARAM, lparam: LPA
let window_title = s.current_window.lock().clone();
// Check exclusions
- if let Some(ref app) = app_name {
- if !s.config.should_capture_app(app) {
- return;
- }
+ if !s.config.should_capture_target(
+ app_name.as_deref().unwrap_or_default(),
+ window_title.as_deref(),
+ ) {
+ return;
}
match msg {
@@ -1115,23 +1123,22 @@ fn process_foreground_change(state: &mut AppObserverState) {
// Get process name
let app_name = get_process_name(pid).unwrap_or_else(|| "Unknown".to_string());
+ // Update shared state before exclusions so input hooks do not keep
+ // attributing keystrokes/clicks to the previously focused app.
+ *state.current_app.lock() = Some(app_name.clone());
+ *state.current_window.lock() = title.clone();
+
// Check exclusions
- if !state.config.should_capture_app(&app_name) {
+ if !state
+ .config
+ .should_capture_target(&app_name, title.as_deref())
+ {
+ *state.focused_element.lock() = None;
state.last_hwnd = hwnd_val;
+ state.last_title = title;
return;
}
- if let Some(ref t) = title {
- if !state.config.should_capture_window(t) {
- state.last_hwnd = hwnd_val;
- return;
- }
- }
-
- // Update shared state for event listener thread
- *state.current_app.lock() = Some(app_name.clone());
- *state.current_window.lock() = title.clone();
-
// Get focused element context from UIA thread
let element = if state.config.capture_context {
state.focused_element.lock().clone()
diff --git a/crates/screenpipe-a11y/src/platform/windows_uia.rs b/crates/screenpipe-a11y/src/platform/windows_uia.rs
index df5f8c197..b424d44e8 100644
--- a/crates/screenpipe-a11y/src/platform/windows_uia.rs
+++ b/crates/screenpipe-a11y/src/platform/windows_uia.rs
@@ -773,15 +773,11 @@ fn capture_and_send(
// Get window info
let (app_name, window_title, pid) = get_window_info(hwnd);
- // Check exclusions
- if !config.should_capture_app(&app_name) {
+ // Check exclusions before making UIA tree calls. Some apps expose slow or
+ // buggy providers, so the guard needs to happen before ElementFromHandle.
+ if !config.should_capture_target(&app_name, window_title.as_deref()) {
return;
}
- if let Some(ref title) = window_title {
- if !config.should_capture_window(title) {
- return;
- }
- }
// Capture the tree
let root = match uia.capture_window_tree(hwnd, config.tree_max_elements) {
diff --git a/crates/screenpipe-audio/src/audio_manager/manager.rs b/crates/screenpipe-audio/src/audio_manager/manager.rs
index a5d6a3368..9b4d85d4d 100644
--- a/crates/screenpipe-audio/src/audio_manager/manager.rs
+++ b/crates/screenpipe-audio/src/audio_manager/manager.rs
@@ -521,10 +521,16 @@ impl AudioManager {
async fn record_device(&self, device: &AudioDevice) -> Result<JoinHandle<Result<()>>> {
let options = self.options.read().await;
- let stream = self.device_manager.stream(device).unwrap();
+ let stream = self
+ .device_manager
+ .stream(device)
+ .ok_or_else(|| anyhow!("audio stream missing after starting device: {device}"))?;
let audio_chunk_duration = options.audio_chunk_duration;
let recording_sender = self.recording_sender.clone();
- let is_running = self.device_manager.is_running_mut(device).unwrap();
+ let is_running = self
+ .device_manager
+ .is_running_mut(device)
+ .ok_or_else(|| anyhow!("audio device state missing after starting device: {device}"))?;
let device_clone = device.clone();
let metrics = self.metrics.clone();
diff --git a/crates/screenpipe-engine/src/ui_recorder.rs b/crates/screenpipe-engine/src/ui_recorder.rs
index d37d1938c..4110e2faa 100644
--- a/crates/screenpipe-engine/src/ui_recorder.rs
+++ b/crates/screenpipe-engine/src/ui_recorder.rs
@@ -115,6 +115,9 @@ impl UiRecorderConfig {
}
}
+ config.ignored_windows = self.ignored_windows.clone();
+ config.included_windows = self.included_windows.clone();
+
config
}
}