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: hide terminal windows on Windows — add CREATE_NO_WINDOW to all subprocess spawns
Louis Beaumont76d18558ea31
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/recording.rs b/apps/screenpipe-app-tauri/src-tauri/src/recording.rsindex 1c53ec4e1..9434696d1 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/recording.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/recording.rs@@ -332,10 +332,14 @@ async fn kill_process_on_port(port: u16) {{let my_pid_num: u32 = std::process::id();// netstat -ano | findstr :PORT- match tokio::process::Command::new("cmd")- .args(["/C", &format!("netstat -ano | findstr :{}", port)])- .output()- .await+ let mut netstat_cmd = tokio::process::Command::new("cmd");+ netstat_cmd.args(["/C", &format!("netstat -ano | findstr :{}", port)]);+ {+ use std::os::windows::process::CommandExt;+ const CREATE_NO_WINDOW: u32 = 0x08000000;+ netstat_cmd.creation_flags(CREATE_NO_WINDOW);+ }+ match netstat_cmd.output().await{Ok(output) if output.status.success() => {let text = String::from_utf8_lossy(&output.stdout);@@ -359,10 +363,14 @@ async fn kill_process_on_port(port: u16) {pids.len(), port, pids, my_pid_num);for pid in &pids {- let _ = tokio::process::Command::new("taskkill")- .args(["/F", "/PID", &pid.to_string()])- .output()- .await;+ let mut kill_cmd = tokio::process::Command::new("taskkill");+ kill_cmd.args(["/F", "/PID", &pid.to_string()]);+ {+ use std::os::windows::process::CommandExt;+ const CREATE_NO_WINDOW: u32 = 0x08000000;+ kill_cmd.creation_flags(CREATE_NO_WINDOW);+ }+ let _ = kill_cmd.output().await;}tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;info!("Killed orphaned process(es) on port {}", port);diff --git a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs b/apps/screenpipe-app-tauri/src-tauri/src/updates.rsindex 9433673b5..a1ffed1d0 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/updates.rs@@ -278,13 +278,20 @@ Start-Process "{install_dir}\{exe_name}"let script_path = std::env::temp_dir().join("screenpipe-rollback.ps1");std::fs::write(&script_path, &script).map_err(|e| format!("failed to write rollback script: {}", e))?;- std::process::Command::new("powershell")+ let mut rollback_cmd = std::process::Command::new("powershell");+ rollback_cmd.args(["-ExecutionPolicy", "Bypass", "-File"]).arg(&script_path).stdin(std::process::Stdio::null()).stdout(std::process::Stdio::null())- .stderr(std::process::Stdio::null())- .spawn()+ .stderr(std::process::Stdio::null());+ #[cfg(target_os = "windows")]+ {+ use std::os::windows::process::CommandExt;+ const CREATE_NO_WINDOW: u32 = 0x08000000;+ rollback_cmd.creation_flags(CREATE_NO_WINDOW);+ }+ rollback_cmd.spawn().map_err(|e| format!("failed to spawn rollback script: {}", e))?;info!("rollback: script spawned, app will quit now");diff --git a/crates/screenpipe-core/src/pipes.rs b/crates/screenpipe-core/src/pipes.rsindex 966f05767..4e05d8d3d 100644--- a/crates/screenpipe-core/src/pipes.rs+++ b/crates/screenpipe-core/src/pipes.rs@@ -304,16 +304,20 @@ async fn spawn_watchdog(parent_pid: u32, child_pid: u32) -> Result<tokio::proces{tokio::spawn(async move {tokio::time::sleep(Duration::from_secs(1)).await;- let output = Command::new("powershell")+ let mut ps_cmd = Command::new("powershell");+ ps_cmd.arg("-NoProfile").arg("-NonInteractive").arg("-Command").arg(format!("Get-Process -Id {} -ErrorAction SilentlyContinue",id- ))- .output()- .await;+ ));+ {+ use std::os::windows::process::CommandExt;+ ps_cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW+ }+ let output = ps_cmd.output().await;match output {Ok(output) => {@@ -525,13 +529,18 @@ pub async fn run_pipe(// Install dependencies using buninfo!("[{}] installing dependencies for next.js pipe", pipe);- let install_output = Command::new(&bun_path)+ let mut install_cmd = Command::new(&bun_path);+ install_cmd.arg("install").current_dir(&pipe_dir).env("NPM_CONFIG_REGISTRY", "https://registry.npmjs.org")- .env("BUN_CONFIG_REGISTRY", "https://registry.npmjs.org")- .output()- .await?;+ .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?;if !install_output.status.success() {let err_msg = String::from_utf8_lossy(&install_output.stderr);@@ -614,6 +623,12 @@ pub async fn run_pipe(.stdout(std::process::Stdio::piped()).stderr(std::process::Stdio::piped());+ #[cfg(target_os = "windows")]+ {+ use std::os::windows::process::CommandExt;+ command.creation_flags(0x08000000); // CREATE_NO_WINDOW+ }+let mut child = command.spawn()?;debug!("[{}] streaming logs for next.js pipe", pipe);@@ -649,14 +664,19 @@ pub async fn run_pipe(main_module.to_str().unwrap().to_string(),));- let mut child = Command::new(&bun_path)- .arg("run")+ let mut cmd = Command::new(&bun_path);+ cmd.arg("run").arg("--bun").arg(&main_module).envs(env_vars).stdout(std::process::Stdio::piped())- .stderr(std::process::Stdio::piped())- .spawn()?;+ .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()?;// Stream logsstream_logs(pipe, &mut child).await?;@@ -781,12 +801,18 @@ async fn retry_install(bun_path: &Path, dest_dir: &Path, max_retries: u32) -> Relet mut last_error = None;while attempt < max_retries {- let mut install_child = Command::new(bun_path)+ let mut install_cmd = Command::new(bun_path);+ install_cmd.arg("i").current_dir(dest_dir).stdout(std::process::Stdio::piped())- .stderr(std::process::Stdio::piped())- .spawn()?;+ .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()?;// Stream logs for npm installif let Ok(()) = stream_logs("bun install", &mut install_child).await {@@ -1574,13 +1600,18 @@ async fn try_build_nextjs(pipe_dir: &Path, bun_path: &Path) -> Result<BuildStatu"[{}] running next.js build",pipe_dir.file_name().unwrap_or_default().to_string_lossy());- let build_output = Command::new(bun_path)+ let mut build_cmd = Command::new(bun_path);+ build_cmd.arg("run").arg("--bun").arg("build")- .current_dir(pipe_dir)- .output()- .await?;+ .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?;if build_output.status.success() {let pipe_json = tokio::fs::read_to_string(&pipe_json_path).await?;diff --git a/crates/screenpipe-server/src/bin/screenpipe-server.rs b/crates/screenpipe-server/src/bin/screenpipe-server.rsindex 2dc6e99fc..459b5602e 100644--- a/crates/screenpipe-server/src/bin/screenpipe-server.rs+++ b/crates/screenpipe-server/src/bin/screenpipe-server.rs@@ -2010,9 +2010,15 @@ async fn download_mcp_directory(// Helper function to check if a command is availablefn is_command_available(command: &str) -> bool {- std::process::Command::new(command)- .arg("--version")- .output()+ let mut cmd = std::process::Command::new(command);+ cmd.arg("--version");+ #[cfg(target_os = "windows")]+ {+ use std::os::windows::process::CommandExt;+ const CREATE_NO_WINDOW: u32 = 0x08000000;+ cmd.creation_flags(CREATE_NO_WINDOW);+ }+ cmd.output().map(|output| output.status.success()).unwrap_or(false)}diff --git a/crates/screenpipe-server/src/video.rs b/crates/screenpipe-server/src/video.rsindex a6742ccf1..366d28e6a 100644--- a/crates/screenpipe-server/src/video.rs+++ b/crates/screenpipe-server/src/video.rs@@ -785,8 +785,8 @@ mod tests {/// Get video dimensions using ffprobeasync fn get_video_dimensions(video_path: &str) -> Result<(u32, u32), anyhow::Error> {- let output = Command::new("ffprobe")- .args([+ let mut cmd = Command::new("ffprobe");+ cmd.args(["-v","error","-select_streams",@@ -796,9 +796,14 @@ mod tests {"-of","csv=s=x:p=0",video_path,- ])- .output()- .await?;+ ]);+ #[cfg(target_os = "windows")]+ {+ use std::os::windows::process::CommandExt;+ const CREATE_NO_WINDOW: u32 = 0x08000000;+ cmd.creation_flags(CREATE_NO_WINDOW);+ }+ let output = cmd.output().await?;let stdout = String::from_utf8_lossy(&output.stdout);let parts: Vec<&str> = stdout.trim().split('x').collect();