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: OpenClaw SFTP ~ path resolution + add cancel button to sync UI
Louis Beaumontcbe3cc6895a4
diff --git a/Cargo.lock b/Cargo.lockindex 55f6cd2c8..a3e0f6784 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -6358,7 +6358,7 @@ dependencies = [[[package]]name = "screenpipe-audio"-version = "0.3.172"+version = "0.3.173"dependencies = ["anyhow","audiopipe",@@ -6415,7 +6415,7 @@ dependencies = [[[package]]name = "screenpipe-core"-version = "0.3.172"+version = "0.3.173"dependencies = ["accessibility","accessibility-sys",@@ -6457,7 +6457,7 @@ dependencies = [[[package]]name = "screenpipe-db"-version = "0.3.172"+version = "0.3.173"dependencies = ["anyhow","chrono",@@ -6482,7 +6482,7 @@ dependencies = [[[package]]name = "screenpipe-events"-version = "0.3.172"+version = "0.3.173"dependencies = ["anyhow","chrono",@@ -6500,7 +6500,7 @@ dependencies = [[[package]]name = "screenpipe-integrations"-version = "0.3.172"+version = "0.3.173"dependencies = ["anyhow","chrono",@@ -6524,7 +6524,7 @@ dependencies = [[[package]]name = "screenpipe-server"-version = "0.3.172"+version = "0.3.173"dependencies = ["anyhow","async-trait",@@ -6588,7 +6588,7 @@ dependencies = [[[package]]name = "screenpipe-vision"-version = "0.3.172"+version = "0.3.173"dependencies = ["accessibility-sys","anyhow",diff --git a/apps/screenpipe-app-tauri/components/settings/openclaw-card.tsx b/apps/screenpipe-app-tauri/components/settings/openclaw-card.tsxindex 8ffce450f..0ea1536d1 100644--- a/apps/screenpipe-app-tauri/components/settings/openclaw-card.tsx+++ b/apps/screenpipe-app-tauri/components/settings/openclaw-card.tsx@@ -96,6 +96,7 @@ export function OpenClawCard() {const [showAdvanced, setShowAdvanced] = useState(false);const [discoveredHosts, setDiscoveredHosts] = useState<DiscoveredHost[]>([]);const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);+ const syncCancelledRef = useRef(false);useEffect(() => {const loaded = loadConfig();@@ -138,12 +139,14 @@ export function OpenClawCard() {const handleSyncNow = async () => {if (!config.host || !config.user) return;+ syncCancelledRef.current = false;setIsSyncing(true);setSyncError(null);try {const result = await invoke<SyncResult>("remote_sync_now", {config: toRustConfig(config),});+ if (syncCancelledRef.current) return;if (result.ok) {const now = new Date().toLocaleString();setLastSync(now);@@ -154,12 +157,19 @@ export function OpenClawCard() {}posthog.capture("openclaw_sync_manual", { success: result.ok });} catch (e) {+ if (syncCancelledRef.current) return;setSyncError(String(e));posthog.capture("openclaw_sync_manual", { success: false });}setIsSyncing(false);};+ const handleCancelSync = () => {+ syncCancelledRef.current = true;+ setIsSyncing(false);+ setSyncError(null);+ };+useEffect(() => {if (intervalRef.current) {clearInterval(intervalRef.current);@@ -381,21 +391,26 @@ export function OpenClawCard() {{isTesting ? <Loader2 className="h-3 w-3 animate-spin" /> : "test"}</Button>- <Button- onClick={handleSyncNow}- disabled={isSyncing}- size="sm"- className="h-7 text-xs w-24"- >- {isSyncing ? (- <Loader2 className="h-3 w-3 animate-spin" />- ) : (- <>- <RefreshCw className="h-3 w-3 mr-1" />- sync now- </>- )}- </Button>+ {isSyncing ? (+ <Button+ onClick={handleCancelSync}+ variant="destructive"+ size="sm"+ className="h-7 text-xs w-24"+ >+ <X className="h-3 w-3 mr-1" />+ cancel+ </Button>+ ) : (+ <Button+ onClick={handleSyncNow}+ size="sm"+ className="h-7 text-xs w-24"+ >+ <RefreshCw className="h-3 w-3 mr-1" />+ sync now+ </Button>+ )}<div className="flex items-center gap-1.5 ml-auto"><span className="text-xs text-muted-foreground">auto</span>diff --git a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsxindex 318055744..d02ee165c 100644--- a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx@@ -902,7 +902,10 @@ export function PipesSection() {<div className="flex items-center gap-2"><Button variant="outline" size="sm" disabled={refreshing} onClick={async () => {setRefreshing(true);- await fetchPipes();+ await Promise.all([+ fetchPipes(),+ new Promise((r) => setTimeout(r, 2000)),+ ]);setRefreshing(false);}}>{refreshing ? <Loader2 className="h-4 w-4 animate-spin" /> : <RefreshCw className="h-4 w-4" />}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rsindex 2409f876e..73889a184 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs@@ -383,7 +383,34 @@ fn parse_where_output(stdout: &str) -> Option<String> {}/// Find pi executable+/// Returns the screenpipe-managed pi install directory (`~/.screenpipe/pi-agent/`).+fn pi_local_install_dir() -> Option<PathBuf> {+ dirs::home_dir().map(|h| h.join(".screenpipe").join("pi-agent"))+}++/// Find the JS entrypoint for the locally-installed pi package.+fn find_local_pi_entrypoint() -> Option<String> {+ let dir = pi_local_install_dir()?;+ let cli_js = dir+ .join("node_modules")+ .join("@mariozechner")+ .join("pi-coding-agent")+ .join("dist")+ .join("cli.js");+ if cli_js.exists() {+ Some(cli_js.to_string_lossy().to_string())+ } else {+ None+ }+}+fn find_pi_executable() -> Option<String> {+ // 1. Check screenpipe-managed local install first (preferred — we control the deps)+ if let Some(js) = find_local_pi_entrypoint() {+ return Some(js);+ }++ // 2. Fallback to global install locationslet home = dirs::home_dir().map(|h| h.to_string_lossy().to_string()).unwrap_or_default();@@ -966,7 +993,7 @@ pub async fn pi_start_inner(.ok_or_else(|| {let bun_found = find_bun_executable().is_some();if bun_found {- format!("Pi not found after install attempt. Install manually with: bun add -g {}", PI_PACKAGE)+ format!("Pi not found after install attempt. Try restarting the app or delete ~/.screenpipe/pi-agent and restart.")} else {format!("Pi not found: bun is not installed. Screenpipe needs bun to run the AI assistant. Expected bundled bun next to the app executable.")}@@ -1437,10 +1464,16 @@ pub async fn pi_install(app: AppHandle) -> Result<(), String> {let bun = find_bun_executable().ok_or("Could not find bun. Install from https://bun.sh")?;+ let install_dir = pi_local_install_dir()+ .ok_or("Cannot determine home directory for Pi install")?;+ std::fs::create_dir_all(&install_dir)+ .map_err(|e| format!("Failed to create Pi install dir: {}", e))?;+let app_handle = app.clone();std::thread::spawn(move || {let mut cmd = std::process::Command::new(&bun);- cmd.args(["add", "-g", PI_PACKAGE]);+ cmd.current_dir(&install_dir)+ .args(["add", PI_PACKAGE]);// On Windows, prevent console window from appearing#[cfg(windows)]@@ -1817,12 +1850,15 @@ fn ensure_bash_available() -> Option<String> {}/// Background Pi installation — call once from app setup.+/// Installs pi into `~/.screenpipe/pi-agent/` (local install, not global)+/// so we fully control the dependency tree and avoid version conflicts./// Runs on a dedicated thread, never panics, never blocks the caller./// Sets `PI_INSTALL_DONE` when finished so `pi_start` can wait for it.pub fn ensure_pi_installed_background() {- // If Pi is already installed, mark done immediately- if find_pi_executable().is_some() {- debug!("Pi already installed, skipping background install");+ // If Pi is already installed locally, mark done immediately.+ // We specifically check the local install (not global) to ensure we control the deps.+ if find_local_pi_entrypoint().is_some() {+ debug!("Pi already installed locally, skipping background install");PI_INSTALL_DONE.store(true, Ordering::SeqCst);return;}@@ -1839,10 +1875,24 @@ pub fn ensure_pi_installed_background() {}};- info!("Pi not found — installing via bun in background");+ let install_dir = match pi_local_install_dir() {+ Some(d) => d,+ None => {+ warn!("Cannot determine home directory for Pi install");+ return;+ }+ };++ if let Err(e) = std::fs::create_dir_all(&install_dir) {+ warn!("Failed to create Pi install dir {}: {}", install_dir.display(), e);+ return;+ }++ info!("Pi not found — installing into {} via bun", install_dir.display());let mut cmd = std::process::Command::new(&bun);- cmd.args(["add", "-g", PI_PACKAGE]);+ cmd.current_dir(&install_dir)+ .args(["add", PI_PACKAGE]);#[cfg(windows)]{@@ -1853,7 +1903,7 @@ pub fn ensure_pi_installed_background() {match cmd.output() {Ok(output) if output.status.success() => {- info!("Pi installed successfully in background");+ info!("Pi installed successfully into {}", install_dir.display());}Ok(output) => {let stderr = String::from_utf8_lossy(&output.stderr);diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rsindex 0ef575fc3..1019abdca 100644--- a/crates/screenpipe-core/src/agents/pi.rs+++ b/crates/screenpipe-core/src/agents/pi.rs@@ -740,7 +740,7 @@ impl AgentExecutor for PiExecutor {Self::ensure_web_search_extension(working_dir, Some(&resolved_provider))?;let pi_path = find_pi_executable()- .ok_or_else(|| anyhow!("pi not found. install with: bun add -g {}", PI_PACKAGE))?;+ .ok_or_else(|| anyhow!("pi not found. try restarting the app or delete ~/.screenpipe/pi-agent and restart"))?;let resolved_model = Self::resolve_model(model, &resolved_provider);info!(@@ -822,7 +822,7 @@ impl AgentExecutor for PiExecutor {Self::ensure_web_search_extension(working_dir, Some(&resolved_provider))?;let pi_path = find_pi_executable()- .ok_or_else(|| anyhow!("pi not found. install with: bun add -g {}", PI_PACKAGE))?;+ .ok_or_else(|| anyhow!("pi not found. try restarting the app or delete ~/.screenpipe/pi-agent and restart"))?;info!("pipe streaming using provider: {}, model: {}",@@ -894,10 +894,16 @@ impl AgentExecutor for PiExecutor {let bun = find_bun_executable().ok_or_else(|| anyhow!("bun not found — install from https://bun.sh"))?;- info!("installing pi via bun …");+ let install_dir = pi_local_install_dir()+ .ok_or_else(|| anyhow!("cannot determine home directory for Pi install"))?;++ std::fs::create_dir_all(&install_dir)?;++ info!("installing pi into {} via bun …", install_dir.display());let mut cmd = std::process::Command::new(&bun);- cmd.args(["add", "-g", PI_PACKAGE]);+ cmd.current_dir(&install_dir)+ .args(["add", PI_PACKAGE]);#[cfg(windows)]{@@ -908,7 +914,7 @@ impl AgentExecutor for PiExecutor {let output = cmd.output()?;if output.status.success() {- info!("pi installed successfully");+ info!("pi installed successfully into {}", install_dir.display());Ok(())} else {let stderr = String::from_utf8_lossy(&output.stderr);@@ -966,7 +972,34 @@ pub fn find_bun_executable() -> Option<String> {paths.into_iter().find(|p| std::path::Path::new(p).exists())}+/// Returns the screenpipe-managed pi install directory (`~/.screenpipe/pi-agent/`).+fn pi_local_install_dir() -> Option<PathBuf> {+ dirs::home_dir().map(|h| h.join(".screenpipe").join("pi-agent"))+}++/// Find the JS entrypoint for the locally-installed pi package.+fn find_local_pi_entrypoint() -> Option<String> {+ let dir = pi_local_install_dir()?;+ let cli_js = dir+ .join("node_modules")+ .join("@mariozechner")+ .join("pi-coding-agent")+ .join("dist")+ .join("cli.js");+ if cli_js.exists() {+ Some(cli_js.to_string_lossy().to_string())+ } else {+ None+ }+}+pub fn find_pi_executable() -> Option<String> {+ // 1. Check screenpipe-managed local install first (preferred — we control the deps)+ if let Some(js) = find_local_pi_entrypoint() {+ return Some(js);+ }++ // 2. Fallback to global install locationslet home = dirs::home_dir().map(|h| h.to_string_lossy().to_string()).unwrap_or_default();@@ -1081,6 +1114,18 @@ fn build_async_command(path: &str) -> tokio::process::Command {let mut c = tokio::process::Command::new("cmd.exe");c.args(["/C", path]);c+ } else if path.ends_with(".js") {+ // Local install returns a .js entrypoint — run with bun+ if let Some(bun) = find_bun_executable() {+ let mut c = tokio::process::Command::new(&bun);+ c.arg(path);+ debug!("running pi JS entrypoint via bun: {} {}", bun, path);+ c+ } else {+ let mut c = tokio::process::Command::new("node");+ c.arg(path);+ c+ }} else {tokio::process::Command::new(path)};diff --git a/crates/screenpipe-integrations/src/remote_sync.rs b/crates/screenpipe-integrations/src/remote_sync.rsindex 10555a97e..8b24313cf 100644--- a/crates/screenpipe-integrations/src/remote_sync.rs+++ b/crates/screenpipe-integrations/src/remote_sync.rs@@ -392,12 +392,22 @@ async fn sync_to_remote_inner(config: &SyncConfig, data_dir: &Path) -> Result<Sy);let (session, sftp) = connect_sftp(config).await?;- let remote_base = &config.remote_path;- mkdir_p(&sftp, remote_base).await;+ // Resolve ~ to absolute path — SFTP doesn't understand tilde+ let remote_base = if config.remote_path.starts_with("~/") {+ let home = sftp+ .canonicalize(".")+ .await+ .unwrap_or_else(|_| "/home/".to_string() + &config.user);+ format!("{}/{}", home.trim_end_matches('/'), &config.remote_path[2..])+ } else {+ config.remote_path.clone()+ };++ mkdir_p(&sftp, &remote_base).await;// List existing remote files for incremental sync- let remote_files = list_remote_recursive(&sftp, remote_base, "").await;+ let remote_files = list_remote_recursive(&sftp, &remote_base, "").await;debug!("{} files already on remote", remote_files.len());let mut files_transferred: u64 = 0;@@ -407,7 +417,7 @@ async fn sync_to_remote_inner(config: &SyncConfig, data_dir: &Path) -> Result<Sysync_dir(&sftp,data_dir,- remote_base,+ &remote_base,"",&remote_files,&mut files_transferred,