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

Louis Beaumont3b9126727032
diff --git a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
index 45fb85d8b..e43f0a032 100644
--- a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
+++ b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
@@ -54,7 +54,9 @@ impl OutputRecoveryBackoff {
// Set to epoch-ish so the first check always fires.
// Use checked_sub to avoid panic on Windows when uptime < 3600s
// (Instant - Duration panics if result would be before boot time).
- last_attempt: Instant::now().checked_sub(Duration::from_secs(3600)).unwrap_or(Instant::now()),
+ last_attempt: Instant::now()
+ .checked_sub(Duration::from_secs(3600))
+ .unwrap_or(Instant::now()),
}
}
@@ -571,7 +573,8 @@ pub async fn start_device_monitor(
match audio_manager.start_device(&default_output).await {
Ok(()) => {
failed_devices.remove(&device_name);
- default_tracker.last_output = Some(device_name.clone());
+ default_tracker.last_output =
+ Some(device_name.clone());
output_recovery_backoff.reset();
info!(
"[DEVICE_RECOVERY] output device restored, device={}", device_name
@@ -590,7 +593,9 @@ pub async fn start_device_monitor(
Err(e) => {
let is_permanent = is_permanent_output_error(&e);
output_recovery_backoff.record_failure(is_permanent);
- if output_recovery_backoff.attempts <= 3 || output_recovery_backoff.attempts % 30 == 0 {
+ if output_recovery_backoff.attempts <= 3
+ || output_recovery_backoff.attempts % 30 == 0
+ {
// Log first 3 attempts, then every 30th to avoid spam
warn!(
"[DEVICE_RECOVERY] no output device available (attempt {}, {}, next retry in {}s): {}",
@@ -889,9 +894,8 @@ mod tests {
);
assert!(is_permanent_output_error(&permanent));
- let transient = anyhow::anyhow!(
- "ScreenCaptureKit unavailable for output audio capture: timeout"
- );
+ let transient =
+ anyhow::anyhow!("ScreenCaptureKit unavailable for output audio capture: timeout");
assert!(!is_permanent_output_error(&transient));
let other = anyhow::anyhow!("some random error");
diff --git a/crates/screenpipe-audio/src/audio_manager/manager.rs b/crates/screenpipe-audio/src/audio_manager/manager.rs
index b2327bdc7..0f57530ab 100644
--- a/crates/screenpipe-audio/src/audio_manager/manager.rs
+++ b/crates/screenpipe-audio/src/audio_manager/manager.rs
@@ -373,7 +373,8 @@ impl AudioManager {
recording_sender.clone(),
is_running.clone(),
metrics,
- )).await;
+ ))
+ .await;
// Check for JoinError (task panic/cancel)
if let Err(ref e) = record_result {
diff --git a/crates/screenpipe-audio/src/core/mod.rs b/crates/screenpipe-audio/src/core/mod.rs
index 1005de09f..e839d6427 100644
--- a/crates/screenpipe-audio/src/core/mod.rs
+++ b/crates/screenpipe-audio/src/core/mod.rs
@@ -92,4 +92,3 @@ pub async fn record_and_transcribe(
}
Ok(())
}
-
diff --git a/crates/screenpipe-core/src/pipes/mod.rs b/crates/screenpipe-core/src/pipes/mod.rs
index cf05a5435..4782c1ef5 100644
--- a/crates/screenpipe-core/src/pipes/mod.rs
+++ b/crates/screenpipe-core/src/pipes/mod.rs
@@ -722,7 +722,10 @@ async fn setup_pipe_permissions(
} else {
let ext_content = include_str!("../../assets/extensions/screenpipe-permissions.ts");
if let Err(e) = std::fs::write(&ext_path, ext_content) {
- warn!("failed to install permissions extension for offline mode: {}", e);
+ warn!(
+ "failed to install permissions extension for offline mode: {}",
+ e
+ );
}
}
}
@@ -2426,7 +2429,10 @@ impl PipeManager {
// Increment generation — the scheduler loop checks this on every tick.
// If a stale task somehow survives stop_scheduler(), the generation
// mismatch will cause it to exit on its next iteration.
- let generation = self.scheduler_generation.fetch_add(1, std::sync::atomic::Ordering::SeqCst) + 1;
+ let generation = self
+ .scheduler_generation
+ .fetch_add(1, std::sync::atomic::Ordering::SeqCst)
+ + 1;
let generation_ref = self.scheduler_generation.clone();
let pipes = self.pipes.clone();
@@ -2932,7 +2938,8 @@ impl PipeManager {
/// to exit. Safe to call multiple times. Safe to call if no scheduler is running.
pub async fn stop_scheduler(&mut self) {
// Increment generation to invalidate any running scheduler
- self.scheduler_generation.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
+ self.scheduler_generation
+ .fetch_add(1, std::sync::atomic::Ordering::SeqCst);
// Signal via watch channel
if let Some(tx) = self.shutdown_tx.take() {
@@ -2943,10 +2950,7 @@ impl PipeManager {
if let Some(handle) = self.scheduler_handle.take() {
handle.abort();
// Wait with timeout — the task should exit quickly after abort
- match tokio::time::timeout(
- std::time::Duration::from_secs(5),
- handle,
- ).await {
+ match tokio::time::timeout(std::time::Duration::from_secs(5), handle).await {
Ok(Ok(())) => info!("pipe scheduler stopped cleanly"),
Ok(Err(e)) if e.is_cancelled() => info!("pipe scheduler aborted"),
Ok(Err(e)) => warn!("pipe scheduler task panicked: {}", e),
@@ -3428,7 +3432,8 @@ mod tests {
/// Helper: create a minimal PipeManager for testing (no executors, no store).
fn test_pipe_manager() -> PipeManager {
- let dir = std::env::temp_dir().join(format!("screenpipe-test-pipes-{}", std::process::id()));
+ let dir =
+ std::env::temp_dir().join(format!("screenpipe-test-pipes-{}", std::process::id()));
let _ = std::fs::create_dir_all(&dir);
PipeManager::new(dir, HashMap::new(), None, 0)
}
@@ -3437,12 +3442,20 @@ mod tests {
async fn test_scheduler_starts_and_stops() {
let mut pm = test_pipe_manager();
assert!(pm.scheduler_handle.is_none());
- assert_eq!(pm.scheduler_generation.load(std::sync::atomic::Ordering::SeqCst), 0);
+ assert_eq!(
+ pm.scheduler_generation
+ .load(std::sync::atomic::Ordering::SeqCst),
+ 0
+ );
pm.start_scheduler().await.unwrap();
assert!(pm.scheduler_handle.is_some());
// Generation: stop_scheduler increments (0→1), start_scheduler increments (1→2)
- assert!(pm.scheduler_generation.load(std::sync::atomic::Ordering::SeqCst) >= 1);
+ assert!(
+ pm.scheduler_generation
+ .load(std::sync::atomic::Ordering::SeqCst)
+ >= 1
+ );
pm.stop_scheduler().await;
assert!(pm.scheduler_handle.is_none());
@@ -3454,13 +3467,22 @@ mod tests {
let mut pm = test_pipe_manager();
pm.start_scheduler().await.unwrap();
- let gen1 = pm.scheduler_generation.load(std::sync::atomic::Ordering::SeqCst);
+ let gen1 = pm
+ .scheduler_generation
+ .load(std::sync::atomic::Ordering::SeqCst);
assert!(gen1 >= 1);
// Starting again should stop the old one and increment generation further
pm.start_scheduler().await.unwrap();
- let gen2 = pm.scheduler_generation.load(std::sync::atomic::Ordering::SeqCst);
- assert!(gen2 > gen1, "generation should increase: {} > {}", gen2, gen1);
+ let gen2 = pm
+ .scheduler_generation
+ .load(std::sync::atomic::Ordering::SeqCst);
+ assert!(
+ gen2 > gen1,
+ "generation should increase: {} > {}",
+ gen2,
+ gen1
+ );
assert!(pm.scheduler_handle.is_some());
}
@@ -3518,7 +3540,8 @@ mod tests {
assert!(
gen_after_drop > gen_before_drop,
"drop should increment generation: {} > {}",
- gen_after_drop, gen_before_drop
+ gen_after_drop,
+ gen_before_drop
);
}
diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rs
index 07fa1bed6..e270478eb 100644
--- a/crates/screenpipe-db/src/db.rs
+++ b/crates/screenpipe-db/src/db.rs
@@ -4628,7 +4628,10 @@ impl DatabaseManager {
// 12. Commit — if this fails, no files are touched
tx.commit().await.map_err(|e| {
- error!("failed to commit delete_time_range_local transaction: {}", e);
+ error!(
+ "failed to commit delete_time_range_local transaction: {}",
+ e
+ );
e
})?;
diff --git a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs b/crates/screenpipe-engine/src/bin/screenpipe-engine.rs
index b0f02b320..fb9a7e99f 100644
--- a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs
+++ b/crates/screenpipe-engine/src/bin/screenpipe-engine.rs
@@ -548,12 +548,10 @@ async fn main() -> anyhow::Result<()> {
Some(detector)
};
- let mut audio_manager_builder = config
- .to_audio_manager_builder(
- PathBuf::from(output_path_clone.clone().to_string()),
- audio_devices,
- )
- ;
+ let mut audio_manager_builder = config.to_audio_manager_builder(
+ PathBuf::from(output_path_clone.clone().to_string()),
+ audio_devices,
+ );
if let Some(ref detector) = meeting_detector {
audio_manager_builder = audio_manager_builder.meeting_detector(detector.clone());
diff --git a/crates/screenpipe-engine/src/drm_detector.rs b/crates/screenpipe-engine/src/drm_detector.rs
index 7bcbe459c..8fc89f193 100644
--- a/crates/screenpipe-engine/src/drm_detector.rs
+++ b/crates/screenpipe-engine/src/drm_detector.rs
@@ -25,8 +25,7 @@ static DRM_CONTENT_PAUSED: AtomicBool = AtomicBool::new(false);
/// Global reference to the UI recorder's stop flag.
/// Set during startup so the DRM detector can stop the UI recorder
/// (which holds native event taps that keep Screen Recording active).
-static UI_RECORDER_STOP_FLAG: Lazy<Mutex<Option<Arc<AtomicBool>>>> =
- Lazy::new(|| Mutex::new(None));
+static UI_RECORDER_STOP_FLAG: Lazy<Mutex<Option<Arc<AtomicBool>>>> = Lazy::new(|| Mutex::new(None));
/// Register the UI recorder's stop flag so DRM detector can stop it.
pub fn set_ui_recorder_stop_flag(flag: Arc<AtomicBool>) {
diff --git a/crates/screenpipe-engine/src/meeting_detector.rs b/crates/screenpipe-engine/src/meeting_detector.rs
index 02430e134..4b6be4145 100644
--- a/crates/screenpipe-engine/src/meeting_detector.rs
+++ b/crates/screenpipe-engine/src/meeting_detector.rs
@@ -1209,10 +1209,8 @@ fn windows_scan_process_uia(
.to_lowercase()
.contains(&title_contains.to_lowercase())
{
- let label = format!(
- "window_title={} ({})",
- title_contains, window_name_str
- );
+ let label =
+ format!("window_title={} ({})", title_contains, window_name_str);
if !found.contains(&label) {
info!(
"meeting scanner: matched window title '{}' on '{}'",
@@ -3094,7 +3092,11 @@ mod tests {
let profiles = load_detection_profiles();
let zoom = profiles
.iter()
- .find(|p| p.app_identifiers.windows_process_names.contains(&"zoom.exe"))
+ .find(|p| {
+ p.app_identifiers
+ .windows_process_names
+ .contains(&"zoom.exe")
+ })
.expect("Zoom profile not found");
let has_window_title = zoom.call_signals.iter().any(|s| {
@@ -3111,7 +3113,11 @@ mod tests {
let profiles = load_detection_profiles();
let zoom = profiles
.iter()
- .find(|p| p.app_identifiers.windows_process_names.contains(&"zoom.exe"))
+ .find(|p| {
+ p.app_identifiers
+ .windows_process_names
+ .contains(&"zoom.exe")
+ })
.expect("Zoom profile not found");
// Verify the NameContains signals for Zoom on Windows exist
@@ -3125,7 +3131,9 @@ mod tests {
.collect();
assert!(
- signal_names.iter().any(|n| n.contains("Zoom Video Container")),
+ signal_names
+ .iter()
+ .any(|n| n.contains("Zoom Video Container")),
"Missing 'Zoom Video Container' signal, found: {:?}",
signal_names
);
@@ -3148,7 +3156,11 @@ mod tests {
let profiles = load_detection_profiles();
let zoom = profiles
.iter()
- .find(|p| p.app_identifiers.windows_process_names.contains(&"zoom.exe"))
+ .find(|p| {
+ p.app_identifiers
+ .windows_process_names
+ .contains(&"zoom.exe")
+ })
.expect("Zoom profile not found");
let has_page_title_pattern = zoom
@@ -3194,9 +3206,10 @@ mod tests {
.find(|p| p.app_identifiers.macos_app_names.contains(&"zoom.us"))
.expect("Zoom profile not found");
- let has_mute_menu = zoom.call_signals.iter().any(|s| {
- matches!(s, CallSignal::MenuItemId(id) if id.contains("Mute"))
- });
+ let has_mute_menu = zoom
+ .call_signals
+ .iter()
+ .any(|s| matches!(s, CallSignal::MenuItemId(id) if id.contains("Mute")));
assert!(
!has_mute_menu,
"Zoom profile must NOT have onMuteAudio:/onMuteVideo: signals — \
@@ -3288,9 +3301,9 @@ mod tests {
})
.expect("Google Meet profile not found");
- let has_cmd_d = meet.call_signals.iter().any(|s| {
- matches!(s, CallSignal::KeyboardShortcut(k) if k.contains('D') || k.contains('d'))
- });
+ let has_cmd_d = meet.call_signals.iter().any(
+ |s| matches!(s, CallSignal::KeyboardShortcut(k) if k.contains('D') || k.contains('d')),
+ );
assert!(
!has_cmd_d,
"Google Meet profile must NOT have Cmd+D/Ctrl+D signals (browser bookmark false positive)"
@@ -3427,7 +3440,13 @@ mod tests {
// A random AXButton with ⌘D in its description (e.g. bookmark button)
// should not be detected as a meeting signal
assert!(
- check_signal_match(&signal_cmd_d, "AXButton", None, Some("Add bookmark ⌘D"), None),
+ check_signal_match(
+ &signal_cmd_d,
+ "AXButton",
+ None,
+ Some("Add bookmark ⌘D"),
+ None
+ ),
"KeyboardShortcut signal itself matches — this test verifies the signal \
was REMOVED from the Google Meet profile, not that matching is broken"
);
@@ -3498,7 +3517,11 @@ mod tests {
let profiles = load_detection_profiles();
let zoom = profiles
.iter()
- .find(|p| p.app_identifiers.windows_process_names.contains(&"zoom.exe"))
+ .find(|p| {
+ p.app_identifiers
+ .windows_process_names
+ .contains(&"zoom.exe")
+ })
.expect("Zoom profile not found");
let browser_titles = [
@@ -3575,7 +3598,11 @@ mod windows_live_tests {
let result = scanner.scan_process(app.pid, &profiles[app.profile_index]);
println!(
" {} (pid={}) => in_call={}, signals={}, matched={:?}",
- app.app_name, app.pid, result.is_in_call, result.signals_found, result.matched_signals
+ app.app_name,
+ app.pid,
+ result.is_in_call,
+ result.signals_found,
+ result.matched_signals
);
}
} else {
@@ -3593,7 +3620,11 @@ mod windows_live_tests {
let zoom_profile = profiles
.iter()
- .find(|p| p.app_identifiers.windows_process_names.contains(&"zoom.exe"))
+ .find(|p| {
+ p.app_identifiers
+ .windows_process_names
+ .contains(&"zoom.exe")
+ })
.expect("Zoom profile must exist");
let scanner = MeetingUiScanner::new();
@@ -3612,10 +3643,7 @@ mod windows_live_tests {
// If Zoom is running with a meeting, this should detect it
if !zoom_procs.is_empty() {
- println!(
- "\n=== RESULT: Zoom meeting detected = {} ===",
- any_in_call
- );
+ println!("\n=== RESULT: Zoom meeting detected = {} ===", any_in_call);
}
}
}
diff --git a/crates/screenpipe-engine/src/retention.rs b/crates/screenpipe-engine/src/retention.rs
index 1ed34f8a3..b1fb07bc9 100644
--- a/crates/screenpipe-engine/src/retention.rs
+++ b/crates/screenpipe-engine/src/retention.rs
@@ -127,7 +127,10 @@ pub async fn retention_configure(
state.retention_state.inner.clone(),
run_now,
);
- info!("retention: re-enabled with {}d", runtime.config.retention_days);
+ info!(
+ "retention: re-enabled with {}d",
+ runtime.config.retention_days
+ );
}
Ok(Json(json!({
diff --git a/crates/screenpipe-engine/src/routes/browser.rs b/crates/screenpipe-engine/src/routes/browser.rs
index 37f1797c2..44692c1d3 100644
--- a/crates/screenpipe-engine/src/routes/browser.rs
+++ b/crates/screenpipe-engine/src/routes/browser.rs
@@ -103,9 +103,7 @@ pub struct StatusResponseBody {
// ---------------------------------------------------------------------------
/// GET /browser/status — check if the extension is connected
-pub async fn browser_status_handler(
- State(bridge): State<Arc<BrowserBridge>>,
-) -> impl IntoResponse {
+pub async fn browser_status_handler(State(bridge): State<Arc<BrowserBridge>>) -> impl IntoResponse {
Json(StatusResponseBody {
connected: bridge.is_connected().await,
})
@@ -150,8 +148,10 @@ pub async fn browser_eval_handler(
let send_result = {
let mut sink = ext_tx.lock().await;
- sink.send(Message::Text(serde_json::to_string(&ws_msg).unwrap().into()))
- .await
+ sink.send(Message::Text(
+ serde_json::to_string(&ws_msg).unwrap().into(),
+ ))
+ .await
};
if let Err(e) = send_result {
@@ -171,8 +171,19 @@ pub async fn browser_eval_handler(
// Wait for response
match tokio::time::timeout(std::time::Duration::from_secs(timeout_secs), resp_rx).await {
Ok(Ok(r)) => {
- let status = if r.ok { StatusCode::OK } else { StatusCode::UNPROCESSABLE_ENTITY };
- (status, Json(EvalResponseBody { success: r.ok, result: r.result, error: r.error }))
+ let status = if r.ok {
+ StatusCode::OK
+ } else {
+ StatusCode::UNPROCESSABLE_ENTITY
+ };
+ (
+ status,
+ Json(EvalResponseBody {
+ success: r.ok,
+ result: r.result,
+ error: r.error,
+ }),
+ )
}
Ok(Err(_)) => (
StatusCode::BAD_GATEWAY,
diff --git a/crates/screenpipe-engine/src/server.rs b/crates/screenpipe-engine/src/server.rs
index 4924f8ce6..f90a88908 100644
--- a/crates/screenpipe-engine/src/server.rs
+++ b/crates/screenpipe-engine/src/server.rs
@@ -569,10 +569,7 @@ impl SCServer {
"/retention/configure",
axum::routing::post(crate::retention::retention_configure),
)
- .route(
- "/retention/status",
- get(crate::retention::retention_status),
- )
+ .route("/retention/status", get(crate::retention::retention_status))
.route(
"/retention/run",
axum::routing::post(crate::retention::retention_run),
@@ -727,18 +724,36 @@ impl SCServer {
.route("/ws/health", get(ws_health_handler))
.route("/ws/metrics", get(ws_metrics_handler))
// Browser extension bridge
- .route("/browser/ws", get({
- let bridge = app_state.browser_bridge.clone();
- move |ws| crate::routes::browser::browser_ws_handler(ws, axum::extract::State(bridge))
- }))
- .route("/browser/eval", axum::routing::post({
- let bridge = app_state.browser_bridge.clone();
- move |body| crate::routes::browser::browser_eval_handler(axum::extract::State(bridge), body)
- }))
- .route("/browser/status", get({
- let bridge = app_state.browser_bridge.clone();
- move || crate::routes::browser::browser_status_handler(axum::extract::State(bridge))
- }))
+ .route(
+ "/browser/ws",
+ get({
+ let bridge = app_state.browser_bridge.clone();
+ move |ws| {
+ crate::routes::browser::browser_ws_handler(ws, axum::extract::State(bridge))
+ }
+ }),
+ )
+ .route(
+ "/browser/eval",
+ axum::routing::post({
+ let bridge = app_state.browser_bridge.clone();
+ move |body| {
+ crate::routes::browser::browser_eval_handler(
+ axum::extract::State(bridge),
+ body,
+ )
+ }
+ }),
+ )
+ .route(
+ "/browser/status",
+ get({
+ let bridge = app_state.browser_bridge.clone();
+ move || {
+ crate::routes::browser::browser_status_handler(axum::extract::State(bridge))
+ }
+ }),
+ )
.route(
"/frames/export",
get(handle_video_export_ws).post(handle_video_export_post),
diff --git a/crates/screenpipe-engine/src/sync_api.rs b/crates/screenpipe-engine/src/sync_api.rs
index 5f4ef06c0..209ac614b 100644
--- a/crates/screenpipe-engine/src/sync_api.rs
+++ b/crates/screenpipe-engine/src/sync_api.rs
@@ -142,7 +142,11 @@ pub async fn sync_init(
let service_config = SyncServiceConfig {
enabled: true,
sync_interval_secs: request.sync_interval_secs.unwrap_or(300),
- sync_types: vec![BlobType::Ocr, BlobType::Transcripts, BlobType::Accessibility],
+ sync_types: vec![
+ BlobType::Ocr,
+ BlobType::Transcripts,
+ BlobType::Accessibility,
+ ],
max_blobs_per_cycle: 10,
sync_on_startup: true,
};
diff --git a/crates/screenpipe-screen/src/wgc_capture.rs b/crates/screenpipe-screen/src/wgc_capture.rs
index 62d5ef147..2fab572a6 100644
--- a/crates/screenpipe-screen/src/wgc_capture.rs
+++ b/crates/screenpipe-screen/src/wgc_capture.rs
@@ -79,15 +79,13 @@ impl PersistentCapture {
break;
}
match receiver.recv_timeout(Duration::from_millis(500)) {
- Ok(frame) => {
- match latest_frame.lock() {
- Ok(mut slot) => *slot = Some(frame),
- Err(_) => {
- tracing::error!("WGC consumer: frame mutex poisoned, exiting");
- break;
- }
+ Ok(frame) => match latest_frame.lock() {
+ Ok(mut slot) => *slot = Some(frame),
+ Err(_) => {
+ tracing::error!("WGC consumer: frame mutex poisoned, exiting");
+ break;
}
- }
+ },
Err(std::sync::mpsc::RecvTimeoutError::Timeout) => {
// No frame — WGC only fires on content change; continue
}