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: Pi bun discovery + remove all compiler warnings
Louis Beaumonted7a81ecb477
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rsindex 671e1956e..6bac4dd12 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs@@ -760,6 +760,16 @@ pub fn kill(pid: u32) -> Result<(), String> {/// Find bun executable (shared by pi_install and ensure_pi_installed_background)fn find_bun_executable() -> Option<String> {+ // First check next to our own executable (bundled bun in AppData/Local/screenpipe/)+ if let Ok(exe_path) = std::env::current_exe() {+ if let Some(exe_folder) = exe_path.parent() {+ let bundled = exe_folder.join(if cfg!(windows) { "bun.exe" } else { "bun" });+ if bundled.exists() {+ return Some(bundled.to_string_lossy().to_string());+ }+ }+ }+let home = dirs::home_dir().map(|h| h.to_string_lossy().to_string()).unwrap_or_default();@@ -914,8 +924,27 @@ mod tests {#[cfg(windows)]fn test_parse_where_output_unix_line_endings() {let output = "C:\\Users\\npm\\pi\nC:\\Users\\npm\\pi.cmd\n";-+let result = parse_where_output(output);assert_eq!(result, Some("C:\\Users\\npm\\pi.cmd".to_string()));}++ /// Test that find_bun_executable checks the exe directory (bundled bun)+ #[test]+ fn test_find_bun_checks_exe_dir() {+ use super::find_bun_executable;+ // On the installed app, bun.exe lives next to screenpipe-app.exe+ // in AppData/Local/screenpipe/. This test verifies the function+ // at least runs without panicking and checks the exe dir first.+ let result = find_bun_executable();+ // We can't guarantee bun exists in CI, but we verify no panic+ // and that if it IS found, the path is valid+ if let Some(ref path) = result {+ assert!(+ std::path::Path::new(path).exists(),+ "find_bun_executable returned non-existent path: {}",+ path+ );+ }+ }}diff --git a/crates/screenpipe-accessibility/src/platform/windows.rs b/crates/screenpipe-accessibility/src/platform/windows.rsindex 28a7d481a..7c6ebf77a 100644--- a/crates/screenpipe-accessibility/src/platform/windows.rs+++ b/crates/screenpipe-accessibility/src/platform/windows.rs@@ -4,7 +4,7 @@use crate::activity_feed::{ActivityFeed, ActivityKind};use crate::config::UiCaptureConfig;-use crate::events::{ElementContext, EventData, UiEvent};+use crate::events::{EventData, UiEvent};use anyhow::Result;use chrono::Utc;use crossbeam_channel::{bounded, Receiver, Sender};@@ -14,7 +14,7 @@ use std::sync::atomic::{AtomicBool, Ordering};use std::sync::Arc;use std::thread;use std::time::Instant;-use tracing::{debug, error, warn};+use tracing::{debug, error};use windows::Win32::Foundation::{HINSTANCE, HWND, LPARAM, LRESULT, WPARAM};use windows::Win32::System::LibraryLoader::GetModuleHandleW;@@ -26,8 +26,8 @@ use windows::Win32::UI::WindowsAndMessaging::{CallNextHookEx, DispatchMessageW, GetForegroundWindow, GetMessageW, GetWindowTextW,GetWindowThreadProcessId, SetWindowsHookExW, TranslateMessage, UnhookWindowsHookEx, HC_ACTION,HHOOK, KBDLLHOOKSTRUCT, MSG, MSLLHOOKSTRUCT, WH_KEYBOARD_LL, WH_MOUSE_LL, WM_KEYDOWN, WM_KEYUP,- WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEMOVE, WM_MOUSEWHEEL,- WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_XBUTTONDOWN, WM_XBUTTONUP,+ WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_MOUSEMOVE, WM_MOUSEWHEEL,+ WM_RBUTTONDOWN, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_XBUTTONDOWN,};/// Permission status for UI capturediff --git a/crates/screenpipe-core/src/pipes.rs b/crates/screenpipe-core/src/pipes.rsindex 4e05d8d3d..b0b23f823 100644--- a/crates/screenpipe-core/src/pipes.rs+++ b/crates/screenpipe-core/src/pipes.rs@@ -36,10 +36,6 @@ use reqwest_middleware::ClientBuilder;use std::collections::HashSet;use std::str::FromStr;-// Add at top of file with other imports-#[cfg(windows)]-use std::os::windows::process::CommandExt;-#[derive(Clone, Debug, Copy)]pub enum PipeState {Port(u16),@@ -314,7 +310,6 @@ async fn spawn_watchdog(parent_pid: u32, child_pid: u32) -> Result<tokio::procesid));{- use std::os::windows::process::CommandExt;ps_cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW}let output = ps_cmd.output().await;@@ -537,7 +532,6 @@ pub async fn run_pipe(.env("BUN_CONFIG_REGISTRY", "https://registry.npmjs.org");#[cfg(target_os = "windows")]{- use std::os::windows::process::CommandExt;install_cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW}let install_output = install_cmd.output().await?;@@ -625,7 +619,6 @@ pub async fn run_pipe(#[cfg(target_os = "windows")]{- use std::os::windows::process::CommandExt;command.creation_flags(0x08000000); // CREATE_NO_WINDOW}@@ -673,7 +666,6 @@ pub async fn run_pipe(.stderr(std::process::Stdio::piped());#[cfg(target_os = "windows")]{- use std::os::windows::process::CommandExt;cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW}let mut child = cmd.spawn()?;@@ -809,7 +801,6 @@ async fn retry_install(bun_path: &Path, dest_dir: &Path, max_retries: u32) -> Re.stderr(std::process::Stdio::piped());#[cfg(target_os = "windows")]{- use std::os::windows::process::CommandExt;install_cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW}let mut install_child = install_cmd.spawn()?;@@ -1608,7 +1599,6 @@ async fn try_build_nextjs(pipe_dir: &Path, bun_path: &Path) -> Result<BuildStatu.current_dir(pipe_dir);#[cfg(target_os = "windows")]{- use std::os::windows::process::CommandExt;build_cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW}let build_output = build_cmd.output().await?;diff --git a/crates/screenpipe-server/src/analytics.rs b/crates/screenpipe-server/src/analytics.rsindex 3eb7487ff..b24804029 100644--- a/crates/screenpipe-server/src/analytics.rs+++ b/crates/screenpipe-server/src/analytics.rs@@ -3,8 +3,9 @@ use reqwest::Client;use serde_json::{json, Value};use std::env;use std::sync::atomic::{AtomicBool, Ordering};-use sysinfo::{System, SystemExt};-use tracing::{debug, error, trace, warn};+#[cfg(target_os = "macos")]+use sysinfo::System;+use tracing::{debug, error, trace};const POSTHOG_API_KEY: &str = "phc_Bt8GoTBPgkCpDrbaIZzJIEYt0CrJjhBiuLaBck1clce";const POSTHOG_HOST: &str = "https://eu.i.posthog.com";diff --git a/crates/screenpipe-server/src/sleep_monitor.rs b/crates/screenpipe-server/src/sleep_monitor.rsindex ea6212709..7c1e126b0 100644--- a/crates/screenpipe-server/src/sleep_monitor.rs+++ b/crates/screenpipe-server/src/sleep_monitor.rs@@ -7,10 +7,15 @@//! Future work: Trigger component reinitialization on wake events.use std::sync::atomic::{AtomicBool, Ordering};+#[cfg(target_os = "macos")]use std::time::Duration;-use tracing::{debug, error, info, warn};+use tracing::debug;+#[cfg(target_os = "macos")]+use tracing::{error, info, warn};+#[cfg(target_os = "macos")]use crate::analytics::capture_event_nonblocking;+#[cfg(target_os = "macos")]use serde_json::json;/// Tracks whether the system is currently in a "post-wake" state@@ -115,6 +120,7 @@ pub fn start_sleep_monitor() {}/// Called when system is about to sleep+#[cfg(target_os = "macos")]fn on_will_sleep() {capture_event_nonblocking("system_will_sleep",@@ -125,6 +131,7 @@ fn on_will_sleep() {}/// Called when system wakes from sleep+#[cfg(target_os = "macos")]fn on_did_wake(handle: &tokio::runtime::Handle) {// Mark that we recently wokeRECENTLY_WOKE.store(true, Ordering::SeqCst);@@ -164,6 +171,7 @@ fn on_did_wake(handle: &tokio::runtime::Handle) {/// Check if audio and vision recording are healthy/// Returns (audio_healthy, vision_healthy)+#[cfg(target_os = "macos")]async fn check_recording_health() -> (bool, bool) {// Try to hit the local health endpointlet client = reqwest::Client::new();diff --git a/crates/screenpipe-server/src/video.rs b/crates/screenpipe-server/src/video.rsindex a612acefa..115c14548 100644--- a/crates/screenpipe-server/src/video.rs+++ b/crates/screenpipe-server/src/video.rs@@ -479,7 +479,6 @@ pub async fn start_ffmpeg_process(output_file: &str, fps: f64, video_quality: &s#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;command.creation_flags(CREATE_NO_WINDOW);}diff --git a/crates/screenpipe-server/src/video_cache.rs b/crates/screenpipe-server/src/video_cache.rsindex 6570e4625..30a642079 100644--- a/crates/screenpipe-server/src/video_cache.rs+++ b/crates/screenpipe-server/src/video_cache.rs@@ -747,7 +747,6 @@ async fn extract_frame(#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;cmd.creation_flags(CREATE_NO_WINDOW);}@@ -867,7 +866,6 @@ async fn is_video_file_complete(ffmpeg_path: &PathBuf, file_path: &str) -> Resul#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;cmd.creation_flags(CREATE_NO_WINDOW);}@@ -1034,7 +1032,6 @@ async fn get_video_fps(ffmpeg_path: &PathBuf, video_path: &str) -> Result<f64> {#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;cmd.creation_flags(CREATE_NO_WINDOW);}diff --git a/crates/screenpipe-server/src/video_utils.rs b/crates/screenpipe-server/src/video_utils.rsindex 47e5452da..2f5b3641c 100644--- a/crates/screenpipe-server/src/video_utils.rs+++ b/crates/screenpipe-server/src/video_utils.rs@@ -109,7 +109,6 @@ pub async fn extract_frame(file_path: &str, offset_index: i64) -> Result<String>#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;command.creation_flags(CREATE_NO_WINDOW);}@@ -166,7 +165,6 @@ pub async fn validate_media(file_path: &str) -> Result<()> {#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;cmd.creation_flags(CREATE_NO_WINDOW);}@@ -232,7 +230,6 @@ pub async fn merge_videos(#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;cmd.creation_flags(CREATE_NO_WINDOW);}@@ -334,7 +331,6 @@ pub async fn extract_frames_from_video(#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;cmd.creation_flags(CREATE_NO_WINDOW);}@@ -445,7 +441,6 @@ async fn get_video_fps_and_duration_uncached(#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;cmd.creation_flags(CREATE_NO_WINDOW);}@@ -531,7 +526,6 @@ pub async fn get_video_metadata(video_path: &str) -> Result<VideoMetadata> {#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;cmd.creation_flags(CREATE_NO_WINDOW);}@@ -604,7 +598,6 @@ async fn get_video_technical_metadata(ffprobe_path: &Path, video_path: &str) ->#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;cmd.creation_flags(CREATE_NO_WINDOW);}@@ -814,7 +807,6 @@ pub async fn extract_frame_from_video(file_path: &str, offset_index: i64, jpeg_q#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;command.creation_flags(CREATE_NO_WINDOW);}@@ -915,7 +907,6 @@ pub async fn extract_high_quality_frame(#[cfg(windows)]{- use std::os::windows::process::CommandExt;const CREATE_NO_WINDOW: u32 = 0x08000000;command.creation_flags(CREATE_NO_WINDOW);}