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

style: fix additional formatting issues

Louis Beaumont0625c58e9799
diff --git a/screenpipe-core/src/operator/platforms/macos.rs b/screenpipe-core/src/operator/platforms/macos.rs
index 2fded9e1d..d60d08a90 100644
--- a/screenpipe-core/src/operator/platforms/macos.rs
+++ b/screenpipe-core/src/operator/platforms/macos.rs
@@ -929,8 +929,7 @@ impl fmt::Display for ClickMethod {
}
// Define enum for click method selection
-#[derive(Debug)]
-#[derive(Default)]
+#[derive(Debug, Default)]
pub enum ClickMethodSelection {
/// Try all methods in sequence (current behavior)
#[default]
@@ -943,7 +942,6 @@ pub enum ClickMethodSelection {
MouseSimulation,
}
-
// Our concrete UIElement implementation for macOS
pub struct MacOSUIElement {
element: ThreadSafeAXUIElement,
@@ -1339,11 +1337,7 @@ impl UIElementImpl for MacOSUIElement {
let properties = HashMap::new();
// Check if this is a window element first
- let is_window = self
- .element
- .0
- .role()
- .is_ok_and(|r| r == "AXWindow");
+ let is_window = self.element.0.role().is_ok_and(|r| r == "AXWindow");
// Special case for windows
if is_window {
@@ -1666,7 +1660,12 @@ impl UIElementImpl for MacOSUIElement {
// First try using the AXRaise action
let raise_attr = AXAttribute::new(&CFString::new("AXRaise"));
- if self.element.0.perform_action(raise_attr.as_CFString()).is_ok() {
+ if self
+ .element
+ .0
+ .perform_action(raise_attr.as_CFString())
+ .is_ok()
+ {
debug!("Successfully raised element");
// Now try to directly focus the element
@@ -1701,7 +1700,6 @@ impl UIElementImpl for MacOSUIElement {
self.click().map(|_result| {
// Optionally log the details of how the click was performed
debug!("Focus achieved via click method: {}", _result.method);
-
})
}
@@ -1957,12 +1955,7 @@ impl UIElementImpl for MacOSUIElement {
let engine = MacOSEngine::new(self.use_background_apps, self.activate_app)?;
// If this is an application element, refresh the tree
- if self
- .element
- .0
- .role()
- .is_ok_and(|r| r == "AXApplication")
- {
+ if self.element.0.role().is_ok_and(|r| r == "AXApplication") {
if let Some(app_name) = self.attributes().label {
engine.refresh_accessibility_tree(Some(&app_name))?;
}
@@ -2190,10 +2183,7 @@ fn element_contains_text(e: &AXUIElement, text: &str) -> bool {
}
// Check title, description and other text attributes
- let contains_in_title = e
- .title()
- .ok()
- .is_some_and(|t| t.to_string().contains(text));
+ let contains_in_title = e.title().ok().is_some_and(|t| t.to_string().contains(text));
let contains_in_desc = e
.description()
diff --git a/screenpipe-core/src/pii_removal.rs b/screenpipe-core/src/pii_removal.rs
index aac291ba3..9296eee63 100644
--- a/screenpipe-core/src/pii_removal.rs
+++ b/screenpipe-core/src/pii_removal.rs
@@ -31,7 +31,9 @@ pub fn remove_pii(text: &str) -> String {
let mut sanitized = text.to_string();
for (pattern, replacement) in PII_PATTERNS.iter() {
let replacement_bracketed = format!("[{}]", replacement);
- sanitized = pattern.replace_all(&sanitized, replacement_bracketed.as_str()).to_string();
+ sanitized = pattern
+ .replace_all(&sanitized, replacement_bracketed.as_str())
+ .to_string();
}
sanitized
}
@@ -111,7 +113,8 @@ pub fn detect_pii_regions(
// Determine if coordinates are normalized (0-1) or pixel values
// Apple OCR returns normalized, Tesseract returns pixels
- let (x_px, y_px, w_px, h_px) = if left <= 1.0 && top <= 1.0 && width <= 1.0 && height <= 1.0 {
+ let (x_px, y_px, w_px, h_px) = if left <= 1.0 && top <= 1.0 && width <= 1.0 && height <= 1.0
+ {
// Normalized coordinates (Apple OCR style)
// Note: Apple's coordinate system has origin at bottom-left, so we need to flip Y
let x = (left * image_width as f64) as u32;
@@ -182,7 +185,10 @@ mod tests {
#[test]
fn test_get_pii_type() {
- assert_eq!(get_pii_type("4532-1234-5678-9012"), Some("CREDIT_CARD".to_string()));
+ assert_eq!(
+ get_pii_type("4532-1234-5678-9012"),
+ Some("CREDIT_CARD".to_string())
+ );
assert_eq!(get_pii_type("123-45-6789"), Some("SSN".to_string()));
assert_eq!(get_pii_type("[email protected]"), Some("EMAIL".to_string()));
assert_eq!(get_pii_type("Hello World"), None);
@@ -191,15 +197,13 @@ mod tests {
#[test]
fn test_detect_pii_regions_credit_card_normalized() {
// Simulating Apple OCR output with normalized coordinates
- let text_json = vec![
- HashMap::from([
- ("text".to_string(), "4532-1234-5678-9012".to_string()),
- ("left".to_string(), "0.1".to_string()),
- ("top".to_string(), "0.8".to_string()), // Apple has bottom-left origin
- ("width".to_string(), "0.3".to_string()),
- ("height".to_string(), "0.05".to_string()),
- ])
- ];
+ let text_json = vec![HashMap::from([
+ ("text".to_string(), "4532-1234-5678-9012".to_string()),
+ ("left".to_string(), "0.1".to_string()),
+ ("top".to_string(), "0.8".to_string()), // Apple has bottom-left origin
+ ("width".to_string(), "0.3".to_string()),
+ ("height".to_string(), "0.05".to_string()),
+ ])];
let regions = detect_pii_regions(&text_json, 1920, 1080);
@@ -214,15 +218,13 @@ mod tests {
#[test]
fn test_detect_pii_regions_pixel_coordinates() {
// Simulating Tesseract output with pixel coordinates
- let text_json = vec![
- HashMap::from([
- ("text".to_string(), "[email protected]".to_string()),
- ("left".to_string(), "100".to_string()),
- ("top".to_string(), "200".to_string()),
- ("width".to_string(), "300".to_string()),
- ("height".to_string(), "50".to_string()),
- ])
- ];
+ let text_json = vec![HashMap::from([
+ ("text".to_string(), "[email protected]".to_string()),
+ ("left".to_string(), "100".to_string()),
+ ("top".to_string(), "200".to_string()),
+ ("width".to_string(), "300".to_string()),
+ ("height".to_string(), "50".to_string()),
+ ])];
let regions = detect_pii_regions(&text_json, 1920, 1080);
@@ -268,15 +270,13 @@ mod tests {
#[test]
fn test_detect_pii_regions_no_pii() {
- let text_json = vec![
- HashMap::from([
- ("text".to_string(), "Hello World".to_string()),
- ("left".to_string(), "100".to_string()),
- ("top".to_string(), "100".to_string()),
- ("width".to_string(), "200".to_string()),
- ("height".to_string(), "30".to_string()),
- ]),
- ];
+ let text_json = vec![HashMap::from([
+ ("text".to_string(), "Hello World".to_string()),
+ ("left".to_string(), "100".to_string()),
+ ("top".to_string(), "100".to_string()),
+ ("width".to_string(), "200".to_string()),
+ ("height".to_string(), "30".to_string()),
+ ])];
let regions = detect_pii_regions(&text_json, 1920, 1080);
assert!(regions.is_empty());
@@ -284,12 +284,10 @@ mod tests {
#[test]
fn test_detect_pii_regions_missing_coordinates() {
- let text_json = vec![
- HashMap::from([
- ("text".to_string(), "4532-1234-5678-9012".to_string()),
- // Missing bounding box coordinates
- ]),
- ];
+ let text_json = vec![HashMap::from([
+ ("text".to_string(), "4532-1234-5678-9012".to_string()),
+ // Missing bounding box coordinates
+ ])];
let regions = detect_pii_regions(&text_json, 1920, 1080);
assert!(regions.is_empty());
diff --git a/screenpipe-server/src/embedding/embedding_endpoint.rs b/screenpipe-server/src/embedding/embedding_endpoint.rs
index c5c81622c..9432278af 100644
--- a/screenpipe-server/src/embedding/embedding_endpoint.rs
+++ b/screenpipe-server/src/embedding/embedding_endpoint.rs
@@ -68,7 +68,8 @@ pub async fn get_or_initialize_model() -> anyhow::Result<Arc<Mutex<EmbeddingMode
EMBEDDING_MODEL
.get()
- .ok_or_else(|| anyhow::anyhow!("model initialization failed")).cloned()
+ .ok_or_else(|| anyhow::anyhow!("model initialization failed"))
+ .cloned()
}
#[oasgen]
diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rs
index 92f6f6b22..c934d9d2b 100644
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@ -41,7 +41,6 @@ use crate::{
},
PipeManager,
};
-use screenpipe_core::pii_removal::detect_pii_regions;
use chrono::{DateTime, Utc};
use screenpipe_audio::{
audio_manager::AudioManager,
@@ -49,6 +48,7 @@ use screenpipe_audio::{
default_input_device, default_output_device, list_audio_devices, AudioDevice, DeviceType,
},
};
+use screenpipe_core::pii_removal::detect_pii_regions;
use tracing::{debug, error, info};
use screenpipe_vision::monitor::{get_monitor_by_id, list_monitors};