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: cargo fmt across workspace

Louis Beaumont12910236fd96
diff --git a/crates/screenpipe-accessibility/src/events.rs b/crates/screenpipe-accessibility/src/events.rs
index 0ba993f39..2351fe90b 100644
--- a/crates/screenpipe-accessibility/src/events.rs
+++ b/crates/screenpipe-accessibility/src/events.rs
@@ -216,7 +216,12 @@ impl AccessibilityNode {
if self.children.is_empty() {
0
} else {
- 1 + self.children.iter().map(|c| c.max_depth()).max().unwrap_or(0)
+ 1 + self
+ .children
+ .iter()
+ .map(|c| c.max_depth())
+ .max()
+ .unwrap_or(0)
}
}
@@ -333,27 +338,54 @@ impl AccessibilityNode {
} else {
0
};
- self_count + self.children.iter().map(|c| c.named_node_count()).sum::<usize>()
+ self_count
+ + self
+ .children
+ .iter()
+ .map(|c| c.named_node_count())
+ .sum::<usize>()
}
/// Count interactive elements (Button, Edit, Document, ComboBox, CheckBox, RadioButton, Slider, Tab, MenuItem, Hyperlink).
pub fn interactive_count(&self) -> usize {
let interactive_types = [
- "Button", "Edit", "Document", "ComboBox", "CheckBox",
- "RadioButton", "Slider", "Tab", "TabItem", "MenuItem", "Hyperlink",
+ "Button",
+ "Edit",
+ "Document",
+ "ComboBox",
+ "CheckBox",
+ "RadioButton",
+ "Slider",
+ "Tab",
+ "TabItem",
+ "MenuItem",
+ "Hyperlink",
];
- let self_count = if interactive_types.iter().any(|t| self.control_type.eq_ignore_ascii_case(t)) {
+ let self_count = if interactive_types
+ .iter()
+ .any(|t| self.control_type.eq_ignore_ascii_case(t))
+ {
1
} else {
0
};
- self_count + self.children.iter().map(|c| c.interactive_count()).sum::<usize>()
+ self_count
+ + self
+ .children
+ .iter()
+ .map(|c| c.interactive_count())
+ .sum::<usize>()
}
/// Count nodes that have bounding rectangles.
pub fn bounds_count(&self) -> usize {
let self_count = if self.bounds.is_some() { 1 } else { 0 };
- self_count + self.children.iter().map(|c| c.bounds_count()).sum::<usize>()
+ self_count
+ + self
+ .children
+ .iter()
+ .map(|c| c.bounds_count())
+ .sum::<usize>()
}
/// Compute a hash for diffing (ignores children — diff by comparing node-by-node)
diff --git a/crates/screenpipe-accessibility/src/platform/windows.rs b/crates/screenpipe-accessibility/src/platform/windows.rs
index 2b1f43f5d..2832b60b2 100644
--- a/crates/screenpipe-accessibility/src/platform/windows.rs
+++ b/crates/screenpipe-accessibility/src/platform/windows.rs
@@ -4,7 +4,7 @@
use crate::activity_feed::{ActivityFeed, ActivityKind};
use crate::config::UiCaptureConfig;
-use crate::events::{EventData, ElementContext, UiEvent, WindowTreeSnapshot};
+use crate::events::{ElementContext, EventData, UiEvent, WindowTreeSnapshot};
use anyhow::Result;
use chrono::Utc;
use crossbeam_channel::{bounded, Receiver, Sender};
@@ -179,8 +179,15 @@ impl UiRecorder {
let focused_element1 = focused_element.clone();
threads.push(thread::spawn(move || {
run_native_hooks(
- tx1, stop1, start_time, config1, app1, window1, feed1,
- click_queue1, focused_element1,
+ tx1,
+ stop1,
+ start_time,
+ config1,
+ app1,
+ window1,
+ feed1,
+ click_queue1,
+ focused_element1,
);
}));
@@ -192,7 +199,15 @@ impl UiRecorder {
let window2 = current_window.clone();
let focused_element2 = focused_element.clone();
threads.push(thread::spawn(move || {
- run_app_observer(tx2, stop2, start_time, config2, app2, window2, focused_element2);
+ run_app_observer(
+ tx2,
+ stop2,
+ start_time,
+ config2,
+ app2,
+ window2,
+ focused_element2,
+ );
}));
// Thread 3: UI Automation worker (tree capture, element context, clipboard)
@@ -649,11 +664,9 @@ unsafe extern "system" fn mouse_hook_proc(code: i32, wparam: WPARAM, lparam: LPA
// Queue ElementFromPoint request for precise element context
if s.config.capture_context {
- s.click_queue.lock().push(ClickElementRequest {
- x,
- y,
- timestamp,
- });
+ s.click_queue
+ .lock()
+ .push(ClickElementRequest { x, y, timestamp });
}
}
diff --git a/crates/screenpipe-accessibility/src/platform/windows_uia.rs b/crates/screenpipe-accessibility/src/platform/windows_uia.rs
index 7bad6bb52..b1a55cfe9 100644
--- a/crates/screenpipe-accessibility/src/platform/windows_uia.rs
+++ b/crates/screenpipe-accessibility/src/platform/windows_uia.rs
@@ -25,13 +25,13 @@ use windows::Win32::System::Com::{
CoCreateInstance, CoInitializeEx, CoUninitialize, CLSCTX_ALL, COINIT_APARTMENTTHREADED,
};
use windows::Win32::UI::Accessibility::{
- CUIAutomation, IUIAutomation, IUIAutomationCacheRequest, IUIAutomationElement,
- IUIAutomationFocusChangedEventHandler, IUIAutomationFocusChangedEventHandler_Impl,
- IUIAutomationTreeWalker, AutomationElementMode_None, TreeScope_Subtree,
- UIA_AutomationIdPropertyId, UIA_BoundingRectanglePropertyId,
- UIA_ClassNamePropertyId, UIA_ControlTypePropertyId, UIA_HasKeyboardFocusPropertyId,
- UIA_IsEnabledPropertyId, UIA_IsKeyboardFocusablePropertyId,
- UIA_NamePropertyId, UIA_PROPERTY_ID, UIA_ValueValuePropertyId,
+ AutomationElementMode_None, CUIAutomation, IUIAutomation, IUIAutomationCacheRequest,
+ IUIAutomationElement, IUIAutomationFocusChangedEventHandler,
+ IUIAutomationFocusChangedEventHandler_Impl, IUIAutomationTreeWalker, TreeScope_Subtree,
+ UIA_AutomationIdPropertyId, UIA_BoundingRectanglePropertyId, UIA_ClassNamePropertyId,
+ UIA_ControlTypePropertyId, UIA_HasKeyboardFocusPropertyId, UIA_IsEnabledPropertyId,
+ UIA_IsKeyboardFocusablePropertyId, UIA_NamePropertyId, UIA_ValueValuePropertyId,
+ UIA_PROPERTY_ID,
};
use windows::Win32::UI::WindowsAndMessaging::{
DispatchMessageW, GetForegroundWindow, GetWindowTextW, GetWindowThreadProcessId, PeekMessageW,
@@ -63,8 +63,7 @@ impl UiaContext {
/// Initialize UI Automation COM objects. Must be called on a COM-initialized thread.
pub(crate) fn new() -> windows::core::Result<Self> {
unsafe {
- let automation: IUIAutomation =
- CoCreateInstance(&CUIAutomation, None, CLSCTX_ALL)?;
+ let automation: IUIAutomation = CoCreateInstance(&CUIAutomation, None, CLSCTX_ALL)?;
// Create cache request with all properties we need
let cache_request = automation.CreateCacheRequest()?;
@@ -233,7 +232,11 @@ impl UiaContext {
}
/// Get a cached boolean property (defaults to false on failure)
- fn get_cached_bool(&self, element: &IUIAutomationElement, property_id: UIA_PROPERTY_ID) -> bool {
+ fn get_cached_bool(
+ &self,
+ element: &IUIAutomationElement,
+ property_id: UIA_PROPERTY_ID,
+ ) -> bool {
unsafe {
element
.GetCachedPropertyValue(property_id)
@@ -303,10 +306,7 @@ impl UiaContext {
&self,
handler: &IUIAutomationFocusChangedEventHandler,
) -> windows::core::Result<()> {
- unsafe {
- self.automation
- .AddFocusChangedEventHandler(None, handler)
- }
+ unsafe { self.automation.AddFocusChangedEventHandler(None, handler) }
}
/// Unsubscribe from focus change events
@@ -314,9 +314,7 @@ impl UiaContext {
&self,
handler: &IUIAutomationFocusChangedEventHandler,
) -> windows::core::Result<()> {
- unsafe {
- self.automation.RemoveFocusChangedEventHandler(handler)
- }
+ unsafe { self.automation.RemoveFocusChangedEventHandler(handler) }
}
}
@@ -462,9 +460,7 @@ pub fn run_uia_thread(
}
// Periodic safety-net re-capture
- if config.tree_capture_interval_ms > 0
- && last_capture_time.elapsed() >= interval_dur
- {
+ if config.tree_capture_interval_ms > 0 && last_capture_time.elapsed() >= interval_dur {
let hwnd = unsafe { GetForegroundWindow() };
if !hwnd.is_invalid() {
capture_and_send(
@@ -628,10 +624,8 @@ fn get_window_info(hwnd: HWND) -> (String, Option<String>, u32) {
/// Get text content from the Windows clipboard
pub fn get_clipboard_text_impl() -> Option<String> {
use windows::Win32::Foundation::HANDLE;
- use windows::Win32::System::DataExchange::{
- CloseClipboard, GetClipboardData, OpenClipboard,
- };
use windows::Win32::Foundation::HGLOBAL;
+ use windows::Win32::System::DataExchange::{CloseClipboard, GetClipboardData, OpenClipboard};
use windows::Win32::System::Memory::{GlobalLock, GlobalUnlock};
use windows::Win32::System::Ole::CF_UNICODETEXT;
@@ -872,8 +866,7 @@ mod tests {
}
// Collect all visible windows with titles
- let windows: Arc<StdMutex<Vec<(HWND, String, u32)>>> =
- Arc::new(StdMutex::new(Vec::new()));
+ let windows: Arc<StdMutex<Vec<(HWND, String, u32)>>> = Arc::new(StdMutex::new(Vec::new()));
let windows_clone = windows.clone();
unsafe {
@@ -907,8 +900,14 @@ mod tests {
}
let windows_list = windows.lock().unwrap().clone();
- println!("\n=== Found {} visible windows with titles ===\n", windows_list.len());
- assert!(windows_list.len() >= 1, "Should find at least 1 visible window");
+ println!(
+ "\n=== Found {} visible windows with titles ===\n",
+ windows_list.len()
+ );
+ assert!(
+ windows_list.len() >= 1,
+ "Should find at least 1 visible window"
+ );
let uia = UiaContext::new().expect("UIA init failed");
@@ -965,13 +964,13 @@ mod tests {
// Verify tree integrity - node_count should be consistent
assert!(count >= 1, "Tree should have at least root node");
- assert!(
- count <= 10000,
- "Tree should not exceed max_elements cap"
- );
+ assert!(count <= 10000, "Tree should not exceed max_elements cap");
}
None => {
- println!(" [FAILED {:>4}ms] {} | {} (pid: {})", elapsed, app, title, pid);
+ println!(
+ " [FAILED {:>4}ms] {} | {} (pid: {})",
+ elapsed, app, title, pid
+ );
failed_count += 1;
}
}
@@ -983,7 +982,11 @@ mod tests {
println!("Capture failures: {}", failed_count);
println!("Total elements: {}", total_elements);
println!("Total capture time: {}ms", total_capture_ms);
- let avg = if captured_count > 0 { total_capture_ms / captured_count as u128 } else { 0 };
+ let avg = if captured_count > 0 {
+ total_capture_ms / captured_count as u128
+ } else {
+ 0
+ };
println!("Avg capture time: {}ms", avg);
println!("Max capture time: {}ms", max_capture_ms);
println!("Max elements: {} ({})", max_elements, max_elements_app);
@@ -1040,8 +1043,12 @@ mod tests {
let indent = " ".repeat(depth);
println!(
"{}{} - {:?} (id: {:?}, class: {:?}, bounds: {:?})",
- indent, node.control_type, node.name, node.automation_id,
- node.class_name, node.bounds
+ indent,
+ node.control_type,
+ node.name,
+ node.automation_id,
+ node.class_name,
+ node.bounds
);
for child in &node.children {
print_tree(child, depth + 1, max_depth);
@@ -1151,7 +1158,10 @@ mod tests {
}
if i == 0 {
- let name = root.as_ref().and_then(|r| r.name.clone()).unwrap_or_default();
+ let name = root
+ .as_ref()
+ .and_then(|r| r.name.clone())
+ .unwrap_or_default();
println!("Window: {:?}", name);
}
}
@@ -1181,7 +1191,10 @@ mod tests {
println!("Max: {:?}", max);
println!("P50: {:?}", p50);
println!("P95: {:?}", p95);
- println!("Unique hashes: {} (1 = perfectly stable)", unique_hashes.len());
+ println!(
+ "Unique hashes: {} (1 = perfectly stable)",
+ unique_hashes.len()
+ );
println!("Total time for {} captures: {:?}", iterations, total);
// Performance assertions
@@ -1251,7 +1264,10 @@ mod tests {
// Focused element should be populated
let fe = focused_element.lock();
- println!("Focused element after capture: {:?}", fe.as_ref().map(|e| &e.role));
+ println!(
+ "Focused element after capture: {:?}",
+ fe.as_ref().map(|e| &e.role)
+ );
unsafe { CoUninitialize() };
}
@@ -1292,7 +1308,10 @@ mod tests {
"Should receive initial tree snapshot within 5s"
);
let snap = snapshot.unwrap();
- println!("Initial snapshot: {} | {:?}", snap.app_name, snap.window_title);
+ println!(
+ "Initial snapshot: {} | {:?}",
+ snap.app_name, snap.window_title
+ );
println!(" Elements: {}", snap.element_count);
println!(" Hash: {}", snap.tree_hash);
assert!(snap.element_count >= 1, "Should have elements");
@@ -1344,10 +1363,8 @@ mod tests {
#[test]
#[ignore]
fn test_live_cpu_usage() {
- use windows::Win32::System::Threading::{
- GetCurrentProcess, GetProcessTimes,
- };
use windows::Win32::Foundation::FILETIME;
+ use windows::Win32::System::Threading::{GetCurrentProcess, GetProcessTimes};
fn get_process_cpu_time() -> u64 {
unsafe {
@@ -1359,8 +1376,7 @@ mod tests {
let _ = GetProcessTimes(process, &mut creation, &mut exit, &mut kernel, &mut user);
let kernel_100ns =
(kernel.dwHighDateTime as u64) << 32 | kernel.dwLowDateTime as u64;
- let user_100ns =
- (user.dwHighDateTime as u64) << 32 | user.dwLowDateTime as u64;
+ let user_100ns = (user.dwHighDateTime as u64) << 32 | user.dwLowDateTime as u64;
kernel_100ns + user_100ns
}
}
@@ -1452,8 +1468,7 @@ mod tests {
}
// Find all visible windows
- let windows: Arc<StdMutex<Vec<(HWND, String, u32)>>> =
- Arc::new(StdMutex::new(Vec::new()));
+ let windows: Arc<StdMutex<Vec<(HWND, String, u32)>>> = Arc::new(StdMutex::new(Vec::new()));
let windows_clone = windows.clone();
unsafe extern "system" fn enum_cb(hwnd: HWND, lparam: LPARAM) -> BOOL {
@@ -1482,10 +1497,7 @@ mod tests {
}
unsafe {
- let _ = EnumWindows(
- Some(enum_cb),
- LPARAM(Arc::as_ptr(&windows_clone) as isize),
- );
+ let _ = EnumWindows(Some(enum_cb), LPARAM(Arc::as_ptr(&windows_clone) as isize));
}
let uia = UiaContext::new().expect("UIA init failed");
@@ -1525,9 +1537,7 @@ mod tests {
match node.control_type.as_str() {
"Text" | "Edit" => *text += 1,
"Button" | "Hyperlink" | "CheckBox" | "RadioButton" | "ComboBox"
- | "MenuItem" | "ListItem" | "TabItem" | "Slider" => {
- *interactive += 1
- }
+ | "MenuItem" | "ListItem" | "TabItem" | "Slider" => *interactive += 1,
_ => {}
}
// Count named nodes as content-bearing
@@ -1550,10 +1560,7 @@ mod tests {
max_depth = depth;
}
- println!(
- " {} | {} (pid: {})",
- app, title, pid
- );
+ println!(" {} | {} (pid: {})", app, title, pid);
println!(
" Elements: {}, Depth: {}, Text/Named: {}, Interactive: {}",
count, depth, text, interactive
diff --git a/crates/screenpipe-accessibility/src/platform/windows_uia_tests.rs b/crates/screenpipe-accessibility/src/platform/windows_uia_tests.rs
index 32e8e248f..b98cd6168 100644
--- a/crates/screenpipe-accessibility/src/platform/windows_uia_tests.rs
+++ b/crates/screenpipe-accessibility/src/platform/windows_uia_tests.rs
@@ -70,10 +70,7 @@ impl TestApp {
// Poll for a NEW window matching the title
loop {
if Instant::now() > deadline {
- eprintln!(
- "[TestApp] Timeout waiting for {} (pid {})",
- spec.exe, pid
- );
+ eprintln!("[TestApp] Timeout waiting for {} (pid {})", spec.exe, pid);
let mut child = child;
let _ = child.kill();
return None;
@@ -114,7 +111,11 @@ impl TestApp {
impl Drop for TestApp {
fn drop(&mut self) {
- println!("[TestApp] Closing {} (pid {})", self.name, self.process.id());
+ println!(
+ "[TestApp] Closing {} (pid {})",
+ self.name,
+ self.process.id()
+ );
let _ = self.process.kill();
let _ = self.process.wait();
// Also close the window by sending WM_CLOSE in case the process re-parented
@@ -156,10 +157,7 @@ fn list_windows_matching(pattern: &str) -> Vec<HWND> {
let mut data = (pattern_lower, results);
unsafe {
- let _ = EnumWindows(
- Some(callback),
- LPARAM(&mut data as *mut _ as isize),
- );
+ let _ = EnumWindows(Some(callback), LPARAM(&mut data as *mut _ as isize));
}
results = data.1;
results
@@ -268,8 +266,7 @@ fn get_window_title(hwnd: HWND) -> String {
#[ignore]
fn test_notepad_tree_structure() {
com_init();
- let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10))
- .expect("Failed to launch Notepad");
+ let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10)).expect("Failed to launch Notepad");
app.focus();
let uia = UiaContext::new().expect("UIA init failed");
@@ -284,8 +281,16 @@ fn test_notepad_tree_structure() {
root.print_tree(4);
// Verify tree structure
- assert!(count >= 5, "Notepad should have at least 5 elements, got {}", count);
- assert!(depth >= 2, "Notepad tree should be at least 2 deep, got {}", depth);
+ assert!(
+ count >= 5,
+ "Notepad should have at least 5 elements, got {}",
+ count
+ );
+ assert!(
+ depth >= 2,
+ "Notepad tree should be at least 2 deep, got {}",
+ depth
+ );
// Should have a menu bar
let menus = root.find_all_by_type("MenuBar");
@@ -293,8 +298,7 @@ fn test_notepad_tree_structure() {
assert!(!menus.is_empty(), "Notepad should have a MenuBar");
// Should have an edit area (RichEdit or Document or Edit)
- let has_edit = root.find_by_type("Edit").is_some()
- || root.find_by_type("Document").is_some();
+ let has_edit = root.find_by_type("Edit").is_some() || root.find_by_type("Document").is_some();
assert!(has_edit, "Notepad should have an Edit or Document control");
// Should have a title bar
@@ -305,8 +309,18 @@ fn test_notepad_tree_structure() {
// Verify some buttons exist (Minimize, Maximize, Close)
let buttons = root.find_all_by_type("Button");
- println!("Buttons: {} ({:?})", buttons.len(), buttons.iter().map(|b| b.name.as_deref().unwrap_or("?")).collect::<Vec<_>>());
- assert!(buttons.len() >= 3, "Should have at least 3 buttons (min/max/close)");
+ println!(
+ "Buttons: {} ({:?})",
+ buttons.len(),
+ buttons
+ .iter()
+ .map(|b| b.name.as_deref().unwrap_or("?"))
+ .collect::<Vec<_>>()
+ );
+ assert!(
+ buttons.len() >= 3,
+ "Should have at least 3 buttons (min/max/close)"
+ );
// Verify window name in root
assert_eq!(root.control_type, "Window");
@@ -320,8 +334,7 @@ fn test_notepad_tree_structure() {
#[ignore]
fn test_notepad_text_capture() {
com_init();
- let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10))
- .expect("Failed to launch Notepad");
+ let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10)).expect("Failed to launch Notepad");
app.focus();
let test_text = "Hello screenpipe accessibility test 12345";
@@ -364,8 +377,8 @@ fn test_notepad_text_capture() {
#[ignore]
fn test_calculator_tree_structure() {
com_init();
- let app = TestApp::launch(&CALCULATOR, Duration::from_secs(10))
- .expect("Failed to launch Calculator");
+ let app =
+ TestApp::launch(&CALCULATOR, Duration::from_secs(10)).expect("Failed to launch Calculator");
app.focus();
// Calculator takes a moment to fully render
std::thread::sleep(Duration::from_secs(1));
@@ -395,10 +408,7 @@ fn test_calculator_tree_structure() {
// Should have number buttons
let buttons = root.find_all_by_type("Button");
- let button_names: Vec<&str> = buttons
- .iter()
- .filter_map(|b| b.name.as_deref())
- .collect();
+ let button_names: Vec<&str> = buttons.iter().filter_map(|b| b.name.as_deref()).collect();
println!("Buttons ({}):", buttons.len());
for name in &button_names {
print!(" [{}]", name);
@@ -409,9 +419,11 @@ fn test_calculator_tree_structure() {
let number_buttons: Vec<&&str> = button_names
.iter()
.filter(|n| {
- ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]
- .iter()
- .any(|num| n.contains(num))
+ [
+ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
+ ]
+ .iter()
+ .any(|num| n.contains(num))
})
.collect();
println!("Number buttons found: {}", number_buttons.len());
@@ -422,8 +434,12 @@ fn test_calculator_tree_structure() {
);
// Check for operator buttons
- let has_operators = button_names.iter().any(|n| n.contains("Plus") || n.contains("Add"))
- || button_names.iter().any(|n| n.contains("Minus") || n.contains("Subtract"));
+ let has_operators = button_names
+ .iter()
+ .any(|n| n.contains("Plus") || n.contains("Add"))
+ || button_names
+ .iter()
+ .any(|n| n.contains("Minus") || n.contains("Subtract"));
println!("Has operator buttons: {}", has_operators);
// Verify bounds are captured for interactive elements
@@ -447,10 +463,10 @@ fn test_calculator_tree_structure() {
#[ignore]
fn test_multi_app_tree_isolation() {
com_init();
- let notepad = TestApp::launch(&NOTEPAD, Duration::from_secs(10))
- .expect("Failed to launch Notepad");
- let calc = TestApp::launch(&CALCULATOR, Duration::from_secs(10))
- .expect("Failed to launch Calculator");
+ let notepad =
+ TestApp::launch(&NOTEPAD, Duration::from_secs(10)).expect("Failed to launch Notepad");
+ let calc =
+ TestApp::launch(&CALCULATOR, Duration::from_secs(10)).expect("Failed to launch Calculator");
std::thread::sleep(Duration::from_secs(1));
@@ -505,8 +521,7 @@ fn test_full_pipeline_with_app() {
let (element_tx, _element_rx) =
bounded::<(ClickElementRequest, crate::events::ElementContext)>(64);
let click_queue = Arc::new(Mutex::new(Vec::<ClickElementRequest>::new()));
- let focused_element =
- Arc::new(Mutex::new(None::<crate::events::ElementContext>));
+ let focused_element = Arc::new(Mutex::new(None::<crate::events::ElementContext>));
let stop = Arc::new(AtomicBool::new(false));
// Start UIA worker thread
@@ -515,7 +530,14 @@ fn test_full_pipeline_with_app() {
let click_queue2 = click_queue.clone();
let focused_element2 = focused_element.clone();
let thread = std::thread::spawn(move || {
- windows_uia::run_uia_thread(tree_tx, element_tx, click_queue2, focused_element2, stop2, config2);
+ windows_uia::run_uia_thread(
+ tree_tx,
+ element_tx,
+ click_queue2,
+ focused_element2,
+ stop2,
+ config2,
+ );
});
// Wait for initial snapshot
@@ -524,14 +546,11 @@ fn test_full_pipeline_with_app() {
.expect("Should receive initial snapshot");
println!(
"\n=== Initial Snapshot ===\nApp: {} | Title: {:?}\nElements: {}",
- snap.app_name,
- snap.window_title,
- snap.element_count
+ snap.app_name, snap.window_title, snap.element_count
);
// Now launch Notepad — should trigger a new snapshot when we focus it
- let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10))
- .expect("Failed to launch Notepad");
+ let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10)).expect("Failed to launch Notepad");
app.focus();
// Wait for the UIA thread to pick up the focus change
@@ -575,8 +594,7 @@ fn test_full_pipeline_with_app() {
#[ignore]
fn test_focusable_state_capture() {
com_init();
- let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10))
- .expect("Failed to launch Notepad");
+ let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10)).expect("Failed to launch Notepad");
app.focus();
let uia = UiaContext::new().expect("UIA init failed");
@@ -613,8 +631,8 @@ fn test_focusable_state_capture() {
#[ignore]
fn test_real_app_capture_perf() {
com_init();
- let app = TestApp::launch(&CALCULATOR, Duration::from_secs(10))
- .expect("Failed to launch Calculator");
+ let app =
+ TestApp::launch(&CALCULATOR, Duration::from_secs(10)).expect("Failed to launch Calculator");
app.focus();
std::thread::sleep(Duration::from_secs(1));
@@ -648,7 +666,10 @@ fn test_real_app_capture_perf() {
let min = times.iter().min().unwrap();
let max = times.iter().max().unwrap();
- println!("\n=== Calculator Capture Perf ({} iterations) ===", iterations);
+ println!(
+ "\n=== Calculator Capture Perf ({} iterations) ===",
+ iterations
+ );
println!("Elements: {}", element_counts.first().unwrap_or(&0));
println!("Avg: {:?}", avg);
println!("P50: {:?}", p50);
@@ -716,8 +737,8 @@ fn collect_focusable_inner<'a>(node: &'a AccessibilityNode, out: &mut Vec<&'a Ac
#[ignore]
fn test_memory_footprint() {
com_init();
- let app = TestApp::launch(&CALCULATOR, Duration::from_secs(10))
- .expect("Failed to launch Calculator");
+ let app =
+ TestApp::launch(&CALCULATOR, Duration::from_secs(10)).expect("Failed to launch Calculator");
app.focus();
std::thread::sleep(Duration::from_secs(1));
@@ -734,9 +755,17 @@ fn test_memory_footprint() {
println!("\n=== Memory Footprint (Calculator) ===");
println!("Nodes: {}", node_count);
- println!("Heap estimate: {} bytes ({:.1} KB)", byte_size, byte_size as f64 / 1024.0);
+ println!(
+ "Heap estimate: {} bytes ({:.1} KB)",
+ byte_size,
+ byte_size as f64 / 1024.0
+ );
println!("Bytes/node: {:.1}", bytes_per_node);
- println!("JSON size: {} bytes ({:.1} KB)", json_size, json_size as f64 / 1024.0);
+ println!(
+ "JSON size: {} bytes ({:.1} KB)",
+ json_size,
+ json_size as f64 / 1024.0
+ );
println!("JSON/node: {:.1}", json_per_node);
// Bounds: each node should be < 1KB average (struct + strings + overhead)
@@ -768,8 +797,8 @@ fn test_memory_footprint() {
#[ignore]
fn test_memory_stability() {
com_init();
- let app = TestApp::launch(&CALCULATOR, Duration::from_secs(10))
- .expect("Failed to launch Calculator");
+ let app =
+ TestApp::launch(&CALCULATOR, Duration::from_secs(10)).expect("Failed to launch Calculator");
app.focus();
std::thread::sleep(Duration::from_secs(1));
@@ -824,8 +853,8 @@ fn test_memory_stability() {
#[ignore]
fn test_calculator_completeness() {
com_init();
- let app = TestApp::launch(&CALCULATOR, Duration::from_secs(10))
- .expect("Failed to launch Calculator");
+ let app =
+ TestApp::launch(&CALCULATOR, Duration::from_secs(10)).expect("Failed to launch Calculator");
app.focus();
std::thread::sleep(Duration::from_secs(1));
@@ -836,10 +865,25 @@ fn test_calculator_completeness() {
// Ground truth: every standard Calculator button that MUST be captured
let required_buttons = [
- "Zero", "One", "Two", "Three", "Four",
- "Five", "Six", "Seven", "Eight", "Nine",
- "Plus", "Minus", "Multiply by", "Divide by", "Equals",
- "Decimal separator", "Backspace", "Clear", "Clear entry",
+ "Zero",
+ "One",
+ "Two",
+ "Three",
+ "Four",
+ "Five",
+ "Six",
+ "Seven",
+ "Eight",
+ "Nine",
+ "Plus",
+ "Minus",
+ "Multiply by",
+ "Divide by",
+ "Equals",
+ "Decimal separator",
+ "Backspace",
+ "Clear",
+ "Clear entry",
];
let all_buttons = root.find_all_by_type("Button");
@@ -861,7 +905,10 @@ fn test_calculator_completeness() {
println!("\n=== Calculator Data Completeness ===");
println!("Required buttons: {}", required_buttons.len());
- println!("Found: {}", required_buttons.len() - missing.len());
+ println!(
+ "Found: {}",
+ required_buttons.len() - missing.len()
+ );
println!("Missing: {} {:?}", missing.len(), missing);
println!("Completeness: {:.1}%", completeness_pct);
@@ -907,8 +954,8 @@ fn test_calculator_completeness() {
#[ignore]
fn test_capture_consistency() {
com_init();
- let app = TestApp::launch(&CALCULATOR, Duration::from_secs(10))
- .expect("Failed to launch Calculator");
+ let app =
+ TestApp::launch(&CALCULATOR, Duration::from_secs(10)).expect("Failed to launch Calculator");
app.focus();
std::thread::sleep(Duration::from_secs(1));
@@ -929,19 +976,23 @@ fn test_capture_consistency() {
}
}
- let mode_count = *node_counts.iter().max_by_key(|&&c| {
- node_counts.iter().filter(|&&x| x == c).count()
- }).unwrap();
+ let mode_count = *node_counts
+ .iter()
+ .max_by_key(|&&c| node_counts.iter().filter(|&&x| x == c).count())
+ .unwrap();
let consistent = node_counts.iter().filter(|&&c| c == mode_count).count();
let consistency_pct = consistent as f64 / iterations as f64 * 100.0;
let unique_hashes: std::collections::HashSet<u64> = hashes.iter().cloned().collect();
- let hash_stability_pct = if unique_hashes.len() == 1 { 100.0 } else {
+ let hash_stability_pct = if unique_hashes.len() == 1 {
+ 100.0
+ } else {
// Percentage of captures that match the most common hash
- let mode_hash = *hashes.iter().max_by_key(|&&h| {
- hashes.iter().filter(|&&x| x == h).count()
- }).unwrap();
+ let mode_hash = *hashes
+ .iter()
+ .max_by_key(|&&h| hashes.iter().filter(|&&x| x == h).count())
+ .unwrap();
hashes.iter().filter(|&&h| h == mode_hash).count() as f64 / iterations as f64 * 100.0
};
@@ -952,11 +1003,25 @@ fn test_capture_consistency() {
let max_bytes = *byte_sizes.iter().max().unwrap();
println!("\n=== Capture Consistency ({} iterations) ===", iterations);
- println!("Node counts: min={}, max={}, avg={}, mode={}", min_nodes, max_nodes, avg_nodes, mode_count);
+ println!(
+ "Node counts: min={}, max={}, avg={}, mode={}",
+ min_nodes, max_nodes, avg_nodes, mode_count
+ );
println!("Byte sizes: min={}, max={}", min_bytes, max_bytes);
- println!("Consistency: {:.1}% ({}/{} match mode)", consistency_pct, consistent, iterations);
- println!("Hash stability: {:.1}% ({} unique hashes)", hash_stability_pct, unique_hashes.len());
- println!("Named nodes: min={}, max={}", named_counts.iter().min().unwrap(), named_counts.iter().max().unwrap());
+ println!(
+ "Consistency: {:.1}% ({}/{} match mode)",
+ consistency_pct, consistent, iterations
+ );
+ println!(
+ "Hash stability: {:.1}% ({} unique hashes)",
+ hash_stability_pct,
+ unique_hashes.len()
+ );
+ println!(
+ "Named nodes: min={}, max={}",
+ named_counts.iter().min().unwrap(),
+ named_counts.iter().max().unwrap()
+ );
// Consistency: at least 90% of captures should produce the same node count
assert!(
@@ -988,8 +1053,7 @@ fn test_capture_consistency() {
#[ignore]
fn test_serialization_fidelity() {
com_init();
- let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10))
- .expect("Failed to launch Notepad");
+ let app = TestApp::launch(&NOTEPAD, Duration::from_secs(10)).expect("Failed to launch Notepad");
app.focus();
let uia = UiaContext::new().expect("UIA init failed");
diff --git a/crates/screenpipe-accessibility/src/tree/windows.rs b/crates/screenpipe-accessibility/src/tree/windows.rs
index df97eb9fe..2a996c1f9 100644
--- a/crates/screenpipe-accessibility/src/tree/windows.rs
+++ b/crates/screenpipe-accessibility/src/tree/windows.rs
@@ -110,10 +110,8 @@ impl WindowsTreeWalker {
state.com_initialized = true;
}
if state.uia.is_none() {
- state.uia = Some(
- UiaContext::new()
- .map_err(|e| anyhow::anyhow!("UIA init failed: {:?}", e))?,
- );
+ state.uia =
+ Some(UiaContext::new().map_err(|e| anyhow::anyhow!("UIA init failed: {:?}", e))?);
}
Ok(state.uia.as_ref().unwrap())
}
@@ -204,7 +202,11 @@ impl TreeWalkerPlatform for WindowsTreeWalker {
debug!(
"tree walk: app={}, window={}, nodes={}, text_len={}, duration={:?}",
- app_name, window_name, node_count, text_buffer.len(), walk_duration
+ app_name,
+ window_name,
+ node_count,
+ text_buffer.len(),
+ walk_duration
);
Ok(Some(TreeSnapshot {
@@ -291,7 +293,9 @@ mod tests {
#[test]
fn test_skip_types() {
- assert!(SKIP_TYPES.iter().any(|&s| "ScrollBar".eq_ignore_ascii_case(s)));
+ assert!(SKIP_TYPES
+ .iter()
+ .any(|&s| "ScrollBar".eq_ignore_ascii_case(s)));
assert!(SKIP_TYPES.iter().any(|&s| "Image".eq_ignore_ascii_case(s)));
assert!(!SKIP_TYPES.iter().any(|&s| "Button".eq_ignore_ascii_case(s)));
}
@@ -301,7 +305,9 @@ mod tests {
assert!(TEXT_TYPES.iter().any(|&t| "Text".eq_ignore_ascii_case(t)));
assert!(TEXT_TYPES.iter().any(|&t| "Button".eq_ignore_ascii_case(t)));
assert!(TEXT_TYPES.iter().any(|&t| "Edit".eq_ignore_ascii_case(t)));
- assert!(!TEXT_TYPES.iter().any(|&t| "ScrollBar".eq_ignore_ascii_case(t)));
+ assert!(!TEXT_TYPES
+ .iter()
+ .any(|&t| "ScrollBar".eq_ignore_ascii_case(t)));
}
#[test]
@@ -373,11 +379,23 @@ mod tests {
extract_text_from_tree(&tree, 0, 10, &mut buf);
// Text node's name should be captured
- assert!(buf.contains("Hello World"), "missing Text node, got: {}", buf);
+ assert!(
+ buf.contains("Hello World"),
+ "missing Text node, got: {}",
+ buf
+ );
// Edit's value should be captured (not its name)
- assert!(buf.contains("typed text"), "missing Edit value, got: {}", buf);
+ assert!(
+ buf.contains("typed text"),
+ "missing Edit value, got: {}",
+ buf
+ );
// Image should be skipped
- assert!(!buf.contains("icon.png"), "Image should be skipped, got: {}", buf);
+ assert!(
+ !buf.contains("icon.png"),
+ "Image should be skipped, got: {}",
+ buf
+ );
}
#[test]
@@ -388,8 +406,12 @@ mod tests {
#[test]
fn test_sensitive_titles() {
- assert!(SENSITIVE_TITLES.iter().any(|s| "enter password".contains(s)));
- assert!(SENSITIVE_TITLES.iter().any(|s| "private browsing".contains(s)));
+ assert!(SENSITIVE_TITLES
+ .iter()
+ .any(|s| "enter password".contains(s)));
+ assert!(SENSITIVE_TITLES
+ .iter()
+ .any(|s| "private browsing".contains(s)));
assert!(!SENSITIVE_TITLES.iter().any(|s| "calculator".contains(s)));
}
}
diff --git a/crates/screenpipe-accessibility/tests/e2e_tree_walker.rs b/crates/screenpipe-accessibility/tests/e2e_tree_walker.rs
index 5e5e83ac1..0d5ee1e80 100644
--- a/crates/screenpipe-accessibility/tests/e2e_tree_walker.rs
+++ b/crates/screenpipe-accessibility/tests/e2e_tree_walker.rs
@@ -20,9 +20,7 @@
#[cfg(target_os = "macos")]
mod e2e {
- use screenpipe_accessibility::tree::{
- cache::TreeCache, create_tree_walker, TreeWalkerConfig,
- };
+ use screenpipe_accessibility::tree::{cache::TreeCache, create_tree_walker, TreeWalkerConfig};
use std::process::Command;
use std::time::{Duration, Instant};
@@ -84,8 +82,7 @@ mod e2e {
libc::getrusage(libc::RUSAGE_SELF, &mut usage);
let user_ms =
usage.ru_utime.tv_sec as u64 * 1000 + usage.ru_utime.tv_usec as u64 / 1000;
- let sys_ms =
- usage.ru_stime.tv_sec as u64 * 1000 + usage.ru_stime.tv_usec as u64 / 1000;
+ let sys_ms = usage.ru_stime.tv_sec as u64 * 1000 + usage.ru_stime.tv_usec as u64 / 1000;
user_ms + sys_ms
}
}
@@ -264,7 +261,9 @@ mod e2e {
println!(
" First walk: app={}, hash={}, text_len={}",
- snap.app_name, snap.content_hash, snap.text_content.len()
+ snap.app_name,
+ snap.content_hash,
+ snap.text_content.len()
);
assert!(cache.should_store(&snap), "first walk should store");
cache.record_store(&snap.app_name, &snap.window_name, snap.content_hash);
@@ -284,9 +283,7 @@ mod e2e {
println!(" Cache dedup confirmed working!");
} else if snap.app_name == snap2.app_name {
// Same app but content changed (dynamic app like Finder with timestamps)
- println!(
- " [info] Same app but content changed between walks (dynamic content)"
- );
+ println!(" [info] Same app but content changed between walks (dynamic content)");
} else {
println!(" [warn] App changed between walks (focus issue)");
}
@@ -382,11 +379,7 @@ mod e2e {
" CPU per walk: {:.2}ms",
cpu_used_ms as f64 / iterations as f64
);
- println!(
- " Successful: {}/{}",
- durations.len(),
- iterations
- );
+ println!(" Successful: {}/{}", durations.len(), iterations);
// Assertions
assert!(
@@ -460,7 +453,10 @@ mod e2e {
let elapsed = start.elapsed();
let cpu_used = process_cpu_time_ms() - cpu_before;
- println!("\n === Rapid Switch Stress ({} switches) ===", switch_count);
+ println!(
+ "\n === Rapid Switch Stress ({} switches) ===",
+ switch_count
+ );
println!(" Wall time: {:?}", elapsed);
println!(" CPU time: {}ms", cpu_used);
println!(" Stored: {}", stored);
@@ -567,7 +563,10 @@ mod e2e {
let cpu_used_ms = cpu_after - cpu_before;
let cpu_percent = (cpu_used_ms as f64 / test_duration.as_millis() as f64) * 100.0;
- println!("\n === Sustained CPU Load ({}s) ===", test_duration.as_secs());
+ println!(
+ "\n === Sustained CPU Load ({}s) ===",
+ test_duration.as_secs()
+ );
println!(" Walks: {}", walk_count);
println!(" CPU time: {}ms", cpu_used_ms);
println!(" CPU load: {:.1}%", cpu_percent);
diff --git a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
index f29decb63..80097d05d 100644
--- a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
+++ b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
@@ -144,14 +144,20 @@ pub async fn start_device_monitor(
if !has_output {
if let Ok(default_output) = default_output_device().await {
let device_name = default_output.to_string();
- info!("no output device running, starting default: {}", device_name);
+ info!(
+ "no output device running, starting default: {}",
+ device_name
+ );
match audio_manager.start_device(&default_output).await {
Ok(()) => {
default_tracker.last_output = Some(device_name.clone());
info!("started missing output device: {}", device_name);
}
Err(e) => {
- debug!("could not start output device {}: {}", device_name, e);
+ debug!(
+ "could not start output device {}: {}",
+ device_name, e
+ );
}
}
}
diff --git a/crates/screenpipe-audio/src/audio_manager/manager.rs b/crates/screenpipe-audio/src/audio_manager/manager.rs
index 510c96283..313251dbf 100644
--- a/crates/screenpipe-audio/src/audio_manager/manager.rs
+++ b/crates/screenpipe-audio/src/audio_manager/manager.rs
@@ -94,8 +94,7 @@ impl AudioManager {
whisper_rs::install_logging_hooks();
// Only create idle detector for Smart mode with local Whisper engines
- let is_local_whisper =
- *options.transcription_engine != AudioTranscriptionEngine::Deepgram;
+ let is_local_whisper = *options.transcription_engine != AudioTranscriptionEngine::Deepgram;
let idle_detector = if options.transcription_mode == TranscriptionMode::Smart
&& is_local_whisper
{
diff --git a/crates/screenpipe-audio/src/idle_detector.rs b/crates/screenpipe-audio/src/idle_detector.rs
index 51a657d72..1954d720c 100644
--- a/crates/screenpipe-audio/src/idle_detector.rs
+++ b/crates/screenpipe-audio/src/idle_detector.rs
@@ -50,7 +50,12 @@ impl IdleDetector {
cpu_usage, self.cpu_threshold
));
} else {
- let secs_below = self.last_above_threshold.read().unwrap().elapsed().as_secs();
+ let secs_below = self
+ .last_above_threshold
+ .read()
+ .unwrap()
+ .elapsed()
+ .as_secs();
if secs_below >= self.stable_secs {
*self.paused_reason.write().unwrap() = None;
} else {
@@ -71,7 +76,12 @@ impl IdleDetector {
/// Returns true if the system is idle (CPU below threshold for `stable_secs`).
pub fn is_idle(&self) -> bool {
- let elapsed = self.last_above_threshold.read().unwrap().elapsed().as_secs();
+ let elapsed = self
+ .last_above_threshold
+ .read()
+ .unwrap()
+ .elapsed()
+ .as_secs();
elapsed >= self.stable_secs
}
diff --git a/crates/screenpipe-audio/src/lib.rs b/crates/screenpipe-audio/src/lib.rs
index ed0ca3c50..832f65efd 100644
--- a/crates/screenpipe-audio/src/lib.rs
+++ b/crates/screenpipe-audio/src/lib.rs
@@ -12,6 +12,6 @@ pub mod transcription;
pub use utils::audio::pcm_decode;
pub use utils::audio::resample;
pub mod audio_manager;
-pub mod idle_detector;
mod device;
+pub mod idle_detector;
mod segmentation;
diff --git a/crates/screenpipe-audio/src/transcription/transcription_result.rs b/crates/screenpipe-audio/src/transcription/transcription_result.rs
index f772f3e39..b459939e3 100644
--- a/crates/screenpipe-audio/src/transcription/transcription_result.rs
+++ b/crates/screenpipe-audio/src/transcription/transcription_result.rs
@@ -115,10 +115,7 @@ pub async fn process_transcription_result(
None
};
- match db
- .get_or_insert_audio_chunk(&result.path, capture_ts)
- .await
- {
+ match db.get_or_insert_audio_chunk(&result.path, capture_ts).await {
Ok(audio_chunk_id) => {
if transcription.is_empty() {
return Ok(Some(audio_chunk_id));
diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rs
index d524a69cc..9cbb478e9 100644
--- a/crates/screenpipe-core/src/agents/pi.rs
+++ b/crates/screenpipe-core/src/agents/pi.rs
@@ -325,7 +325,14 @@ impl AgentExecutor for PiExecutor {
);
let output = self
- .spawn_pi(&pi_path, prompt, model, working_dir, &resolved_provider, pid_tx)
+ .spawn_pi(
+ &pi_path,
+ prompt,
+ model,
+ working_dir,
+ &resolved_provider,
+ pid_tx,
+ )
.await?;
// Retry once on "model not found": delete stale models.json and rewrite
@@ -346,7 +353,14 @@ impl AgentExecutor for PiExecutor {
None,
)?;
return self
- .spawn_pi(&pi_path, prompt, model, working_dir, &resolved_provider, None)
+ .spawn_pi(
+ &pi_path,
+ prompt,
+ model,
+ working_dir,
+ &resolved_provider,
+ None,
+ )
.await;
}
@@ -556,7 +570,10 @@ pub fn kill_process_group(pid: u32) -> Result<()> {
unsafe {
// Check if process still exists before sending SIGKILL
if libc::kill(-pgid, 0) == 0 {
- warn!("process group {} did not exit after SIGTERM, sending SIGKILL", pgid);
+ warn!(
+ "process group {} did not exit after SIGTERM, sending SIGKILL",
+ pgid
+ );
libc::kill(-pgid, libc::SIGKILL);
}
}
@@ -599,7 +616,10 @@ mod tests {
let providers = config.get("providers").unwrap().as_object().unwrap();
// Should have both screenpipe and ollama providers
- assert!(providers.contains_key("screenpipe"), "missing screenpipe provider");
+ assert!(
+ providers.contains_key("screenpipe"),
+ "missing screenpipe provider"
+ );
assert!(providers.contains_key("ollama"), "missing ollama provider");
let ollama = &providers["ollama"];
diff --git a/crates/screenpipe-core/src/pipes/mod.rs b/crates/screenpipe-core/src/pipes/mod.rs
index f2e9d555d..3bf5dbdb4 100644
--- a/crates/screenpipe-core/src/pipes/mod.rs
+++ b/crates/screenpipe-core/src/pipes/mod.rs
@@ -264,7 +264,11 @@ fn resolve_preset(pipes_dir: &Path, preset_id: &str) -> Option<ResolvedPreset> {
.filter(|s| !s.is_empty())
.map(|s| s.to_string());
- Some(ResolvedPreset { model, provider, url })
+ Some(ResolvedPreset {
+ model,
+ provider,
+ url,
+ })
}
// ---------------------------------------------------------------------------
@@ -516,9 +520,8 @@ impl PipeManager {
let last_log = pipe_logs.and_then(|l| l.back());
let last_error = last_log.filter(|l| !l.success).map(|l| l.stderr.clone());
// Read raw file from disk for editing
- let raw_content =
- std::fs::read_to_string(self.pipes_dir.join(name).join("pipe.md"))
- .unwrap_or_else(|_| serialize_pipe(config, body).unwrap_or_default());
+ let raw_content = std::fs::read_to_string(self.pipes_dir.join(name).join("pipe.md"))
+ .unwrap_or_else(|_| serialize_pipe(config, body).unwrap_or_default());
let mut cfg = config.clone();
cfg.name = name.clone(); // always use directory name
result.push(PipeStatus {
@@ -625,7 +628,8 @@ impl PipeManager {
let pipe_dir = self.pipes_dir.join(name);
// Resolve preset → model/provider overrides
- let (run_model, run_provider, run_provider_url) = if let Some(ref preset_id) = config.preset {
+ let (run_model, run_provider, run_provider_url) = if let Some(ref preset_id) = config.preset
+ {
match resolve_preset(&self.pipes_dir, preset_id) {
Some(resolved) => {
info!(
@@ -718,7 +722,13 @@ impl PipeManager {
let timeout_duration = std::time::Duration::from_secs(DEFAULT_TIMEOUT_SECS);
let run_result = tokio::time::timeout(
timeout_duration,
- executor.run(&prompt, &run_model, &pipe_dir, run_provider.as_deref(), Some(pid_tx)),
+ executor.run(
+ &prompt,
+ &run_model,
+ &pipe_dir,
+ run_provider.as_deref(),
+ Some(pid_tx),
+ ),
)
.await;
@@ -744,7 +754,11 @@ impl PipeManager {
(None, None)
};
- let status = if output.success { "completed" } else { "failed" };
+ let status = if output.success {
+ "completed"
+ } else {
+ "failed"
+ };
if let (Some(ref store), Some(id)) = (&self.store, exec_id) {
let _ = store
.finish_execution(
@@ -839,10 +853,7 @@ impl PipeManager {
finished_at,
success: false,
stdout: String::new(),
- stderr: format!(
- "execution timed out after {}s",
- DEFAULT_TIMEOUT_SECS
- ),
+ stderr: format!("execution timed out after {}s", DEFAULT_TIMEOUT_SECS),
}
}
};
@@ -1207,7 +1218,8 @@ impl PipeManager {
}
// Resolve preset → model/provider overrides (same as run_pipe)
- let (model, provider, provider_url) = if let Some(ref preset_id) = config.preset {
+ let (model, provider, provider_url) = if let Some(ref preset_id) = config.preset
+ {
match resolve_preset(&pipes_dir, preset_id) {
Some(resolved) => {
info!("scheduler: pipe '{}' using preset '{}' → model={}, provider={:?}",
@@ -1248,7 +1260,12 @@ impl PipeManager {
// Create DB execution row
let exec_id = if let Some(ref store) = store_ref {
match store
- .create_execution(&pipe_name, "scheduled", &model, provider.as_deref())
+ .create_execution(
+ &pipe_name,
+ "scheduled",
+ &model,
+ provider.as_deref(),
+ )
.await
{
Ok(id) => {
@@ -1288,7 +1305,9 @@ impl PipeManager {
handle.pid = pid;
}
}
- if let (Some(ref store), Some(id)) = (&store_for_pid, exec_id_for_pid) {
+ if let (Some(ref store), Some(id)) =
+ (&store_for_pid, exec_id_for_pid)
+ {
let _ = store.set_execution_running(id, Some(pid)).await;
}
}
@@ -1298,7 +1317,13 @@ impl PipeManager {
let timeout_duration = std::time::Duration::from_secs(DEFAULT_TIMEOUT_SECS);
let run_result = tokio::time::timeout(
timeout_duration,
- executor.run(&prompt, &model, &pipe_dir, provider.as_deref(), Some(pid_tx)),
+ executor.run(
+ &prompt,
+ &model,
+ &pipe_dir,
+ provider.as_deref(),
+ Some(pid_tx),
+ ),
)
.await;
@@ -1321,7 +1346,11 @@ impl PipeManager {
} else {
(None, None)
};
- let status = if output.success { "completed" } else { "failed" };
+ let status = if output.success {
+ "completed"
+ } else {
+ "failed"
+ };
if let (Some(ref store), Some(id)) = (&store_ref, exec_id) {
let _ = store
@@ -1337,7 +1366,9 @@ impl PipeManager {
.await;
}
if let Some(ref store) = store_ref {
- let _ = store.upsert_scheduler_state(&pipe_name, output.success).await;
+ let _ = store
+ .upsert_scheduler_state(&pipe_name, output.success)
+ .await;
}
if output.success {
@@ -1359,8 +1390,13 @@ impl PipeManager {
if let (Some(ref store), Some(id)) = (&store_ref, exec_id) {
let _ = store
.finish_execution(
- id, "failed", "", &e.to_string(), None,
- Some("crash"), Some(&e.to_string()),
+ id,
+ "failed",
+ "",
+ &e.to_string(),
+ None,
+ Some("crash"),
+ Some(&e.to_string()),
)
.await;
}
@@ -1377,7 +1413,10 @@ impl PipeManager {
}
}
Err(_elapsed) => {
- warn!("pipe '{}' timed out after {}s", pipe_name, DEFAULT_TIMEOUT_SECS);
+ warn!(
+ "pipe '{}' timed out after {}s",
+ pipe_name, DEFAULT_TIMEOUT_SECS
+ );
if let Some(handle) = removed_handle {
if handle.pid != 0 {
let _ = crate::agents::pi::kill_process_group(handle.pid);
@@ -1386,9 +1425,16 @@ impl PipeManager {
if let (Some(ref store), Some(id)) = (&store_ref, exec_id) {
let _ = store
.finish_execution(
- id, "timed_out", "", "", None,
+ id,
+ "timed_out",
+ "",
+ "",
+ None,
Some("timeout"),
- Some(&format!("execution timed out after {}s", DEFAULT_TIMEOUT_SECS)),
+ Some(&format!(
+ "execution timed out after {}s",
+ DEFAULT_TIMEOUT_SECS
+ )),
)
.await;
}
@@ -1401,7 +1447,10 @@ impl PipeManager {
finished_at,
success: false,
stdout: String::new(),
- stderr: format!("execution timed out after {}s", DEFAULT_TIMEOUT_SECS),
+ stderr: format!(
+ "execution timed out after {}s",
+ DEFAULT_TIMEOUT_SECS
+ ),
}
}
};
diff --git a/crates/screenpipe-db/src/fts_indexer.rs b/crates/screenpipe-db/src/fts_indexer.rs
index 44f220666..5463f29d9 100644
--- a/crates/screenpipe-db/src/fts_indexer.rs
+++ b/crates/screenpipe-db/src/fts_indexer.rs
@@ -332,4 +332,3 @@ async fn index_accessibility_fts(db: &DatabaseManager) -> Result<i64, sqlx::Erro
Ok(count)
}
-
diff --git a/crates/screenpipe-db/tests/audio_duplicate_test.rs b/crates/screenpipe-db/tests/audio_duplicate_test.rs
index 3bed9b14b..c46efab8f 100644
--- a/crates/screenpipe-db/tests/audio_duplicate_test.rs
+++ b/crates/screenpipe-db/tests/audio_duplicate_test.rs
@@ -53,7 +53,10 @@ mod tests {
let db = setup_test_db().await;
// Simulate system output capturing "It was the first computer with beautiful typography."
- let chunk_output = db.insert_audio_chunk("output_audio.mp4", None).await.unwrap();
+ let chunk_output = db
+ .insert_audio_chunk("output_audio.mp4", None)
+ .await
+ .unwrap();
let id1 = db
.insert_audio_transcription(
chunk_output,
@@ -71,7 +74,10 @@ mod tests {
assert!(id1 > 0, "First insert should succeed");
// Simulate microphone picking up the SAME content (different chunk, different device)
- let chunk_input = db.insert_audio_chunk("input_audio.mp4", None).await.unwrap();
+ let chunk_input = db
+ .insert_audio_chunk("input_audio.mp4", None)
+ .await
+ .unwrap();
let id2 = db
.insert_audio_transcription(
chunk_input, // Different chunk!
@@ -194,7 +200,10 @@ mod tests {
let db = setup_test_db().await;
// From production logs at 14:17:22 - Display 4 (output)
- let chunk1 = db.insert_audio_chunk("output_14_17.mp4", None).await.unwrap();
+ let chunk1 = db
+ .insert_audio_chunk("output_14_17.mp4", None)
+ .await
+ .unwrap();
let id1 = db
.insert_audio_transcription(
chunk1,
@@ -216,7 +225,10 @@ mod tests {
// From production logs at 14:17:54 - MacBook Pro Microphone (input)
// Contains the same phrase in a longer transcription
- let chunk2 = db.insert_audio_chunk("input_14_17.mp4", None).await.unwrap();
+ let chunk2 = db
+ .insert_audio_chunk("input_14_17.mp4", None)
+ .await
+ .unwrap();
let id2 = db
.insert_audio_transcription(
chunk2,
@@ -502,7 +514,9 @@ mod tests {
};
let id = db
- .insert_audio_transcription(chunk, text, 0, "whisper", &device, None, None, None, None)
+ .insert_audio_transcription(
+ chunk, text, 0, "whisper", &device, None, None, None, None,
+ )
.await
.unwrap();
@@ -568,8 +582,14 @@ mod tests {
// Scenario 2: Different device, different chunk, SAME content - Cross-device dedup
println!("\nScenario 2: Different devices, same content (THE BUG WE FIXED)");
- let chunk2a = db.insert_audio_chunk("output_chunk.mp4", None).await.unwrap();
- let chunk2b = db.insert_audio_chunk("input_chunk.mp4", None).await.unwrap();
+ let chunk2a = db
+ .insert_audio_chunk("output_chunk.mp4", None)
+ .await
+ .unwrap();
+ let chunk2b = db
+ .insert_audio_chunk("input_chunk.mp4", None)
+ .await
+ .unwrap();
let id2a = db
.insert_audio_transcription(
chunk2a,
@@ -606,8 +626,14 @@ mod tests {
// Scenario 3: Different devices, DIFFERENT content - Should both succeed
println!("\nScenario 3: Different devices, different content");
- let chunk3a = db.insert_audio_chunk("output_different.mp4", None).await.unwrap();
- let chunk3b = db.insert_audio_chunk("input_different.mp4", None).await.unwrap();
+ let chunk3a = db
+ .insert_audio_chunk("output_different.mp4", None)
+ .await
+ .unwrap();
+ let chunk3b = db
+ .insert_audio_chunk("input_different.mp4", None)
+ .await
+ .unwrap();
let id3a = db
.insert_audio_transcription(
chunk3a,
diff --git a/crates/screenpipe-db/tests/db.rs b/crates/screenpipe-db/tests/db.rs
index ea63ece1c..c15805f92 100644
--- a/crates/screenpipe-db/tests/db.rs
+++ b/crates/screenpipe-db/tests/db.rs
@@ -723,7 +723,10 @@ mod tests {
.await
.unwrap();
- let audio_chunk_id2 = db.insert_audio_chunk("test_audio2.mp4", None).await.unwrap();
+ let audio_chunk_id2 = db
+ .insert_audio_chunk("test_audio2.mp4", None)
+ .await
+ .unwrap();
db.insert_audio_transcription(
audio_chunk_id2,
@@ -1124,7 +1127,10 @@ mod tests {
db.update_speaker_name(speaker.id, "test name")
.await
.unwrap();
- let audio_chunk_id = db.insert_audio_chunk("test_audio1.mp4", None).await.unwrap();
+ let audio_chunk_id = db
+ .insert_audio_chunk("test_audio1.mp4", None)
+ .await
+ .unwrap();
db.insert_audio_transcription(
audio_chunk_id,
"similar speakers test transcription one",
@@ -1145,7 +1151,10 @@ mod tests {
// Create second speaker with audio data
let speaker2 = db.insert_speaker(&vec![0.2; 512]).await.unwrap();
db.update_speaker_name(speaker2.id, "name").await.unwrap();
- let audio_chunk_id2 = db.insert_audio_chunk("test_audio2.mp4", None).await.unwrap();
+ let audio_chunk_id2 = db
+ .insert_audio_chunk("test_audio2.mp4", None)
+ .await
+ .unwrap();
db.insert_audio_transcription(
audio_chunk_id2,
"similar speakers test transcription two",
@@ -1593,7 +1602,10 @@ mod tests {
let db = setup_test_db().await;
// Insert an audio chunk via a committed transaction (baseline)
- let chunk_id = db.insert_audio_chunk("rollback_test.mp4", None).await.unwrap();
+ let chunk_id = db
+ .insert_audio_chunk("rollback_test.mp4", None)
+ .await
+ .unwrap();
assert!(chunk_id > 0);
// Start a transaction, insert a row, then DROP without committing.
@@ -1608,16 +1620,21 @@ mod tests {
}
// Verify the uncommitted row was rolled back
- let row: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM audio_chunks WHERE file_path = 'should_not_exist.mp4'")
- .fetch_one(&db.pool)
- .await
- .unwrap();
+ let row: (i64,) = sqlx::query_as(
+ "SELECT COUNT(*) FROM audio_chunks WHERE file_path = 'should_not_exist.mp4'",
+ )
+ .fetch_one(&db.pool)
+ .await
+ .unwrap();
assert_eq!(row.0, 0, "Uncommitted row should have been rolled back");
// Verify the pool is still healthy — we can acquire connections and do work.
// If the connection was leaked (detached), the pool would eventually exhaust.
for i in 0..5 {
- let id = db.insert_audio_chunk(&format!("pool_health_{}.mp4", i), None).await.unwrap();
+ let id = db
+ .insert_audio_chunk(&format!("pool_health_{}.mp4", i), None)
+ .await
+ .unwrap();
assert!(id > 0, "Pool should still be healthy after rollback");
}
}
@@ -1643,9 +1660,14 @@ mod tests {
async fn test_insert_and_search_accessibility() {
let db = setup_test_db().await;
- db.insert_accessibility_text("Safari", "Wikipedia", "Hello from accessibility tree", Some("https://en.wikipedia.org"))
- .await
- .unwrap();
+ db.insert_accessibility_text(
+ "Safari",
+ "Wikipedia",
+ "Hello from accessibility tree",
+ Some("https://en.wikipedia.org"),
+ )
+ .await
+ .unwrap();
index_accessibility_fts(&db).await;
@@ -1800,9 +1822,14 @@ mod tests {
async fn test_search_accessibility_fts() {
let db = setup_test_db().await;
- db.insert_accessibility_text("App", "Win", "the quick brown fox jumps over the lazy dog", None)
- .await
- .unwrap();
+ db.insert_accessibility_text(
+ "App",
+ "Win",
+ "the quick brown fox jumps over the lazy dog",
+ None,
+ )
+ .await
+ .unwrap();
db.insert_accessibility_text("App", "Win", "hello world greeting message", None)
.await
.unwrap();
@@ -1935,7 +1962,10 @@ mod tests {
.await
.unwrap();
- let ui_count = results.iter().filter(|r| matches!(r, SearchResult::UI(_))).count();
+ let ui_count = results
+ .iter()
+ .filter(|r| matches!(r, SearchResult::UI(_)))
+ .count();
assert_eq!(ui_count, 1, "Expected 1 Accessibility result in All");
}
@@ -1970,7 +2000,10 @@ mod tests {
.await
.unwrap();
- let ui_count = results.iter().filter(|r| matches!(r, SearchResult::UI(_))).count();
+ let ui_count = results
+ .iter()
+ .filter(|r| matches!(r, SearchResult::UI(_)))
+ .count();
assert_eq!(ui_count, 1, "Expected 1 Accessibility result in Vision");
}
@@ -1979,9 +2012,14 @@ mod tests {
let db = setup_test_db().await;
// Insert into accessibility table (not ui_monitoring)
- db.insert_accessibility_text("DeprecatedApp", "DeprecatedWin", "deprecated UI query text", None)
- .await
- .unwrap();
+ db.insert_accessibility_text(
+ "DeprecatedApp",
+ "DeprecatedWin",
+ "deprecated UI query text",
+ None,
+ )
+ .await
+ .unwrap();
// ContentType::UI should still work and return accessibility data (empty query)
let results = db
diff --git a/crates/screenpipe-server/src/bin/screenpipe-server.rs b/crates/screenpipe-server/src/bin/screenpipe-server.rs
index 353db7051..9b0881d92 100644
--- a/crates/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/crates/screenpipe-server/src/bin/screenpipe-server.rs
@@ -156,8 +156,8 @@ fn setup_logging(local_data_dir: &PathBuf, cli: &Cli) -> anyhow::Result<WorkerGu
.directory(local_data_dir)
.prefix("screenpipe")
.suffix("log")
- .max_file_size(50 * 1024 * 1024) // 50 MB per file
- .max_total_size(200 * 1024 * 1024) // 200 MB total across all log files
+ .max_file_size(50 * 1024 * 1024) // 50 MB per file
+ .max_total_size(200 * 1024 * 1024) // 200 MB total across all log files
.build()?;
let (file_writer, guard) = tracing_appender::non_blocking(file_appender);
@@ -900,18 +900,13 @@ async fn main() -> anyhow::Result<()> {
agent_executors.insert("pi".to_string(), pi_executor.clone());
// Create pipe store backed by the main SQLite DB
- let pipe_store: Option<std::sync::Arc<dyn screenpipe_core::pipes::PipeStore>> = Some(
- std::sync::Arc::new(screenpipe_server::pipe_store::SqlitePipeStore::new(
- db.pool.clone(),
- )),
- );
+ let pipe_store: Option<std::sync::Arc<dyn screenpipe_core::pipes::PipeStore>> =
+ Some(std::sync::Arc::new(
+ screenpipe_server::pipe_store::SqlitePipeStore::new(db.pool.clone()),
+ ));
- let mut pipe_manager = screenpipe_core::pipes::PipeManager::new(
- pipes_dir,
- agent_executors,
- pipe_store,
- cli.port,
- );
+ let mut pipe_manager =
+ screenpipe_core::pipes::PipeManager::new(pipes_dir, agent_executors, pipe_store, cli.port);
pipe_manager.set_on_run_complete(std::sync::Arc::new(|pipe_name, success, duration_secs| {
analytics::capture_event_nonblocking(
"pipe_scheduled_run",
diff --git a/crates/screenpipe-server/src/lib.rs b/crates/screenpipe-server/src/lib.rs
index 45e66dbd7..898e4b87b 100644
--- a/crates/screenpipe-server/src/lib.rs
+++ b/crates/screenpipe-server/src/lib.rs
@@ -7,11 +7,11 @@ pub mod analytics;
mod apple_intelligence_api;
mod auto_destruct;
pub mod cli;
-pub mod logging;
pub mod cli_pipe;
pub mod cli_status;
pub mod cloud_search;
pub mod core;
+pub mod logging;
pub mod pipe_store;
pub mod pipes_api;
pub mod routes;
@@ -32,6 +32,7 @@ pub use axum::Json as JsonResponse;
pub use cli::Cli;
pub use core::{record_video, start_continuous_recording};
+pub use cloud_search::{CloudSearchClient, CloudSearchMetadata, CloudStatus};
pub use resource_monitor::{ResourceMonitor, RestartSignal};
pub use screenpipe_core::Language;
pub use server::health_check_handler as health_check;
@@ -42,9 +43,8 @@ pub use server::PaginatedResponse;
pub use server::SCServer;
pub use server::{api_list_monitors_handler as api_list_monitors, MonitorInfo};
pub use sleep_monitor::start_sleep_monitor;
+pub use ui_recorder::{start_ui_recording, UiRecorderConfig, UiRecorderHandle};
pub use video::{
video_quality_to_crf, video_quality_to_jpeg_q, video_quality_to_preset, FrameWriteInfo,
FrameWriteTracker, VideoCapture,
};
-pub use cloud_search::{CloudSearchClient, CloudSearchMetadata, CloudStatus};
-pub use ui_recorder::{start_ui_recording, UiRecorderConfig, UiRecorderHandle};
diff --git a/crates/screenpipe-server/src/logging.rs b/crates/screenpipe-server/src/logging.rs
index b4787464e..895e98e21 100644
--- a/crates/screenpipe-server/src/logging.rs
+++ b/crates/screenpipe-server/src/logging.rs
@@ -109,12 +109,22 @@ impl SizedRollingWriter {
#[cfg(test)]
fn current_path(&self) -> PathBuf {
- self.dir
- .join(Self::filename(&self.prefix, &self.suffix, &self.date_str, self.index))
+ self.dir.join(Self::filename(
+ &self.prefix,
+ &self.suffix,
+ &self.date_str,
+ self.index,
+ ))
}
/// Open (or create) a log file in append mode and return it with its size.
- fn open(dir: &Path, prefix: &str, suffix: &str, date: &str, index: u32) -> io::Result<(File, u64)> {
+ fn open(
+ dir: &Path,
+ prefix: &str,
+ suffix: &str,
+ date: &str,
+ index: u32,
+ ) -> io::Result<(File, u64)> {
let path = dir.join(Self::filename(prefix, suffix, date, index));
let file = OpenOptions::new().create(true).append(true).open(&path)?;
let size = file.metadata()?.len();
@@ -128,7 +138,13 @@ impl SizedRollingWriter {
self.estimated_total += self.size;
self.index += 1;
- let (file, size) = Self::open(&self.dir, &self.prefix, &self.suffix, &self.date_str, self.index)?;
+ let (file, size) = Self::open(
+ &self.dir,
+ &self.prefix,
+ &self.suffix,
+ &self.date_str,
+ self.index,
+ )?;
self.file = file;
self.size = size;
@@ -144,7 +160,13 @@ impl SizedRollingWriter {
self.index = 0;
self.next_date = next_midnight();
- let (file, size) = Self::open(&self.dir, &self.prefix, &self.suffix, &self.date_str, self.index)?;
+ let (file, size) = Self::open(
+ &self.dir,
+ &self.prefix,
+ &self.suffix,
+ &self.date_str,
+ self.index,
+ )?;
self.file = file;
self.size = size;
@@ -209,7 +231,7 @@ impl Default for Builder {
directory: None,
prefix: "app".into(),
suffix: "log".into(),
- max_file_size: 50 * 1024 * 1024, // 50 MB
+ max_file_size: 50 * 1024 * 1024, // 50 MB
max_total_size: 200 * 1024 * 1024, // 200 MB
}
}
@@ -247,9 +269,9 @@ impl Builder {
}
pub fn build(self) -> io::Result<SizedRollingWriter> {
- let dir = self.directory.ok_or_else(|| {
- io::Error::new(io::ErrorKind::InvalidInput, "directory is required")
- })?;
+ let dir = self
+ .directory
+ .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "directory is required"))?;
fs::create_dir_all(&dir)?;
@@ -650,17 +672,9 @@ mod tests {
let today = today_string();
// File for a different date.
- fs::write(
- tmp.path().join("test.1999-01-01.0.log"),
- &[0u8; 100],
- )
- .unwrap();
+ fs::write(tmp.path().join("test.1999-01-01.0.log"), &[0u8; 100]).unwrap();
// File for today.
- fs::write(
- tmp.path().join(format!("test.{}.3.log", today)),
- &[0u8; 10],
- )
- .unwrap();
+ fs::write(tmp.path().join(format!("test.{}.3.log", today)), &[0u8; 10]).unwrap();
let (max_idx, total) = scan_existing(tmp.path(), "test", "log", &today);
assert_eq!(max_idx, 3);
diff --git a/crates/screenpipe-server/src/pipe_store.rs b/crates/screenpipe-server/src/pipe_store.rs
index 0443ce355..d8709760b 100644
--- a/crates/screenpipe-server/src/pipe_store.rs
+++ b/crates/screenpipe-server/src/pipe_store.rs
@@ -264,9 +264,7 @@ mod tests {
use screenpipe_core::pipes::PipeStore;
async fn setup_test_store() -> SqlitePipeStore {
- let pool = sqlx::SqlitePool::connect("sqlite::memory:")
- .await
- .unwrap();
+ let pool = sqlx::SqlitePool::connect("sqlite::memory:").await.unwrap();
// Create only the tables we need (avoids needing sqlite-vec extension
// that full migrations require for speaker tables).
sqlx::query(
@@ -579,7 +577,12 @@ mod tests {
// 1. Create
let id = store
- .create_execution("lifecycle-pipe", "manual", "claude-haiku", Some("screenpipe"))
+ .create_execution(
+ "lifecycle-pipe",
+ "manual",
+ "claude-haiku",
+ Some("screenpipe"),
+ )
.await
.unwrap();
diff --git a/crates/screenpipe-server/src/pipes_api.rs b/crates/screenpipe-server/src/pipes_api.rs
index bc007f814..1d70bf690 100644
--- a/crates/screenpipe-server/src/pipes_api.rs
+++ b/crates/screenpipe-server/src/pipes_api.rs
@@ -94,10 +94,7 @@ pub async fn run_pipe_now(
}
/// POST /pipes/:id/stop — stop a running pipe.
-pub async fn stop_pipe(
- State(pm): State<SharedPipeManager>,
- Path(id): Path<String>,
-) -> Json<Value> {
+pub async fn stop_pipe(State(pm): State<SharedPipeManager>, Path(id): Path<String>) -> Json<Value> {
let mgr = pm.lock().await;
match mgr.stop_pipe(&id).await {
Ok(()) => Json(json!({ "success": true })),
diff --git a/crates/screenpipe-server/src/ui_recorder.rs b/crates/screenpipe-server/src/ui_recorder.rs
index b2abde7c5..d6ba1260d 100644
--- a/crates/screenpipe-server/src/ui_recorder.rs
+++ b/crates/screenpipe-server/src/ui_recorder.rs
@@ -335,7 +335,15 @@ pub async fn start_ui_recording(
let join_handle = std::thread::Builder::new()
.name("tree-walker".to_string())
.spawn(move || {
- run_tree_walker(tree_db, tree_stop, walk_interval, rt_handle, tree_wake, ignored_windows_clone, included_windows_clone);
+ run_tree_walker(
+ tree_db,
+ tree_stop,
+ walk_interval,
+ rt_handle,
+ tree_wake,
+ ignored_windows_clone,
+ included_windows_clone,
+ );
})
.expect("failed to spawn tree-walker thread");
// Wrap in a JoinHandle<()> compatible with the tokio handle used on other platforms
@@ -346,7 +354,15 @@ pub async fn start_ui_recording(
#[cfg(not(target_os = "windows"))]
{
Some(tokio::task::spawn_blocking(move || {
- run_tree_walker(tree_db, tree_stop, walk_interval, rt_handle, tree_wake, ignored_windows_clone, included_windows_clone);
+ run_tree_walker(
+ tree_db,
+ tree_stop,
+ walk_interval,
+ rt_handle,
+ tree_wake,
+ ignored_windows_clone,
+ included_windows_clone,
+ );
}))
}
} else {
diff --git a/crates/screenpipe-server/src/video.rs b/crates/screenpipe-server/src/video.rs
index d4bc84c28..d76b99597 100644
--- a/crates/screenpipe-server/src/video.rs
+++ b/crates/screenpipe-server/src/video.rs
@@ -454,7 +454,10 @@ impl VideoCapture {
}
if disable_ocr {
- info!("OCR disabled for monitor {} — passing frames through without text extraction", monitor_id);
+ info!(
+ "OCR disabled for monitor {} — passing frames through without text extraction",
+ monitor_id
+ );
} else {
info!("Starting OCR worker for monitor {}", monitor_id);
}
@@ -469,11 +472,7 @@ impl VideoCapture {
captured_at: raw_frame.captured_at,
window_ocr_results: Vec::new(),
};
- push_to_ocr_queue(
- &ocr_frame_queue_clone,
- &Arc::new(capture),
- "OCR-out",
- );
+ push_to_ocr_queue(&ocr_frame_queue_clone, &Arc::new(capture), "OCR-out");
} else {
let ocr_start = std::time::Instant::now();
match process_ocr_task(
@@ -1280,9 +1279,7 @@ mod tests {
let tracker = FrameWriteTracker::new();
tracker.record_write(7, 3, "/tmp/test.mp4".to_string());
- let result = tracker
- .wait_for_offset(7, Duration::from_secs(5))
- .await;
+ let result = tracker.wait_for_offset(7, Duration::from_secs(5)).await;
assert!(result.is_some(), "Expected Some for written frame");
let info = result.unwrap();
assert_eq!(info.offset, 3);
@@ -1303,12 +1300,13 @@ mod tests {
// Wait should succeed well before the 5s timeout
let start = std::time::Instant::now();
- let result = tracker
- .wait_for_offset(99, Duration::from_secs(5))
- .await;
+ let result = tracker.wait_for_offset(99, Duration::from_secs(5)).await;
let elapsed = start.elapsed();
- assert!(result.is_some(), "Expected Some for concurrently written frame");
+ assert!(
+ result.is_some(),
+ "Expected Some for concurrently written frame"
+ );
assert!(
elapsed < Duration::from_secs(1),
"Should have woken up quickly, took {:?}",
diff --git a/crates/screenpipe-server/tests/endpoint_test.rs b/crates/screenpipe-server/tests/endpoint_test.rs
index e4bebe6fa..99bcaeefa 100644
--- a/crates/screenpipe-server/tests/endpoint_test.rs
+++ b/crates/screenpipe-server/tests/endpoint_test.rs
@@ -64,9 +64,18 @@ mod tests {
let (app, db) = setup_test_app().await;
// Insert some test data
- let _ = db.insert_audio_chunk("test_audio1.wav", None).await.unwrap();
- let audio_chunk_id1 = db.insert_audio_chunk("test_audio2.wav", None).await.unwrap();
- let audio_chunk_id2 = db.insert_audio_chunk("test_audio3.wav", None).await.unwrap();
+ let _ = db
+ .insert_audio_chunk("test_audio1.wav", None)
+ .await
+ .unwrap();
+ let audio_chunk_id1 = db
+ .insert_audio_chunk("test_audio2.wav", None)
+ .await
+ .unwrap();
+ let audio_chunk_id2 = db
+ .insert_audio_chunk("test_audio3.wav", None)
+ .await
+ .unwrap();
let _ = db
.insert_audio_transcription(
@@ -209,8 +218,14 @@ mod tests {
.await
.unwrap();
- let audio_chunk_id1 = db.insert_audio_chunk("test_audio1.wav", None).await.unwrap();
- let audio_chunk_id2 = db.insert_audio_chunk("test_audio2.wav", None).await.unwrap();
+ let audio_chunk_id1 = db
+ .insert_audio_chunk("test_audio1.wav", None)
+ .await
+ .unwrap();
+ let audio_chunk_id2 = db
+ .insert_audio_chunk("test_audio2.wav", None)
+ .await
+ .unwrap();
let _ = db
.insert_audio_transcription(
audio_chunk_id1,
@@ -408,7 +423,10 @@ mod tests {
.insert_frame("test_device", None, None, None, None, true, None)
.await
.unwrap();
- let audio_chunk_id1 = db.insert_audio_chunk("test_audio1.wav", None).await.unwrap();
+ let audio_chunk_id1 = db
+ .insert_audio_chunk("test_audio1.wav", None)
+ .await
+ .unwrap();
let now = DateTime::parse_from_rfc3339("2024-09-21T10:49:23.240367Z")
.unwrap()
diff --git a/crates/screenpipe-server/tests/tags_test.rs b/crates/screenpipe-server/tests/tags_test.rs
index 8ab4817fd..cf80c234c 100644
--- a/crates/screenpipe-server/tests/tags_test.rs
+++ b/crates/screenpipe-server/tests/tags_test.rs
@@ -397,7 +397,10 @@ async fn insert_test_data(db: &Arc<DatabaseManager>) {
.unwrap();
// Insert test audio chunk
- let audio_chunk_id = db.insert_audio_chunk("test_audio_file.wav", None).await.unwrap();
+ let audio_chunk_id = db
+ .insert_audio_chunk("test_audio_file.wav", None)
+ .await
+ .unwrap();
// Insert test audio data
db.insert_audio_transcription(
diff --git a/crates/screenpipe-vision/src/monitor.rs b/crates/screenpipe-vision/src/monitor.rs
index ed7ef3519..32f5dbbd5 100644
--- a/crates/screenpipe-vision/src/monitor.rs
+++ b/crates/screenpipe-vision/src/monitor.rs
@@ -406,7 +406,11 @@ impl SafeMonitor {
/// If the monitor name is empty, falls back to "Display" to avoid ambiguous IDs.
pub fn stable_id(&self) -> String {
let d = &self.monitor_data;
- let name = if d.name.is_empty() { "Display" } else { &d.name };
+ let name = if d.name.is_empty() {
+ "Display"
+ } else {
+ &d.name
+ };
format!("{}_{}x{}_{},{}", name, d.width, d.height, d.x, d.y)
}
@@ -632,7 +636,14 @@ mod tests {
use super::*;
/// Create a SafeMonitor for testing without requiring real OS monitors
- fn make_test_monitor(id: u32, name: &str, width: u32, height: u32, x: i32, y: i32) -> SafeMonitor {
+ fn make_test_monitor(
+ id: u32,
+ name: &str,
+ width: u32,
+ height: u32,
+ x: i32,
+ y: i32,
+ ) -> SafeMonitor {
SafeMonitor {
monitor_id: id,
monitor_data: Arc::new(MonitorData {