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

chore: fix clippy warnings across crates

Louis Beaumont3c4b7fd360d0
diff --git a/crates/screenpipe-accessibility/src/events.rs b/crates/screenpipe-accessibility/src/events.rs
index c94b37ded..71ea792a7 100644
--- a/crates/screenpipe-accessibility/src/events.rs
+++ b/crates/screenpipe-accessibility/src/events.rs
@@ -353,6 +353,7 @@ impl EventType {
}
}
+ #[allow(clippy::should_implement_trait)]
pub fn from_str(s: &str) -> Option<Self> {
match s {
"click" | "c" => Some(EventType::Click),
diff --git a/crates/screenpipe-accessibility/src/platform/macos.rs b/crates/screenpipe-accessibility/src/platform/macos.rs
index 394e42784..a607d2da2 100644
--- a/crates/screenpipe-accessibility/src/platform/macos.rs
+++ b/crates/screenpipe-accessibility/src/platform/macos.rs
@@ -1198,7 +1198,7 @@ fn run_activity_only_tap(activity_feed: ActivityFeed, stop: Arc<AtomicBool>) {
cg::EventTapOpts::LISTEN_ONLY,
mask,
activity_only_callback,
- feed_ptr as *mut ActivityFeed,
+ feed_ptr,
);
let Some(tap) = tap else {
diff --git a/crates/screenpipe-core/src/embedding/model.rs b/crates/screenpipe-core/src/embedding/model.rs
index f5138a6a2..040a1bab7 100644
--- a/crates/screenpipe-core/src/embedding/model.rs
+++ b/crates/screenpipe-core/src/embedding/model.rs
@@ -16,18 +16,16 @@ impl EmbeddingModel {
let device = Device::new_metal(0).unwrap_or(Device::new_cuda(0).unwrap_or(Device::Cpu));
// default to jina-embeddings-v2-base-en if no paths provided
- let (model_path, tokenizer_path) = if model_path.is_none() || tokenizer_path.is_none() {
- let api = Api::new()?;
- let repo = api.repo(Repo::new(
- "jinaai/jina-embeddings-v2-base-en".to_string(),
- RepoType::Model,
- ));
- (repo.get("model.safetensors")?, repo.get("tokenizer.json")?)
- } else {
- (
- std::path::PathBuf::from(model_path.unwrap()),
- std::path::PathBuf::from(tokenizer_path.unwrap()),
- )
+ let (model_path, tokenizer_path) = match (model_path, tokenizer_path) {
+ (Some(m), Some(t)) => (std::path::PathBuf::from(m), std::path::PathBuf::from(t)),
+ _ => {
+ let api = Api::new()?;
+ let repo = api.repo(Repo::new(
+ "jinaai/jina-embeddings-v2-base-en".to_string(),
+ RepoType::Model,
+ ));
+ (repo.get("model.safetensors")?, repo.get("tokenizer.json")?)
+ }
};
let tokenizer = Tokenizer::from_file(tokenizer_path).map_err(E::msg)?;
diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rs
index a7318ff42..e8e07ce64 100644
--- a/crates/screenpipe-db/src/db.rs
+++ b/crates/screenpipe-db/src/db.rs
@@ -623,8 +623,9 @@ impl DatabaseManager {
///
/// # Arguments
/// * `offset_index` - The video frame index. Multiple window records from the same capture cycle
- /// should share the same offset_index to correctly reference the video frame.
- /// If None, auto-calculates based on DB records (legacy behavior, may cause mismatches).
+ /// should share the same offset_index to correctly reference the video frame.
+ /// If None, auto-calculates based on DB records (legacy behavior, may cause mismatches).
+ #[allow(clippy::too_many_arguments)]
pub async fn insert_frame(
&self,
device_name: &str,
diff --git a/crates/screenpipe-server/src/bin/screenpipe-server.rs b/crates/screenpipe-server/src/bin/screenpipe-server.rs
index 1149a4c66..dd83a6e38 100644
--- a/crates/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/crates/screenpipe-server/src/bin/screenpipe-server.rs
@@ -916,7 +916,7 @@ async fn main() -> anyhow::Result<()> {
languages: languages_clone.clone(),
capture_unfocused_windows: cli.capture_unfocused_windows,
realtime_vision: cli.enable_realtime_audio_transcription,
- activity_feed: activity_feed,
+ activity_feed,
video_quality: cli.video_quality.clone(),
};
Some(Arc::new(VisionManager::new(
@@ -1415,7 +1415,7 @@ async fn main() -> anyhow::Result<()> {
pub async fn handle_mcp_command(
command: &McpCommand,
- local_data_dir: &PathBuf,
+ local_data_dir: &std::path::Path,
) -> Result<(), anyhow::Error> {
let client = Client::new();
diff --git a/crates/screenpipe-server/src/cli.rs b/crates/screenpipe-server/src/cli.rs
index d170ad089..47e62d55a 100644
--- a/crates/screenpipe-server/src/cli.rs
+++ b/crates/screenpipe-server/src/cli.rs
@@ -375,11 +375,11 @@ impl Cli {
#[cfg(feature = "ui-events")]
pub fn to_ui_recorder_config(&self) -> crate::ui_recorder::UiRecorderConfig {
// Use sensible defaults - the single enable_ui_events flag controls everything
- let mut config = crate::ui_recorder::UiRecorderConfig::default();
- config.enabled = self.enable_ui_events;
- // Reuse ignored_windows for UI exclusion
- config.excluded_windows = self.ignored_windows.clone();
- config
+ crate::ui_recorder::UiRecorderConfig {
+ enabled: self.enable_ui_events,
+ excluded_windows: self.ignored_windows.clone(),
+ ..Default::default()
+ }
}
/// Create UI recorder configuration (stub when ui-events feature is disabled)
diff --git a/crates/screenpipe-server/src/core.rs b/crates/screenpipe-server/src/core.rs
index 17f4ce4e0..0e4e9d0f5 100644
--- a/crates/screenpipe-server/src/core.rs
+++ b/crates/screenpipe-server/src/core.rs
@@ -12,7 +12,7 @@ use std::time::Duration;
use tokio::runtime::Handle;
use tracing::{debug, error, info, warn};
-#[allow(clippy::too_many_arguments)]
+#[allow(clippy::too_many_arguments, clippy::clone_on_copy)]
pub async fn start_continuous_recording(
db: Arc<DatabaseManager>,
output_path: Arc<String>,
@@ -45,6 +45,7 @@ pub async fn start_continuous_recording(
let ignored_urls_video = ignored_urls.to_vec();
let languages = languages.clone();
+ #[allow(clippy::clone_on_copy)] // ActivityFeedOption is not Copy when adaptive-fps feature is enabled
let activity_feed = activity_feed.clone();
let video_quality = video_quality.clone();
diff --git a/crates/screenpipe-server/src/video.rs b/crates/screenpipe-server/src/video.rs
index 97482be48..bbd87113e 100644
--- a/crates/screenpipe-server/src/video.rs
+++ b/crates/screenpipe-server/src/video.rs
@@ -85,6 +85,11 @@ impl FrameWriteTracker {
pub fn len(&self) -> usize {
self.writes.len()
}
+
+ /// Check if there are no tracked frames.
+ pub fn is_empty(&self) -> bool {
+ self.writes.is_empty()
+ }
}
impl Default for FrameWriteTracker {
@@ -111,7 +116,7 @@ pub struct VideoCapture {
}
impl VideoCapture {
- #[allow(clippy::too_many_arguments)]
+ #[allow(clippy::too_many_arguments, clippy::clone_on_copy)]
pub fn new(
output_path: &str,
fps: f64,
@@ -511,6 +516,7 @@ async fn log_ffmpeg_output(stream: impl AsyncBufReadExt + Unpin, stream_name: &s
}
}
+#[allow(clippy::too_many_arguments)]
async fn save_frames_as_video(
frame_queue: &Arc<ArrayQueue<Arc<CaptureResult>>>,
output_path: &str,
diff --git a/crates/screenpipe-server/src/video_utils.rs b/crates/screenpipe-server/src/video_utils.rs
index 70ce8d1f8..b010fd25c 100644
--- a/crates/screenpipe-server/src/video_utils.rs
+++ b/crates/screenpipe-server/src/video_utils.rs
@@ -369,7 +369,7 @@ pub async fn extract_frames_from_video(
Ok(frames)
}
-async fn get_video_fps(ffmpeg_path: &PathBuf, video_path: &str) -> Result<f64> {
+async fn get_video_fps(ffmpeg_path: &std::path::Path, video_path: &str) -> Result<f64> {
let (fps, _) = get_video_fps_and_duration(ffmpeg_path, video_path).await?;
Ok(fps)
}
@@ -378,7 +378,10 @@ async fn get_video_fps(ffmpeg_path: &PathBuf, video_path: &str) -> Result<f64> {
/// Uses a global cache to avoid repeated ffprobe calls for the same video file.
/// This is critical for timeline performance - without caching, every frame
/// request spawns a new ffprobe process (~200-500ms overhead).
-async fn get_video_fps_and_duration(ffmpeg_path: &PathBuf, video_path: &str) -> Result<(f64, f64)> {
+async fn get_video_fps_and_duration(
+ ffmpeg_path: &std::path::Path,
+ video_path: &str,
+) -> Result<(f64, f64)> {
// Check cache first (fast path)
{
let cache = VIDEO_METADATA_CACHE.read().await;
@@ -420,7 +423,7 @@ async fn get_video_fps_and_duration(ffmpeg_path: &PathBuf, video_path: &str) ->
/// Internal function that actually calls ffprobe - used by the cached wrapper.
async fn get_video_fps_and_duration_uncached(
- ffmpeg_path: &PathBuf,
+ ffmpeg_path: &std::path::Path,
video_path: &str,
) -> Result<(f64, f64)> {
let ffprobe_path = get_ffprobe_path(ffmpeg_path);
diff --git a/crates/screenpipe-server/src/vision_manager/manager.rs b/crates/screenpipe-server/src/vision_manager/manager.rs
index 107efb9fc..54e97c7cd 100644
--- a/crates/screenpipe-server/src/vision_manager/manager.rs
+++ b/crates/screenpipe-server/src/vision_manager/manager.rs
@@ -133,6 +133,7 @@ impl VisionManager {
}
/// Start recording on a specific monitor
+ #[allow(clippy::clone_on_copy)] // ActivityFeedOption is not Copy when adaptive-fps feature is enabled
pub async fn start_monitor(&self, monitor_id: u32) -> Result<()> {
// Check if already recording
if self.recording_tasks.contains_key(&monitor_id) {
diff --git a/crates/screenpipe-vision/src/core.rs b/crates/screenpipe-vision/src/core.rs
index aff6dbc79..a696146d1 100644
--- a/crates/screenpipe-vision/src/core.rs
+++ b/crates/screenpipe-vision/src/core.rs
@@ -151,6 +151,7 @@ pub type ActivityFeedOption = Option<screenpipe_accessibility::ActivityFeed>;
#[cfg(not(feature = "adaptive-fps"))]
pub type ActivityFeedOption = Option<()>;
+#[allow(clippy::too_many_arguments)]
pub async fn continuous_capture(
result_tx: Sender<CaptureResult>,
interval: Duration,
@@ -317,7 +318,7 @@ pub async fn continuous_capture(
if current_diff > max_avg_value {
max_average = Some(MaxAverageFrame {
image: image.clone(),
- window_images: window_images,
+ window_images,
image_hash: 0, // Hash is now internal to FrameComparer
frame_number: frame_counter,
timestamp: Instant::now(),
diff --git a/crates/screenpipe-vision/src/ocr_cache.rs b/crates/screenpipe-vision/src/ocr_cache.rs
index dc3872536..e752e0558 100644
--- a/crates/screenpipe-vision/src/ocr_cache.rs
+++ b/crates/screenpipe-vision/src/ocr_cache.rs
@@ -43,11 +43,6 @@ impl WindowOcrCache {
}
}
- /// Create with default settings (5 minute max age, 100 entries)
- pub fn default() -> Self {
- Self::new(Duration::from_secs(300), 100)
- }
-
/// Calculate hash for an image's raw bytes
pub fn calculate_image_hash(image_bytes: &[u8]) -> u64 {
let mut hasher = DefaultHasher::new();
@@ -140,6 +135,13 @@ impl WindowOcrCache {
}
}
+impl Default for WindowOcrCache {
+ /// Create with default settings (5 minute max age, 100 entries)
+ fn default() -> Self {
+ Self::new(Duration::from_secs(300), 100)
+ }
+}
+
#[derive(Debug, Clone)]
pub struct CacheStats {
pub entries: usize,