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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: stop SCK stream thrashing from transient window ID changes
Louis Beaumonte7e6699bb7f8
diff --git a/Cargo.lock b/Cargo.lockindex 718197671..b55a7bdac 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -225,7 +225,7 @@ version = "1.1.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"dependencies = [- "windows-sys 0.61.2",+ "windows-sys 0.60.2",][[package]]@@ -236,7 +236,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"dependencies = ["anstyle","once_cell_polyfill",- "windows-sys 0.61.2",+ "windows-sys 0.60.2",][[package]]@@ -1170,7 +1170,7 @@ dependencies = [[[package]]name = "cidre"version = "0.15.0"-source = "git+https://github.com/yury/cidre.git#34638ae16c5226d3c349953fcdd46533e3379a17"+source = "git+https://github.com/yury/cidre.git#61e5e77ed1b33ff9a8758626b6266b8509df5506"dependencies = ["cc","cidre-macros 0.5.0",@@ -2015,7 +2015,7 @@ dependencies = ["libc","option-ext","redox_users 0.5.2",- "windows-sys 0.61.2",+ "windows-sys 0.59.0",][[package]]@@ -2305,7 +2305,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"dependencies = ["libc",- "windows-sys 0.61.2",+ "windows-sys 0.52.0",][[package]]@@ -3287,7 +3287,7 @@ dependencies = ["hyper","libc","pin-project-lite",- "socket2 0.6.3",+ "socket2 0.5.10","tokio","tower-service","tracing",@@ -3637,7 +3637,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"dependencies = ["hermit-abi","libc",- "windows-sys 0.61.2",+ "windows-sys 0.52.0",][[package]]@@ -4596,7 +4596,7 @@ version = "0.50.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"dependencies = [- "windows-sys 0.61.2",+ "windows-sys 0.59.0",][[package]]@@ -5846,7 +5846,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d"dependencies = ["anyhow",- "itertools 0.14.0",+ "itertools 0.10.5","proc-macro2","quote","syn 2.0.117",@@ -5923,7 +5923,7 @@ dependencies = ["quinn-udp","rustc-hash 2.1.2","rustls 0.23.37",- "socket2 0.6.3",+ "socket2 0.5.10","thiserror 2.0.18","tokio","tracing",@@ -5960,7 +5960,7 @@ dependencies = ["cfg_aliases","libc","once_cell",- "socket2 0.6.3",+ "socket2 0.5.10","tracing","windows-sys 0.60.2",]@@ -6561,7 +6561,7 @@ dependencies = ["errno","libc","linux-raw-sys 0.12.1",- "windows-sys 0.61.2",+ "windows-sys 0.52.0",][[package]]@@ -6747,7 +6747,7 @@ dependencies = [[[package]]name = "sck-rs"version = "0.1.0"-source = "git+https://github.com/screenpipe/sck-rs#8151b16b705f91716ed8c10c54fb42c94fce9b8d"+source = "git+https://github.com/screenpipe/sck-rs#33aba937686f79b8c5b7301f698cbd1427ba53d4"dependencies = ["cidre 0.15.0","image",@@ -7625,7 +7625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"dependencies = ["libc",- "windows-sys 0.61.2",+ "windows-sys 0.60.2",][[package]]@@ -8340,7 +8340,7 @@ dependencies = ["getrandom 0.4.2","once_cell","rustix 1.1.4",- "windows-sys 0.61.2",+ "windows-sys 0.52.0",][[package]]@@ -8951,7 +8951,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"dependencies = ["memoffset","tempfile",- "windows-sys 0.61.2",+ "windows-sys 0.60.2",][[package]]@@ -9616,7 +9616,7 @@ version = "0.1.11"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"dependencies = [- "windows-sys 0.61.2",+ "windows-sys 0.48.0",][[package]]diff --git a/crates/screenpipe-engine/src/event_driven_capture.rs b/crates/screenpipe-engine/src/event_driven_capture.rsindex 596d7d2a2..53466ecc7 100644--- a/crates/screenpipe-engine/src/event_driven_capture.rs+++ b/crates/screenpipe-engine/src/event_driven_capture.rs@@ -345,6 +345,11 @@ pub async fn event_driven_capture_loop();}+ // Cache sorted excluded SCK window IDs to avoid recreating the persistent+ // SCK stream every time a transient window (tooltip, popup, badge) appears+ // or disappears. Only update when the sorted set actually changes.+ let mut cached_excluded_ids: Vec<u32> = Vec::new();+loop {if stop_signal.load(Ordering::Relaxed) {info!("event-driven capture stopping for monitor {}", monitor_id);@@ -456,9 +461,14 @@ pub async fn event_driven_capture_loop(&capture_params.tree_walker_config.included_windows,&[],);- let vc_excluded = get_excluded_sck_window_ids(&vc_filters);+ let mut fresh_ids = get_excluded_sck_window_ids(&vc_filters);+ fresh_ids.sort_unstable();+ fresh_ids.dedup();+ if fresh_ids != cached_excluded_ids {+ cached_excluded_ids = fresh_ids;+ }if let Some(ref mut comparer) = frame_comparer {- match capture_monitor_image(&monitor, &vc_excluded).await {+ match capture_monitor_image(&monitor, &cached_excluded_ids).await {Ok((image, _dur)) => {let diff = comparer.compare(&image);if diff > visual_change_threshold {@@ -794,12 +804,16 @@ async fn do_capture(// Resolve ignored windows to SCK window IDs so ScreenCaptureKit// excludes them from the capture buffer (zero overhead, pixel-perfect).+ // Sort + dedup so the persistent stream isn't needlessly recreated when+ // transient windows (tooltips, popups) cause ordering changes.let window_filters = WindowFilters::new(¶ms.tree_walker_config.ignored_windows,¶ms.tree_walker_config.included_windows,&[],);- let excluded_ids = get_excluded_sck_window_ids(&window_filters);+ let mut excluded_ids = get_excluded_sck_window_ids(&window_filters);+ excluded_ids.sort_unstable();+ excluded_ids.dedup();// Take screenshot (with ignored windows excluded at the OS level)let (image, capture_dur) = capture_monitor_image(params.monitor, &excluded_ids).await?;