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 build

Louis Beaumont739068c9b358
diff --git a/Cargo.toml b/Cargo.toml
index f6a93f068..b6097d861 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@ resolver = "2"
[workspace.package]
-version = "0.2.46"
+version = "0.2.47"
authors = ["louis030195 <[email protected]>"]
description = ""
repository = "https://github.com/mediar-ai/screenpipe"
diff --git a/screenpipe-vision/src/capture_screenshot_by_window.rs b/screenpipe-vision/src/capture_screenshot_by_window.rs
index 183f0f0b8..2c01376dd 100644
--- a/screenpipe-vision/src/capture_screenshot_by_window.rs
+++ b/screenpipe-vision/src/capture_screenshot_by_window.rs
@@ -195,26 +195,36 @@ pub async fn capture_all_visible_windows(
) -> Result<Vec<CapturedWindow>, Box<dyn Error>> {
let mut all_captured_images = Vec::new();
- // Execute the window capture on the current thread
- let windows = tokio::task::spawn_blocking(Window::all).await??;
+ // Get windows and immediately extract the data we need
+ let windows_data = tokio::task::spawn_blocking(|| {
+ Window::all().map(|windows| {
+ windows
+ .into_iter()
+ .map(|window| {
+ (
+ window.app_name().to_string(),
+ window.title().to_string(),
+ window.is_focused(),
+ window,
+ )
+ })
+ .collect::<Vec<_>>()
+ })
+ })
+ .await??;
- if windows.is_empty() {
+ if windows_data.is_empty() {
return Err(Box::new(CaptureError::NoWindows));
}
- for window in windows {
+ for (app_name, window_name, is_focused, window) in windows_data {
let is_valid = is_valid_window(&window, monitor, window_filters, capture_unfocused_windows);
if !is_valid {
continue;
}
- // Store these before moving window
- let app_name = window.app_name().to_string();
- let window_name = window.title().to_string();
- let is_focused = window.is_focused();
-
- // Now we can move window
+ // Capture image in blocking context
match tokio::task::spawn_blocking(move || window.capture_image()).await? {
Ok(buffer) => {
let image = DynamicImage::ImageRgba8(