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
swift path + app flag (#618)
Matthew Diakonovc905d1ec9f89
diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/recording-settings.tsxindex 165fd03f3..54502ca44 100644--- a/screenpipe-app-tauri/components/recording-settings.tsx+++ b/screenpipe-app-tauri/components/recording-settings.tsx@@ -1388,6 +1388,43 @@ export function RecordingSettings({)}</div></div>+ <div className="flex items-center space-x-2">+ <Switch+ id="ui-monitoring-toggle"+ checked={localSettings.enableUiMonitoring}+ onCheckedChange={(checked) =>+ setLocalSettings({+ ...localSettings,+ enableUiMonitoring: checked,+ })+ }+ />+ <Label+ htmlFor="ui-monitoring-toggle"+ className="flex items-center space-x-2"+ >+ <span>enable UI monitoring</span>+ <Badge variant="outline" className="ml-2">macOS only</Badge>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger>+ <HelpCircle className="h-4 w-4 cursor-default" />+ </TooltipTrigger>+ <TooltipContent side="right">+ <p>+ enables monitoring of UI elements and their interactions.+ <br />+ this allows for better context in search results+ <br />+ and more accurate activity tracking.+ <br />+ (macOS only)+ </p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ </Label>+ </div></CardContent></Card></div>diff --git a/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex 66f72d9d6..e2361e4dd 100644--- a/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -55,6 +55,7 @@ export interface Settings {showScreenpipeShortcut: string;isFirstTimeUser: boolean;enableFrameCache: boolean; // Add this line+ enableUiMonitoring: boolean; // Add this line}const defaultSettings: Settings = {@@ -101,6 +102,7 @@ const defaultSettings: Settings = {showScreenpipeShortcut: "Super+Alt+S",isFirstTimeUser: true,enableFrameCache: false, // Add this line+ enableUiMonitoring: false, // Add this line};let store: Awaited<ReturnType<typeof createStore>> | null = null;@@ -321,6 +323,7 @@ export function useSettings() {showScreenpipeShortcut: savedShowScreenpipeShortcut,isFirstTimeUser: savedIsFirstTimeUser,enableFrameCache: savedEnableFrameCache,+ enableUiMonitoring: false,});} catch (error) {console.error("failed to load settings:", error);diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rsindex eed3116dc..ab3bda24c 100644--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs@@ -176,6 +176,11 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {.and_then(|v| v.as_bool()).unwrap_or(false);+ let enable_ui_monitoring = store+ .get("enableUiMonitoring")+ .and_then(|v| v.as_bool())+ .unwrap_or(false);+println!("audio_chunk_duration: {}", audio_chunk_duration);let port_str = port.to_string();@@ -277,6 +282,10 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {args.push("--enable-frame-cache");}+ if enable_ui_monitoring {+ args.push("--enable-ui-monitoring");+ }+if cfg!(windows) {let exe_dir = env::current_exe().expect("Failed to get current executable path")diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.tomlindex 2b077b865..65197c040 100644--- a/screenpipe-vision/Cargo.toml+++ b/screenpipe-vision/Cargo.toml@@ -40,6 +40,8 @@ screenpipe-core = { path = "../screenpipe-core" }tracing-subscriber = { workspace = true }tracing = { workspace = true }+once_cell = "1.19"+which = "6.0"[dev-dependencies]tempfile = "3.3.0"diff --git a/screenpipe-vision/src/run_ui_monitoring_macos.rs b/screenpipe-vision/src/run_ui_monitoring_macos.rsindex 7f3500da9..f121c5e08 100644--- a/screenpipe-vision/src/run_ui_monitoring_macos.rs+++ b/screenpipe-vision/src/run_ui_monitoring_macos.rs@@ -5,6 +5,9 @@ use tokio::select;use tokio::process::Command as TokioCommand;use anyhow::Result;use log::{info, warn, error, debug};+use once_cell::sync::Lazy;+use which::which;+use std::path::PathBuf;// UPDATE THIS STRING EVERY TIME YOU MAKE CHANGES IN THE UI_MONITORING_MACOS.SWIFT FILEconst UI_MONITORING_SCRIPT: &str = r#"@@ -1394,7 +1397,48 @@ class ScreenPipeDB {"#;+static SWIFT_PATH: Lazy<Option<PathBuf>> = Lazy::new(find_swift_path_internal);++fn find_swift_path_internal() -> Option<PathBuf> {+ debug!("Starting search for swift executable");++ // Check if `swift` is in the PATH environment variable+ if let Ok(path) = which("swift") {+ debug!("Found swift in PATH: {:?}", path);+ return Some(path);+ }+ debug!("swift not found in PATH");++ // Common Swift installation paths on macOS+ let common_paths = [+ "/usr/bin/swift",+ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift",+ "/Library/Developer/CommandLineTools/usr/bin/swift",+ ];++ for path in common_paths {+ let path = PathBuf::from(path);+ if path.exists() {+ debug!("Found swift at common path: {:?}", path);+ return Some(path);+ }+ }++ error!("swift not found");+ None+}++pub fn find_swift_path() -> Option<PathBuf> {+ SWIFT_PATH.as_ref().map(|p| p.clone())+}+pub async fn run_ui() -> Result<()> {+ // Check for Swift availability first+ if find_swift_path().is_none() {+ return Err(anyhow::anyhow!(+ "swift not found. Please install Xcode Command Line Tools or Xcode"+ ));+ }// Create a temporary file for the Swift scriptlet temp_dir = std::env::temp_dir();let script_path = temp_dir.join("ui_monitoring_macos.swift");@@ -1423,7 +1467,12 @@ pub async fn run_ui() -> Result<()> {// Separate function to handle the monitoring processasync fn run_ui_monitoring(script_path: &std::path::Path) -> Result<()> {- let mut child = TokioCommand::new("swift")+ // Get Swift path+ let swift_path = find_swift_path().ok_or_else(|| {+ anyhow::anyhow!("swift not found. Please install Xcode Command Line Tools or Xcode")+ })?;++ let mut child = TokioCommand::new(swift_path).arg(script_path.to_str().unwrap()).stdout(Stdio::piped()).stderr(Stdio::piped())