YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
chore: fix clippy warnings and cargo fmt
Louis Beaumont71ea47a53dff
diff --git a/crates/screenpipe-audio/src/idle_detector.rs b/crates/screenpipe-audio/src/idle_detector.rsindex 18cacd7c4..0852937ed 100644--- a/crates/screenpipe-audio/src/idle_detector.rs+++ b/crates/screenpipe-audio/src/idle_detector.rs@@ -137,8 +137,9 @@ mod tests {fn test_idle_after_stable_period() {// Simulate being idle: set threshold very high and backdate last_above_thresholdlet detector = IdleDetector::new(100.0);- *detector.last_above_threshold.write().unwrap() =- Instant::now().checked_sub(std::time::Duration::from_secs(60)).unwrap_or(Instant::now());+ *detector.last_above_threshold.write().unwrap() = Instant::now()+ .checked_sub(std::time::Duration::from_secs(60))+ .unwrap_or(Instant::now());assert!(detector.is_idle(),"should be idle after stable period exceeds threshold"diff --git a/crates/screenpipe-connect/src/connections/github_issues.rs b/crates/screenpipe-connect/src/connections/github_issues.rsindex a98b4ecd5..5843d5b75 100644--- a/crates/screenpipe-connect/src/connections/github_issues.rs+++ b/crates/screenpipe-connect/src/connections/github_issues.rs@@ -43,7 +43,7 @@ impl Integration for GithubIssues {let api_token = require_str(creds, "api_token")?;let repo = require_str(creds, "repo")?;let resp: Value = client- .get(&format!("https://api.github.com/repos/{}", repo))+ .get(format!("https://api.github.com/repos/{}", repo)).bearer_auth(api_token).header("User-Agent", "screenpipe").send()diff --git a/crates/screenpipe-connect/src/connections/jira.rs b/crates/screenpipe-connect/src/connections/jira.rsindex 910dac112..5e70a7b9b 100644--- a/crates/screenpipe-connect/src/connections/jira.rs+++ b/crates/screenpipe-connect/src/connections/jira.rs@@ -51,7 +51,7 @@ impl Integration for Jira {let email = require_str(creds, "email")?;let api_token = require_str(creds, "api_token")?;let resp: Value = client- .get(&format!("https://{}/rest/api/3/myself", domain))+ .get(format!("https://{}/rest/api/3/myself", domain)).basic_auth(email, Some(api_token)).send().await?diff --git a/crates/screenpipe-connect/src/connections/pipedrive.rs b/crates/screenpipe-connect/src/connections/pipedrive.rsindex 0c47e064c..2ca8b9bf7 100644--- a/crates/screenpipe-connect/src/connections/pipedrive.rs+++ b/crates/screenpipe-connect/src/connections/pipedrive.rs@@ -43,7 +43,7 @@ impl Integration for Pipedrive {let api_token = require_str(creds, "api_token")?;let domain = require_str(creds, "domain")?;let resp: Value = client- .get(&format!(+ .get(format!("https://{}.pipedrive.com/api/v1/users/me?api_token={}",domain, api_token))diff --git a/crates/screenpipe-connect/src/connections/sentry.rs b/crates/screenpipe-connect/src/connections/sentry.rsindex 4e3e0aa14..553d2c675 100644--- a/crates/screenpipe-connect/src/connections/sentry.rs+++ b/crates/screenpipe-connect/src/connections/sentry.rs@@ -43,7 +43,7 @@ impl Integration for Sentry {let auth_token = require_str(creds, "auth_token")?;let org = require_str(creds, "organization")?;let resp: Value = client- .get(&format!(+ .get(format!("https://sentry.io/api/0/organizations/{}/projects/",org))diff --git a/crates/screenpipe-connect/src/mdns.rs b/crates/screenpipe-connect/src/mdns.rsindex 28e28c2a9..4d1c220af 100644--- a/crates/screenpipe-connect/src/mdns.rs+++ b/crates/screenpipe-connect/src/mdns.rs@@ -16,12 +16,7 @@ use std::time::Duration;use tracing::{debug, info, warn};fn get_hostname() -> String {- let cmd = if cfg!(windows) {- "hostname"- } else {- "hostname"- };- std::process::Command::new(cmd)+ std::process::Command::new("hostname").output().ok().and_then(|o| String::from_utf8(o.stdout).ok())diff --git a/crates/screenpipe-connect/src/oauth.rs b/crates/screenpipe-connect/src/oauth.rsindex 47a65e301..feb9f828e 100644--- a/crates/screenpipe-connect/src/oauth.rs+++ b/crates/screenpipe-connect/src/oauth.rs@@ -27,7 +27,8 @@//! 2. Implement `oauth_config()` on the `Integration` trait impl.//! 3. Register the redirect URI `http://localhost:3030/connections/oauth/callback`//! in the provider's developer console.-//! That's it — all Tauri commands and frontend rendering are automatic.+//!+//! That's it -- all Tauri commands and frontend rendering are automatic.use anyhow::Result;use once_cell::sync::Lazy;diff --git a/crates/screenpipe-connect/src/remote_sync.rs b/crates/screenpipe-connect/src/remote_sync.rsindex 312fb072b..7b68950d6 100644--- a/crates/screenpipe-connect/src/remote_sync.rs+++ b/crates/screenpipe-connect/src/remote_sync.rs@@ -630,7 +630,7 @@ pub async fn discover_ssh_hosts() -> Vec<DiscoveredHost> {} else {host},- port: port,+ port,user: None,key_path: None,source: "mdns".into(),diff --git a/crates/screenpipe-connect/src/sync_scheduler.rs b/crates/screenpipe-connect/src/sync_scheduler.rsindex 0816ab3f8..61d0e7d79 100644--- a/crates/screenpipe-connect/src/sync_scheduler.rs+++ b/crates/screenpipe-connect/src/sync_scheduler.rs@@ -20,8 +20,8 @@ pub struct SyncScheduler {last_error: Arc<Mutex<Option<String>>>,}-impl SyncScheduler {- pub fn new() -> Self {+impl Default for SyncScheduler {+ fn default() -> Self {Self {running: Arc::new(AtomicBool::new(false)),config: Arc::new(Mutex::new(None)),@@ -29,6 +29,12 @@ impl SyncScheduler {last_error: Arc::new(Mutex::new(None)),}}+}++impl SyncScheduler {+ pub fn new() -> Self {+ Self::default()+ }/// Start the background sync loop. If already running, updates the config/// (the running loop picks up the new config on its next iteration).diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rsindex 11fbd3259..51694fc8c 100644--- a/crates/screenpipe-core/src/agents/pi.rs+++ b/crates/screenpipe-core/src/agents/pi.rs@@ -291,10 +291,10 @@ impl PiExecutor {json!({"providers": {}})};// Ensure providers key exists and is an object- if !models_config+ if models_config.get("providers").and_then(|p| p.as_object())- .is_some()+ .is_none(){models_config = json!({"providers": {}});}diff --git a/crates/screenpipe-core/src/permissions.rs b/crates/screenpipe-core/src/permissions.rsindex d667b313b..c00164679 100644--- a/crates/screenpipe-core/src/permissions.rs+++ b/crates/screenpipe-core/src/permissions.rs@@ -180,7 +180,7 @@ pub fn check_microphone() -> PermissionStatus {// AVMediaTypeAudio = @"soun"let media_type: *mut Object =- msg_send![class!(NSString), stringWithUTF8String: b"soun\0".as_ptr()];+ msg_send![class!(NSString), stringWithUTF8String: c"soun".as_ptr()];let status: i64 = msg_send![cls, authorizationStatusForMediaType: media_type];let _: () = msg_send![pool, drain];diff --git a/crates/screenpipe-core/src/pipes/permissions.rs b/crates/screenpipe-core/src/pipes/permissions.rsindex 49cd359d2..c56bf7042 100644--- a/crates/screenpipe-core/src/pipes/permissions.rs+++ b/crates/screenpipe-core/src/pipes/permissions.rs@@ -248,15 +248,13 @@ impl PipePermissions {// Default allowlistif self.use_default_allowlist {for pattern in DEFAULT_ALLOWED_ENDPOINTS {- if let Some(rule) = parse_bare_api(pattern) {- if let PermissionRule::Api {- method: rm,- path: rp,- } = &rule- {- if (rm == "*" || rm == &m) && glob_match(rp, path) {- return true;- }+ if let Some(PermissionRule::Api {+ method: rm,+ path: rp,+ }) = parse_bare_api(pattern)+ {+ if (rm == "*" || rm == m) && glob_match(&rp, path) {+ return true;}}}diff --git a/crates/screenpipe-core/src/pipes/preset_fallback.rs b/crates/screenpipe-core/src/pipes/preset_fallback.rsindex 50d45ecb5..e5b644bc4 100644--- a/crates/screenpipe-core/src/pipes/preset_fallback.rs+++ b/crates/screenpipe-core/src/pipes/preset_fallback.rs@@ -217,10 +217,7 @@ impl PresetFallbackRegistry {let mut changed = false;for (i, preset_id) in presets.iter().enumerate().take(MAX_FALLBACK_DEPTH) {- let breaker = state- .presets- .entry(preset_id.clone())- .or_insert_with(PresetBreaker::default);+ let breaker = state.presets.entry(preset_id.clone()).or_default();// Check if cooldown expired → HALF_OPENif breaker.check_recovery() {@@ -246,10 +243,7 @@ impl PresetFallbackRegistry {/// Record a successful execution for a preset.pub fn record_success(&self, preset_id: &str) {let mut state = self.state.lock().unwrap_or_else(|e| e.into_inner());- let breaker = state- .presets- .entry(preset_id.to_string())- .or_insert_with(PresetBreaker::default);+ let breaker = state.presets.entry(preset_id.to_string()).or_default();breaker.record_success();self.persist(&state);}@@ -276,10 +270,7 @@ impl PresetFallbackRegistry {};let mut state = self.state.lock().unwrap_or_else(|e| e.into_inner());- let breaker = state- .presets- .entry(preset_id.to_string())- .or_insert_with(PresetBreaker::default);+ let breaker = state.presets.entry(preset_id.to_string()).or_default();breaker.trip(reason);self.persist(&state);@@ -319,10 +310,7 @@ impl PresetFallbackRegistry {};let mut state = self.state.lock().unwrap_or_else(|e| e.into_inner());- let breaker = state- .presets- .entry(preset_id.to_string())- .or_insert_with(PresetBreaker::default);+ let breaker = state.presets.entry(preset_id.to_string()).or_default();breaker.trip(reason);self.persist(&state);diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rsindex 3911f4466..5dd2fecea 100644--- a/crates/screenpipe-db/src/db.rs+++ b/crates/screenpipe-db/src/db.rs@@ -6820,9 +6820,8 @@ LIMIT ? OFFSET ?let merged_start: Option<String> = row.try_get("ms")?;let merged_end: Option<String> = row.try_get("me")?;// Update the survivor row- let update_sql =- format!("UPDATE meetings SET meeting_start = ?1, meeting_end = ?2 WHERE id = ?3");- sqlx::query(&update_sql)+ let update_sql = "UPDATE meetings SET meeting_start = ?1, meeting_end = ?2 WHERE id = ?3";+ sqlx::query(update_sql).bind(&merged_start).bind(&merged_end).bind(survivor_id)@@ -7028,7 +7027,7 @@ LIMIT ? OFFSET ?sql.push_str(" ORDER BY importance DESC, created_at DESC LIMIT ?7 OFFSET ?8");- let fts_query = query.map(|q| crate::text_normalizer::sanitize_fts5_query(q));+ let fts_query = query.map(crate::text_normalizer::sanitize_fts5_query);sqlx::query_as::<_, MemoryRecord>(&sql).bind(fts_query.as_deref())@@ -7083,7 +7082,7 @@ LIMIT ? OFFSET ?sql.push_str(" AND created_at <= ?6");}- let fts_query = query.map(|q| crate::text_normalizer::sanitize_fts5_query(q));+ let fts_query = query.map(crate::text_normalizer::sanitize_fts5_query);sqlx::query_scalar::<_, i64>(&sql).bind(fts_query.as_deref())diff --git a/crates/screenpipe-db/src/write_queue.rs b/crates/screenpipe-db/src/write_queue.rsindex bb668378c..e8d31e0b2 100644--- a/crates/screenpipe-db/src/write_queue.rs+++ b/crates/screenpipe-db/src/write_queue.rs@@ -478,15 +478,13 @@ async fn execute_batch(*result = Err(sqlx::Error::WorkerCrashed);}}- } else {- if let Err(e) = sqlx::query("COMMIT").execute(&mut *conn).await {- warn!("write_queue: COMMIT failed: {}", e);- // All results become the commit error- for pw in batch.drain(..) {- let _ = pw.respond.send(Err(sqlx::Error::WorkerCrashed));- }- return;+ } else if let Err(e) = sqlx::query("COMMIT").execute(&mut *conn).await {+ warn!("write_queue: COMMIT failed: {}", e);+ // All results become the commit error+ for pw in batch.drain(..) {+ let _ = pw.respond.send(Err(sqlx::Error::WorkerCrashed));}+ return;}// Send results to callers@@ -1172,18 +1170,18 @@ async fn execute_single_write(VALUES (?, 'queued', ?, ?, ?, ?)RETURNING id"#,)- .bind(&pipe_name)- .bind(&trigger_type)- .bind(&model)- .bind(&provider)- .bind(&started_at)+ .bind(pipe_name)+ .bind(trigger_type)+ .bind(model)+ .bind(provider)+ .bind(started_at).fetch_one(&mut **conn).await?;Ok(WriteResult::Id(row))}WriteOp::PipeUpdateExecution { sql, binds } => {- let mut query = sqlx::query(&sql);+ let mut query = sqlx::query(sql);for bind in binds {match bind {PipeBindValue::Text(v) => {diff --git a/crates/screenpipe-engine/src/connections_api.rs b/crates/screenpipe-engine/src/connections_api.rsindex 84e72b6cc..e568e4eb2 100644--- a/crates/screenpipe-engine/src/connections_api.rs+++ b/crates/screenpipe-engine/src/connections_api.rs@@ -406,9 +406,10 @@ async fn oauth_callback(Query(params): Query<OAuthCallbackQuery>) -> (StatusCodelet (code, state) = match (params.code, params.state) {(Some(c), Some(s)) => (c, s),_ => {- let html = "<html><body style=\"font-family:system-ui;text-align:center;padding:60px\">\+ let html =+ "<html><body style=\"font-family:system-ui;text-align:center;padding:60px\">\<h2>Invalid callback</h2><p>Missing code or state parameter.</p></body></html>"- .to_string();+ .to_string();return (StatusCode::BAD_REQUEST, Html(html));}};@@ -421,12 +422,13 @@ async fn oauth_callback(Query(params): Query<OAuthCallbackQuery>) -> (StatusCodematch sender {Some(tx) => {let _ = tx.send(code);- let html = "<html><body style=\"font-family:system-ui;text-align:center;padding:60px\">\+ let html =+ "<html><body style=\"font-family:system-ui;text-align:center;padding:60px\">\<h2>Connected!</h2>\<p>You can close this tab and return to screenpipe.</p>\<script>window.close()</script>\</body></html>"- .to_string();+ .to_string();(StatusCode::OK, Html(html))}None => {diff --git a/crates/screenpipe-engine/src/meeting_detector.rs b/crates/screenpipe-engine/src/meeting_detector.rsindex ccc9a7b98..6085807aa 100644--- a/crates/screenpipe-engine/src/meeting_detector.rs+++ b/crates/screenpipe-engine/src/meeting_detector.rs@@ -2628,7 +2628,9 @@ mod tests {#[test]fn test_confirming_to_idle_timeout() {let state = MeetingState::Confirming {- since: Instant::now().checked_sub(CONFIRM_TIMEOUT + Duration::from_secs(1)).unwrap_or(Instant::now()),+ since: Instant::now()+ .checked_sub(CONFIRM_TIMEOUT + Duration::from_secs(1))+ .unwrap_or(Instant::now()),app: "Zoom".to_string(),profile_index: 0,};@@ -2742,7 +2744,9 @@ mod tests {meeting_id: 42,app: "Zoom".to_string(),started_at: Utc::now(),- since: Instant::now().checked_sub(ENDING_TIMEOUT + Duration::from_secs(1)).unwrap_or(Instant::now()),+ since: Instant::now()+ .checked_sub(ENDING_TIMEOUT + Duration::from_secs(1))+ .unwrap_or(Instant::now()),};let results: Vec<ScanResult> = vec![];let (new_state, action) = advance_state(state, &results);@@ -2795,7 +2799,9 @@ mod tests {meeting_id: 42,app: "Zoom".to_string(),started_at: Utc::now(),- since: Instant::now().checked_sub(ENDING_TIMEOUT + Duration::from_secs(1)).unwrap_or(Instant::now()),+ since: Instant::now()+ .checked_sub(ENDING_TIMEOUT + Duration::from_secs(1))+ .unwrap_or(Instant::now()),};let (state, action) = advance_state(state, &[]);assert!(matches!(state, MeetingState::Idle));@@ -2870,7 +2876,9 @@ mod tests {meeting_id: 42,app: "Zoom".to_string(),started_at: Utc::now(),- since: Instant::now().checked_sub(ENDING_TIMEOUT + Duration::from_secs(1)).unwrap_or(Instant::now()),+ since: Instant::now()+ .checked_sub(ENDING_TIMEOUT + Duration::from_secs(1))+ .unwrap_or(Instant::now()),};let (new_state, ended_id) = handle_no_apps_running(state);assert!(matches!(new_state, MeetingState::Idle));@@ -2897,7 +2905,9 @@ mod tests {meeting_id: -1,app: "Zoom".to_string(),started_at: Utc::now(),- since: Instant::now().checked_sub(ENDING_TIMEOUT + Duration::from_secs(1)).unwrap_or(Instant::now()),+ since: Instant::now()+ .checked_sub(ENDING_TIMEOUT + Duration::from_secs(1))+ .unwrap_or(Instant::now()),};let (_, ended_id) = handle_no_apps_running(state);assert!(ended_id.is_none(), "should not end meeting with id=-1");diff --git a/crates/screenpipe-engine/src/server.rs b/crates/screenpipe-engine/src/server.rsindex 15f440507..344401398 100644--- a/crates/screenpipe-engine/src/server.rs+++ b/crates/screenpipe-engine/src/server.rs@@ -168,7 +168,10 @@ async fn stats_handler(axum::extract::State(state): axum::extract::State<Arc<AppState>>,query: axum::extract::Query<std::collections::HashMap<String, String>>,) -> axum::Json<crate::stats::UserStats> {- let force = query.get("force_refresh").map(|v| v == "true").unwrap_or(false);+ let force = query+ .get("force_refresh")+ .map(|v| v == "true")+ .unwrap_or(false);let stats = if force {crate::stats::refresh_stats(&state.db).await} else {diff --git a/crates/screenpipe-engine/src/stats.rs b/crates/screenpipe-engine/src/stats.rsindex 6eaa47736..f3e999e23 100644--- a/crates/screenpipe-engine/src/stats.rs+++ b/crates/screenpipe-engine/src/stats.rs@@ -306,7 +306,9 @@ async fn compute_all_time_stats(db: &screenpipe_db::DatabaseManager) -> AllTimeSstreak += 1;// Compute previous dayif let Ok(parsed) = chrono::NaiveDate::parse_from_str(&expected, "%Y-%m-%d") {- expected = (parsed - chrono::Duration::days(1)).format("%Y-%m-%d").to_string();+ expected = (parsed - chrono::Duration::days(1))+ .format("%Y-%m-%d")+ .to_string();} else {break;}@@ -327,11 +329,10 @@ async fn compute_all_time_stats(db: &screenpipe_db::DatabaseManager) -> AllTimeS.unwrap_or(0);// Total meetings- let total_meetings: i64 =- sqlx::query_scalar("SELECT COUNT(*) FROM meetings")- .fetch_one(pool)- .await- .unwrap_or(0);+ let total_meetings: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM meetings")+ .fetch_one(pool)+ .await+ .unwrap_or(0);// Total distinct appslet total_apps: i64 = sqlx::query_scalar(@@ -342,13 +343,11 @@ async fn compute_all_time_stats(db: &screenpipe_db::DatabaseManager) -> AllTimeS.unwrap_or(0);// Recording since- let first_frame: Option<String> = sqlx::query_scalar(- "SELECT date(MIN(timestamp)) FROM frames",- )- .fetch_optional(pool)- .await- .ok()- .flatten();+ let first_frame: Option<String> = sqlx::query_scalar("SELECT date(MIN(timestamp)) FROM frames")+ .fetch_optional(pool)+ .await+ .ok()+ .flatten();AllTimeStats {recording_streak: streak,