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
fix(rust): clean clippy warnings
Louis Beaumont44241935a0b0
diff --git a/crates/screenpipe-a11y/src/tree/macos.rs b/crates/screenpipe-a11y/src/tree/macos.rsindex d10a5f6ed..3ada58b5f 100644--- a/crates/screenpipe-a11y/src/tree/macos.rs+++ b/crates/screenpipe-a11y/src/tree/macos.rs@@ -386,7 +386,7 @@ impl MacosTreeWalker {let ama_attr = ax::Attr::with_string(&ama_attr_name);let focused_editability = focused_element_editability(&ax_app);- if enhanced_ax_mode_already_enabled(&ax_app, &eui_attr, &ama_attr) {+ if enhanced_ax_mode_already_enabled(&ax_app, eui_attr, ama_attr) {debug!("enhanced AX mode already enabled for pid={} app={}; skipping re-assert",pid, app_name@@ -890,8 +890,8 @@ fn vscode_terminal_window_name(ax_app: &ax::UiElement) -> Option<String> {return None;}let search_end = (list_idx + 12).min(steps);- for k in (list_idx + 1)..search_end {- let elem: &ax::UiElement = unsafe { std::mem::transmute(&*ancestors[k]) };+ for ancestor in ancestors.iter().take(search_end).skip(list_idx + 1) {+ let elem: &ax::UiElement = unsafe { std::mem::transmute(&**ancestor) };for attr in [ax::attr::desc(), ax::attr::title()] {if let Some(val) = get_string_attr(elem, attr) {if let Some(name) = parse_vscode_terminal_name(&val)@@ -1058,16 +1058,16 @@ fn walk_element(elem: &ax::UiElement, depth: usize, state: &mut WalkState) {}}let is_vscode_terminal_list = is_vscode_terminal_list_role(&role_str, depth, &state.app);- if is_vscode_terminal_list {- if matches!(+ if is_vscode_terminal_list+ && matches!(state.app,AppState::VsCode {mode: VsCodeMode::Editor,..}- ) {- return; // prune entire terminal subtree — no children walked, no text emitted- }+ )+ {+ return; // prune entire terminal subtree — no children walked, no text emitted}// Extract text from this element.@@ -1449,7 +1449,7 @@ fn ui_element_attr(elem: &ax::UiElement, attr: &ax::Attr) -> Option<Retained<ax:if val.get_type_id() != ax::UiElement::type_id() {return None;}- Some(unsafe { std::mem::transmute(val) })+ Some(unsafe { std::mem::transmute::<Retained<cf::Type>, Retained<ax::UiElement>>(val) })}fn resolve_focused_window(@@ -1554,7 +1554,7 @@ fn focused_element_editability(app: &ax::UiElement) -> FocusEditability {}let editable_attr_name = cf::String::from_str("AXEditable");let editable_attr = ax::Attr::with_string(&editable_attr_name);- if get_bool_attr(elem, &editable_attr).unwrap_or(false) {+ if get_bool_attr(elem, editable_attr).unwrap_or(false) {FocusEditability::Editable} else {FocusEditability::NotEditablediff --git a/crates/screenpipe-audio-eval/src/bin/eval_transcription.rs b/crates/screenpipe-audio-eval/src/bin/eval_transcription.rsindex a4f35518f..beb36380d 100644--- a/crates/screenpipe-audio-eval/src/bin/eval_transcription.rs+++ b/crates/screenpipe-audio-eval/src/bin/eval_transcription.rs@@ -132,115 +132,6 @@ fn parse_models(spec: &str, default_cap: usize) -> Result<Vec<ModelSpec>> {Ok(out)}-#[cfg(test)]-mod tests {- use super::*;-- #[test]- fn single_model_no_cap_uses_default() {- let specs = parse_models("tiny", 50).unwrap();- assert_eq!(specs.len(), 1);- assert_eq!(specs[0].name, "tiny");- assert_eq!(specs[0].cap, 50);- assert!(matches!(- specs[0].engine,- AudioTranscriptionEngine::WhisperTiny- ));- }-- #[test]- fn cap_override_wins_over_default() {- let specs = parse_models("tiny=10", 50).unwrap();- assert_eq!(specs[0].cap, 10);- }-- #[test]- fn multiple_models_preserve_order() {- let specs =- parse_models("tiny=50,whisper-large-v3-turbo-quantized=20,parakeet", 30).unwrap();- assert_eq!(specs.len(), 3);- assert_eq!(specs[0].name, "tiny");- assert_eq!(specs[0].cap, 50);- assert_eq!(specs[1].name, "whisper-large-v3-turbo-quantized");- assert_eq!(specs[1].cap, 20);- assert_eq!(specs[2].name, "parakeet");- // parakeet falls back to default since no =N was provided.- assert_eq!(specs[2].cap, 30);- }-- #[test]- fn whitespace_and_empty_entries_tolerated() {- let specs = parse_models(" tiny ,, , parakeet=5 ", 50).unwrap();- assert_eq!(specs.len(), 2);- assert_eq!(specs[0].name, "tiny");- assert_eq!(specs[1].name, "parakeet");- assert_eq!(specs[1].cap, 5);- }-- #[test]- fn unknown_model_errors_with_clear_message() {- let err = parse_models("bogus-engine", 50).unwrap_err().to_string();- assert!(- err.contains("unknown model"),- "expected 'unknown model' in: {err}"- );- }-- #[test]- fn base_alias_rejected_not_silently_remapped() {- let err = parse_models("base", 50).unwrap_err().to_string();- // Don't silently fall through to tiny — surface a clear error so the- // CI report doesn't mislead.- assert!(- err.contains("not a screenpipe engine variant"),- "expected explicit rejection in: {err}"- );- }-- #[test]- fn empty_spec_errors() {- let err = parse_models("", 50).unwrap_err().to_string();- assert!(err.contains("empty"), "expected 'empty' in: {err}");- let err2 = parse_models(" , , ", 50).unwrap_err().to_string();- assert!(err2.contains("empty"), "expected 'empty' in: {err2}");- }-- #[test]- fn zero_cap_rejected() {- let err = parse_models("tiny=0", 50).unwrap_err().to_string();- assert!(err.contains("is 0"), "expected '=0' rejection in: {err}");- }-- #[test]- fn non_numeric_cap_errors() {- let err = parse_models("tiny=lots", 50).unwrap_err().to_string();- assert!(- err.contains("invalid cap"),- "expected parse error in: {err}"- );- }-- #[test]- fn whisper_aliases_resolve() {- assert!(matches!(- parse_engine("whisper-tiny").unwrap(),- AudioTranscriptionEngine::WhisperTiny- ));- assert!(matches!(- parse_engine("whisper-large").unwrap(),- AudioTranscriptionEngine::WhisperLargeV3- ));- assert!(matches!(- parse_engine("whisper-large-v3-turbo-quantized").unwrap(),- AudioTranscriptionEngine::WhisperLargeV3TurboQuantized- ));- assert!(matches!(- parse_engine("parakeet").unwrap(),- AudioTranscriptionEngine::Parakeet- ));- }-}-/// Ensure the model weights are on disk before constructing the engine./// Whisper variants go through screenpipe's own HF helper; Parakeet goes/// through audiopipe directly because the engine constructor only does a@@ -426,3 +317,112 @@ async fn main() -> Result<()> {}Ok(())}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn single_model_no_cap_uses_default() {+ let specs = parse_models("tiny", 50).unwrap();+ assert_eq!(specs.len(), 1);+ assert_eq!(specs[0].name, "tiny");+ assert_eq!(specs[0].cap, 50);+ assert!(matches!(+ specs[0].engine,+ AudioTranscriptionEngine::WhisperTiny+ ));+ }++ #[test]+ fn cap_override_wins_over_default() {+ let specs = parse_models("tiny=10", 50).unwrap();+ assert_eq!(specs[0].cap, 10);+ }++ #[test]+ fn multiple_models_preserve_order() {+ let specs =+ parse_models("tiny=50,whisper-large-v3-turbo-quantized=20,parakeet", 30).unwrap();+ assert_eq!(specs.len(), 3);+ assert_eq!(specs[0].name, "tiny");+ assert_eq!(specs[0].cap, 50);+ assert_eq!(specs[1].name, "whisper-large-v3-turbo-quantized");+ assert_eq!(specs[1].cap, 20);+ assert_eq!(specs[2].name, "parakeet");+ // parakeet falls back to default since no =N was provided.+ assert_eq!(specs[2].cap, 30);+ }++ #[test]+ fn whitespace_and_empty_entries_tolerated() {+ let specs = parse_models(" tiny ,, , parakeet=5 ", 50).unwrap();+ assert_eq!(specs.len(), 2);+ assert_eq!(specs[0].name, "tiny");+ assert_eq!(specs[1].name, "parakeet");+ assert_eq!(specs[1].cap, 5);+ }++ #[test]+ fn unknown_model_errors_with_clear_message() {+ let err = parse_models("bogus-engine", 50).unwrap_err().to_string();+ assert!(+ err.contains("unknown model"),+ "expected 'unknown model' in: {err}"+ );+ }++ #[test]+ fn base_alias_rejected_not_silently_remapped() {+ let err = parse_models("base", 50).unwrap_err().to_string();+ // Don't silently fall through to tiny — surface a clear error so the+ // CI report doesn't mislead.+ assert!(+ err.contains("not a screenpipe engine variant"),+ "expected explicit rejection in: {err}"+ );+ }++ #[test]+ fn empty_spec_errors() {+ let err = parse_models("", 50).unwrap_err().to_string();+ assert!(err.contains("empty"), "expected 'empty' in: {err}");+ let err2 = parse_models(" , , ", 50).unwrap_err().to_string();+ assert!(err2.contains("empty"), "expected 'empty' in: {err2}");+ }++ #[test]+ fn zero_cap_rejected() {+ let err = parse_models("tiny=0", 50).unwrap_err().to_string();+ assert!(err.contains("is 0"), "expected '=0' rejection in: {err}");+ }++ #[test]+ fn non_numeric_cap_errors() {+ let err = parse_models("tiny=lots", 50).unwrap_err().to_string();+ assert!(+ err.contains("invalid cap"),+ "expected parse error in: {err}"+ );+ }++ #[test]+ fn whisper_aliases_resolve() {+ assert!(matches!(+ parse_engine("whisper-tiny").unwrap(),+ AudioTranscriptionEngine::WhisperTiny+ ));+ assert!(matches!(+ parse_engine("whisper-large").unwrap(),+ AudioTranscriptionEngine::WhisperLargeV3+ ));+ assert!(matches!(+ parse_engine("whisper-large-v3-turbo-quantized").unwrap(),+ AudioTranscriptionEngine::WhisperLargeV3TurboQuantized+ ));+ assert!(matches!(+ parse_engine("parakeet").unwrap(),+ AudioTranscriptionEngine::Parakeet+ ));+ }+}diff --git a/crates/screenpipe-audio/src/core/process_tap.rs b/crates/screenpipe-audio/src/core/process_tap.rsindex d569c6545..004125a32 100644--- a/crates/screenpipe-audio/src/core/process_tap.rs+++ b/crates/screenpipe-audio/src/core/process_tap.rs@@ -534,10 +534,7 @@ fn build_capture(// at 96kHz (common for headphone DACs), asbd may still report 48kHz, causing// the recording pipeline to interpret 1.44M samples as 30s @ 48kHz when// they're actually 15s @ 96kHz — produces files that play at 2x slowmo.- let sample_rate = agg_device- .nominal_sample_rate()- .map(|r| r as f64)- .unwrap_or(asbd.sample_rate);+ let sample_rate = agg_device.nominal_sample_rate().unwrap_or(asbd.sample_rate);info!("Process Tap: {:.0} Hz (asbd reported {:.0} Hz), {} ch, {} bit",sample_rate, asbd.sample_rate, channels, asbd.bits_per_channeldiff --git a/crates/screenpipe-audio/src/core/stream.rs b/crates/screenpipe-audio/src/core/stream.rsindex 4dd9b1d67..dee11ca90 100644--- a/crates/screenpipe-audio/src/core/stream.rs+++ b/crates/screenpipe-audio/src/core/stream.rs@@ -227,6 +227,7 @@ impl AudioStream {/// Start the standard cpal/SCK audio stream. Shared by all platforms/// and used as fallback when Process Tap is unavailable or fails.+ #[allow(clippy::too_many_arguments)]#[cfg(not(all(target_os = "linux", feature = "pulseaudio")))]async fn start_cpal_stream(device: &Arc<AudioDevice>,@@ -840,13 +841,13 @@ where{#[cfg(target_os = "macos")]{- return build_cpal_input_stream(+ build_cpal_input_stream(device,stream_config,data_callback,error_callback,macos_voice_processing_config(macos_input_vpio),- );+ )}#[cfg(not(target_os = "macos"))]{diff --git a/crates/screenpipe-connect/src/connections/mod.rs b/crates/screenpipe-connect/src/connections/mod.rsindex 7e00f9a06..12ab2f86c 100644--- a/crates/screenpipe-connect/src/connections/mod.rs+++ b/crates/screenpipe-connect/src/connections/mod.rs@@ -161,19 +161,13 @@ pub enum ProxyAuth {/// whenever the last successful refresh is older than this duration, even/// if the access token is still valid. The value should leave headroom/// against the provider's published limit (e.g. Zoom's 15h ⇒ 12h floor).-#[derive(Debug, Clone, Copy)]+#[derive(Debug, Clone, Copy, Default)]pub struct RefreshPolicy {/// Maximum gap between successful refreshes. `None` = no keep-alive/// pressure beyond the access-token-expiry path.pub keep_alive: Option<std::time::Duration>,}-impl Default for RefreshPolicy {- fn default() -> Self {- Self { keep_alive: None }- }-}-#[async_trait]pub trait Integration: Send + Sync {/// Static metadata for this integration.diff --git a/crates/screenpipe-connect/src/mcp_servers.rs b/crates/screenpipe-connect/src/mcp_servers.rsindex ba2bdbe18..580ef5ce8 100644--- a/crates/screenpipe-connect/src/mcp_servers.rs+++ b/crates/screenpipe-connect/src/mcp_servers.rs@@ -704,7 +704,7 @@ impl McpServerStore {let Some(ss) = &self.secret_store else {return Ok(None);};- Ok(ss.get_json::<McpOAuthToken>(&oauth_token_key(id)).await?)+ ss.get_json::<McpOAuthToken>(&oauth_token_key(id)).await}async fn write_oauth_token(&self, id: &str, token: McpOAuthToken) -> Result<()> {diff --git a/crates/screenpipe-connect/src/oauth.rs b/crates/screenpipe-connect/src/oauth.rsindex efb7e6690..3a1001488 100644--- a/crates/screenpipe-connect/src/oauth.rs+++ b/crates/screenpipe-connect/src/oauth.rs@@ -1355,7 +1355,7 @@ mod tests {assert_eq!(merged["access_token"], "new");assert_eq!(merged["refresh_token"], "rt");assert!(- merged.get("expires_at").map_or(true, Value::is_null),+ merged.get("expires_at").is_none_or(Value::is_null),"stale expires_at must not survive a refresh that produced a new access_token; got {:?}",merged.get("expires_at"),);@@ -1381,7 +1381,7 @@ mod tests {});let merged = merge_refresh_response(&stored, &resp);assert!(- merged.get("expires_at").map_or(true, Value::is_null),+ merged.get("expires_at").is_none_or(Value::is_null),"merge should defer expires_at to write_oauth_token_instance");assert_eq!(merged["expires_in"], 3599);diff --git a/crates/screenpipe-engine/src/cli/search.rs b/crates/screenpipe-engine/src/cli/search.rsindex 1bfd0dda0..4364c9054 100644--- a/crates/screenpipe-engine/src/cli/search.rs+++ b/crates/screenpipe-engine/src/cli/search.rs@@ -196,7 +196,7 @@ fn print_text(items: &[ContentItem]) {fn one_line(s: &str) -> String {// Collapse newlines so each result stays on one terminal line.- s.replace('\n', " ").replace('\r', " ")+ s.replace(['\n', '\r'], " ")}#[cfg(test)]diff --git a/crates/screenpipe-engine/src/event_driven_capture.rs b/crates/screenpipe-engine/src/event_driven_capture.rsindex c3792be5b..cb717cbee 100644--- a/crates/screenpipe-engine/src/event_driven_capture.rs+++ b/crates/screenpipe-engine/src/event_driven_capture.rs@@ -571,7 +571,7 @@ pub async fn event_driven_capture_loop(let current_monitors = list_monitors().await;let all_monitor_bounds = current_monitors.iter()- .map(|monitor| monitor_bounds(monitor))+ .map(monitor_bounds).collect::<Vec<_>>();let idle_phase_delay = idle_phase_delay(&monitor,@@ -1688,6 +1688,7 @@ fn bypasses_capture_throttles(trigger: &CaptureTrigger) -> bool {////// `hd_active` bypasses content dedup entirely for this capture — see/// [`dedup_applies`].+#[allow(clippy::too_many_arguments)]async fn do_capture(params: &CaptureParams<'_>,trigger: &CaptureTrigger,diff --git a/crates/screenpipe-engine/src/high_fps_controller.rs b/crates/screenpipe-engine/src/high_fps_controller.rsindex 4b97c0de2..58eac2146 100644--- a/crates/screenpipe-engine/src/high_fps_controller.rs+++ b/crates/screenpipe-engine/src/high_fps_controller.rs@@ -69,7 +69,7 @@ pub const MIN_TIMER_DURATION: Duration = Duration::from_secs(60);/// Max time a `PrewarmPending` session waits for `meeting_started` before/// self-expiring. 30 minutes is the prewarm-notification lookahead ceiling-/// + a buffer for late starts. If no meeting arrives in this window, the+/// + a buffer for late starts. If no meeting arrives in this window, the/// session expires without ever upgrading.pub const PREWARM_WAIT: Duration = Duration::from_secs(30 * 60);diff --git a/crates/screenpipe-engine/src/mcp_servers_api.rs b/crates/screenpipe-engine/src/mcp_servers_api.rsindex 35f06bd6e..2ba738062 100644--- a/crates/screenpipe-engine/src/mcp_servers_api.rs+++ b/crates/screenpipe-engine/src/mcp_servers_api.rs@@ -239,9 +239,7 @@ async fn delete_server(State(state): State<McpServersState>, Path(id): Path<Strifn validate_headers(headers: &[McpHeader]) -> Result<(), String> {for h in headers {if h.name.bytes().any(|b| b == b'\r' || b == b'\n' || b == 0) {- return Err(format!(- "header name contains a CR/LF/NUL byte — refusing to send"- ));+ return Err("header name contains a CR/LF/NUL byte — refusing to send".to_string());}if h.value.bytes().any(|b| b == b'\r' || b == b'\n' || b == 0) {return Err(format!(diff --git a/crates/screenpipe-engine/src/meeting_detector.rs b/crates/screenpipe-engine/src/meeting_detector.rsindex 2e7da7e7c..596c35d1e 100644--- a/crates/screenpipe-engine/src/meeting_detector.rs+++ b/crates/screenpipe-engine/src/meeting_detector.rs@@ -3177,7 +3177,7 @@ mod tests {#[test]fn attr_needs_identifier_only_signals() {- let signals = vec![+ let signals = [CallSignal::AutomationId("foo"),CallSignal::AutomationIdContains("bar"),CallSignal::MenuItemId("baz"),@@ -3195,7 +3195,7 @@ mod tests {#[test]fn attr_needs_title_only_signals() {- let signals = vec![+ let signals = [CallSignal::MenuBarItem {title_contains: "Meeting",},@@ -3216,7 +3216,7 @@ mod tests {#[test]fn attr_needs_title_and_desc_signals() {- let signals = vec![+ let signals = [CallSignal::NameContains("Leave call"),CallSignal::KeyboardShortcut("⌘⇧M"),CallSignal::RoleWithName {@@ -3237,7 +3237,7 @@ mod tests {#[test]fn attr_needs_mixed_signals_unions_all_attrs() {- let signals = vec![+ let signals = [CallSignal::AutomationId("foo"),CallSignal::NameContains("Leave"),];@@ -3628,7 +3628,7 @@ mod tests {let must_be_path_qualified = ["cal.com", "dialpad.com"];for host in must_be_path_qualified {- let bare_present = patterns.iter().any(|p| *p == host);+ let bare_present = patterns.contains(&host);assert!(!bare_present,"url pattern {host:?} must be path-qualified (e.g. {host}/<call-route>), \diff --git a/crates/screenpipe-engine/src/routes/streaming.rs b/crates/screenpipe-engine/src/routes/streaming.rsindex d084b2817..92357427d 100644--- a/crates/screenpipe-engine/src/routes/streaming.rs+++ b/crates/screenpipe-engine/src/routes/streaming.rs@@ -6,11 +6,10 @@ use axum::{body::Body,extract::{ws::{Message, WebSocket, WebSocketUpgrade},- Query, State,+ State,},http::StatusCode,response::{IntoResponse, Response},- Json,};use chrono::{DateTime, Utc};@@ -716,34 +715,6 @@ async fn send_batch(Ok(())}-#[derive(Debug, Deserialize)]-#[serde(rename_all = "snake_case")]-pub struct VideoExportRequest {- #[serde(default, deserialize_with = "deserialize_frame_ids_optional")]- frame_ids: Vec<i64>,- #[serde(default = "default_fps")]- fps: f64,-}--fn default_fps() -> f64 {- 0.5-}--fn deserialize_frame_ids_optional<'de, D>(deserializer: D) -> Result<Vec<i64>, D::Error>-where- D: serde::Deserializer<'de>,-{- let s: Option<String> = Option::deserialize(deserializer)?;- match s {- Some(s) if !s.is_empty() => s- .split(',')- .map(|id| id.trim().parse::<i64>())- .collect::<Result<Vec<_>, _>>()- .map_err(serde::de::Error::custom),- _ => Ok(Vec::new()),- }-}-#[cfg(test)]mod tests {use super::*;diff --git a/crates/screenpipe-engine/src/ui_recorder.rs b/crates/screenpipe-engine/src/ui_recorder.rsindex 0e1348a18..ca715b833 100644--- a/crates/screenpipe-engine/src/ui_recorder.rs+++ b/crates/screenpipe-engine/src/ui_recorder.rs@@ -1302,17 +1302,21 @@ mod tests {fn window_focus_capture_is_always_enabled() {assert!(UiRecorderConfig::default().capture_window_focus);- let mut config = UiRecorderConfig::default();- config.capture_window_focus = false;+ let config = UiRecorderConfig {+ capture_window_focus: false,+ ..Default::default()+ };assert!(config.to_ui_config().capture_window_focus);}#[test]fn clipboard_trigger_detection_does_not_require_clipboard_storage() {- let mut config = UiRecorderConfig::default();- config.capture_clipboard = false;- config.capture_clipboard_content = true;- config.capture_on_clipboard = true;+ let config = UiRecorderConfig {+ capture_clipboard: false,+ capture_clipboard_content: true,+ capture_on_clipboard: true,+ ..Default::default()+ };let ui_config = config.to_ui_config();diff --git a/crates/screenpipe-engine/src/vision_manager/manager.rs b/crates/screenpipe-engine/src/vision_manager/manager.rsindex bf0d9ab55..bfa5437e9 100644--- a/crates/screenpipe-engine/src/vision_manager/manager.rs+++ b/crates/screenpipe-engine/src/vision_manager/manager.rs@@ -707,7 +707,7 @@ mod tests {.expect("expected Ok via stale-id fallback when monitors exist");assert!(- vm.recording_tasks.len() > 0,+ !vm.recording_tasks.is_empty(),"fallback should start at least one monitor task");assert_eq!(vm.status().await, VisionManagerStatus::Running);diff --git a/crates/screenpipe-events/src/custom_events/meetings.rs b/crates/screenpipe-events/src/custom_events/meetings.rsindex 34e41bd2c..86aba6f15 100644--- a/crates/screenpipe-events/src/custom_events/meetings.rs+++ b/crates/screenpipe-events/src/custom_events/meetings.rs@@ -89,7 +89,7 @@ fn extract_join_url(event: &CalendarEventSignal) -> Option<String> {let trimmed = raw.trim().trim_matches(|c| matches!(c, '<' | '>' | '"' | '\''))- .trim_end_matches(|c| matches!(c, ')' | ']' | ',' | '.' | ';'));+ .trim_end_matches([')', ']', ',', '.', ';']);if trimmed.is_empty() || !known(trimmed) {return None;}