the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
fix(windows): suppress noninteractive process windows
Ogulcan Celik616d1dd8125e
diff --git a/docs/next/CHANGELOG.md b/docs/next/CHANGELOG.mdindex 2e83fd02f..bee2cf631 100644--- a/docs/next/CHANGELOG.md+++ b/docs/next/CHANGELOG.md@@ -7,7 +7,7 @@- Added macOS support for the `HERDR_AGENT=<agent>` foreground-process hint, allowing agents hidden behind host-visible wrappers such as `nono` to use the named agent's screen manifest. (#679)### Fixed-- Background agent-detection manifest checks no longer flash curl console windows on Windows. (#1468)+- Background update checks, captured plugin commands, and workspace Git probes no longer flash console windows on Windows. (#1468)- Live handoff now preserves installed plugins and no longer lets the next plugin installation overwrite the existing registry. (#893)- `herdr wait agent-status` now returns `pane_not_found` promptly when its target pane closes instead of waiting for the full timeout. (#1439)diff --git a/src/detect/manifest_update.rs b/src/detect/manifest_update.rsindex 02efa3bca..8c5fc3398 100644--- a/src/detect/manifest_update.rs+++ b/src/detect/manifest_update.rs@@ -4,7 +4,7 @@ use std::{fmt, fs,io::{Read, Write},path::{Path, PathBuf},- process::{Command, Stdio},+ process::Stdio,time::{SystemTime, UNIX_EPOCH},};@@ -470,9 +470,7 @@ fn catalog_url() -> String {fn fetch_text(url: &str) -> Result<String, String> {let max_fetch_bytes = MAX_FETCH_BYTES.to_string();- let mut command = Command::new("curl");- crate::platform::configure_background_command(&mut command);- let mut child = command+ let mut child = crate::noninteractive_process::curl_command().args(["-sfL","--retry",diff --git a/src/main.rs b/src/main.rsindex c48951c6d..d7746f579 100644--- a/src/main.rs+++ b/src/main.rs@@ -74,6 +74,7 @@ mod kitty_graphics;mod layout;mod logging;mod metadata_tokens;+mod noninteractive_process;mod pane;mod persist;mod platform;diff --git a/src/noninteractive_process.rs b/src/noninteractive_process.rsnew file mode 100644index 000000000..98198dce5--- /dev/null+++ b/src/noninteractive_process.rs@@ -0,0 +1,12 @@+use std::{ffi::OsStr, process::Command};++/// Builds a subprocess whose stdio is controlled by the caller and which never opens a Windows console.+pub(crate) fn command(program: impl AsRef<OsStr>) -> Command {+ let mut command = Command::new(program);+ crate::platform::configure_background_command(&mut command);+ command+}++pub(crate) fn curl_command() -> Command {+ command("curl")+}diff --git a/src/plugin_command.rs b/src/plugin_command.rsindex ba0a14226..a0f718941 100644--- a/src/plugin_command.rs+++ b/src/plugin_command.rs@@ -12,7 +12,7 @@ pub(crate) fn command_for_argv(program: &str, args: &[String]) -> Command {#[cfg(not(windows))]fn command_for_program(program: &str) -> Command {- Command::new(program)+ crate::noninteractive_process::command(program)}#[cfg(windows)]@@ -29,11 +29,11 @@ fn command_for_program(program: &str) -> Command {{let shell =std::env::var_os("ComSpec").unwrap_or_else(|| r"C:\Windows\System32\cmd.exe".into());- let mut command = Command::new(shell);+ let mut command = crate::noninteractive_process::command(shell);command.arg("/d").arg("/c").arg(command_program);command} else {- Command::new(command_program)+ crate::noninteractive_process::command(command_program)}}@@ -126,4 +126,25 @@ mod tests {assert!(!is_windows_batch_file_name("node.exe"));assert!(!is_windows_batch_file_name("node"));}++ #[cfg(windows)]+ #[test]+ fn windows_batch_command_captures_output() {+ let path = std::env::temp_dir().join(format!(+ "herdr-plugin-command-output-{}.cmd",+ std::process::id()+ ));+ std::fs::write(&path, "@echo off\r\necho plugin-%1\r\n").expect("write batch fixture");++ let output = command_for_argv(&path.display().to_string(), &["ready".to_string()])+ .output()+ .expect("run batch fixture");+ let _ = std::fs::remove_file(&path);++ assert!(output.status.success(), "{output:?}");+ assert_eq!(+ String::from_utf8_lossy(&output.stdout).trim(),+ "plugin-ready"+ );+ }}diff --git a/src/remote/unix.rs b/src/remote/unix.rsindex 7544585f2..40e8bb454 100644--- a/src/remote/unix.rs+++ b/src/remote/unix.rs@@ -1449,7 +1449,7 @@ fn download_release_asset(platform: &RemotePlatform) -> io::Result<InstallSourcelet dir = private_download_dir(&asset_key)?;let path = dir.join("herdr.tmp");- let status = Command::new("curl")+ let status = crate::noninteractive_process::curl_command().args(["-sfL", "--max-time", "120", "-o"]).arg(&path).arg(&asset.url)@@ -1473,7 +1473,7 @@ fn download_release_asset(platform: &RemotePlatform) -> io::Result<InstallSource}fn fetch_remote_manifest(url: &str) -> io::Result<Vec<u8>> {- let output = Command::new("curl")+ let output = crate::noninteractive_process::curl_command().args(["-sfL","--retry",diff --git a/src/update.rs b/src/update.rsindex 8ef778401..eac917bf6 100644--- a/src/update.rs+++ b/src/update.rs@@ -294,7 +294,7 @@ fn fetch_json_manifest<T>(url: &str) -> Result<T, String>whereT: serde::de::DeserializeOwned,{- let output = Command::new("curl")+ let output = crate::noninteractive_process::curl_command().args(["-sfL","--retry",@@ -508,7 +508,7 @@ fn homebrew_update_from_formula_json(fn check_homebrew_latest() -> Result<Option<Version>, String> {let current = Version::current();- let output = Command::new("curl")+ let output = crate::noninteractive_process::curl_command().args(["-sfL","--retry",@@ -571,7 +571,7 @@ fn download_update(release: &ReleaseInfo) -> Result<DownloadedUpdate, String> {let tmp_path = parent.join(format!(".herdr-update-{}.tmp", std::process::id()));// Download the exact asset URL (pinned to the release we checked)- let status = Command::new("curl")+ let status = crate::noninteractive_process::curl_command().args(["-sfL", "--max-time", "120", "-o"]).arg(&tmp_path).arg(&release.download_url)diff --git a/src/workspace/git/discovery.rs b/src/workspace/git/discovery.rsindex 9aa351b2a..4edfcbc27 100644--- a/src/workspace/git/discovery.rs+++ b/src/workspace/git/discovery.rs@@ -216,7 +216,7 @@ fn strip_git_config_comment(value: &str) -> &str {}fn git_trimmed_stdout(repo_root: &Path, args: &[&str]) -> Option<String> {- let output = std::process::Command::new("git")+ let output = crate::noninteractive_process::command("git").arg("-C").arg(repo_root).args(args)diff --git a/src/workspace/git/status.rs b/src/workspace/git/status.rsindex 024ffdde3..d9c3123a0 100644--- a/src/workspace/git/status.rs+++ b/src/workspace/git/status.rs@@ -218,7 +218,7 @@ fn git_ahead_behind_between(upstream_oid: &str,) -> Option<(usize, usize)> {let range = format!("{head_oid}...{upstream_oid}");- let output = std::process::Command::new("git")+ let output = crate::noninteractive_process::command("git").arg("-C").arg(cwd).args(["rev-list", "--left-right", "--count", &range])