Skip to content

Commit ded1cbb

Browse files
committed
fix: avoid windows startup console flicker
1 parent 2993c3c commit ded1cbb

8 files changed

Lines changed: 16 additions & 17 deletions

File tree

src/apps/desktop/src/computer_use/desktop_host.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3138,7 +3138,7 @@ tell application "System Events" to get unix id of first process whose frontmost
31383138
#[cfg(target_os = "windows")]
31393139
{
31403140
let result = tokio::task::spawn_blocking(move || -> BitFunResult<OpenAppResult> {
3141-
let output = std::process::Command::new("cmd")
3141+
let output = bitfun_core::util::process_manager::create_command("cmd")
31423142
.args(["/c", "start", "", &name])
31433143
.output()
31443144
.map_err(|e| BitFunError::tool(format!("open_app: {}", e)))?;

src/crates/acp/src/client/manager.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl AcpClientService {
353353

354354
let program =
355355
resolve_configured_command(&connection.config.command, &connection.config.env);
356-
let mut command = Command::new(&program);
356+
let mut command = bitfun_core::util::process_manager::create_tokio_command(&program);
357357
command
358358
.args(&connection.config.args)
359359
.stdin(Stdio::piped())
@@ -1345,7 +1345,7 @@ async fn terminate_child_process_tree(client_id: &str, mut child: Child) {
13451345
#[cfg(unix)]
13461346
if let Some(pid) = pid {
13471347
let process_group = format!("-{}", pid);
1348-
match Command::new("kill")
1348+
match bitfun_core::util::process_manager::create_tokio_command("kill")
13491349
.arg("-TERM")
13501350
.arg(&process_group)
13511351
.status()
@@ -1377,7 +1377,7 @@ async fn terminate_child_process_tree(client_id: &str, mut child: Child) {
13771377
Err(_) => {}
13781378
}
13791379

1380-
if let Err(error) = Command::new("kill")
1380+
if let Err(error) = bitfun_core::util::process_manager::create_tokio_command("kill")
13811381
.arg("-KILL")
13821382
.arg(&process_group)
13831383
.status()
@@ -1394,7 +1394,7 @@ async fn terminate_child_process_tree(client_id: &str, mut child: Child) {
13941394

13951395
#[cfg(windows)]
13961396
if let Some(pid) = pid {
1397-
match Command::new("taskkill")
1397+
match bitfun_core::util::process_manager::create_tokio_command("taskkill")
13981398
.arg("/PID")
13991399
.arg(pid.to_string())
14001400
.arg("/T")

src/crates/acp/src/client/requirements.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ where
250250
I: IntoIterator<Item = S>,
251251
S: AsRef<OsStr>,
252252
{
253-
let mut command = Command::new(program);
253+
let mut command = bitfun_core::util::process_manager::create_tokio_command(program);
254254
command.args(args);
255255
apply_command_environment(&mut command, None);
256256
match tokio::time::timeout(timeout, command.output()).await {

src/crates/core/src/agentic/tools/implementations/computer_use_actions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ impl ComputerUseActions {
14261426
let mut chosen_cmd = String::new();
14271427
let mut chosen_args: Vec<String> = vec![];
14281428
for (cmd, args) in &attempts {
1429-
match std::process::Command::new(cmd).args(args).output() {
1429+
match crate::util::process_manager::create_command(cmd).args(args).output() {
14301430
Ok(out) => {
14311431
if out.status.success() {
14321432
chosen_cmd = cmd.clone();
@@ -2056,7 +2056,7 @@ fn read_os_version() -> Option<String> {
20562056
}
20572057
#[cfg(target_os = "windows")]
20582058
{
2059-
let out = std::process::Command::new("cmd")
2059+
let out = crate::util::process_manager::create_command("cmd")
20602060
.args(["/C", "ver"])
20612061
.output()
20622062
.ok()?;

src/crates/core/src/miniapp/host_dispatch.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use base64::{engine::general_purpose::STANDARD as BASE64, Engine};
2929
use serde_json::{json, Value};
3030
use std::path::{Path, PathBuf};
3131
use std::time::Duration;
32-
use tokio::process::Command;
3332

3433
/// Namespaces handled by the host-side dispatch (no Worker required).
3534
const HOST_NAMESPACES: &[&str] = &["fs", "shell", "os", "net"];
@@ -377,13 +376,13 @@ async fn dispatch_shell(
377376

378377
#[cfg(target_os = "windows")]
379378
let mut cmd = {
380-
let mut c = Command::new("cmd");
379+
let mut c = crate::util::process_manager::create_tokio_command("cmd");
381380
c.args(["/C", &command]);
382381
c
383382
};
384383
#[cfg(not(target_os = "windows"))]
385384
let mut cmd = {
386-
let mut c = Command::new("sh");
385+
let mut c = crate::util::process_manager::create_tokio_command("sh");
387386
c.args(["-c", &command]);
388387
c
389388
};

src/crates/core/src/miniapp/js_worker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::sync::atomic::{AtomicI64, Ordering};
99
use std::sync::Arc;
1010
use std::time::Duration;
1111
use tokio::io::{AsyncBufReadExt, BufReader};
12-
use tokio::process::{Child, ChildStdin, Command};
12+
use tokio::process::{Child, ChildStdin};
1313
use tokio::sync::{oneshot, Mutex};
1414

1515
type JsWorkerResponse = Result<Value, String>;
@@ -36,7 +36,7 @@ impl JsWorker {
3636
) -> Result<Self, String> {
3737
let exe = runtime.path.to_string_lossy();
3838
let host = worker_host_path.to_string_lossy();
39-
let mut child = Command::new(&*exe)
39+
let mut child = crate::util::process_manager::create_tokio_command(&*exe)
4040
.arg(&*host)
4141
.arg(policy_json)
4242
.current_dir(app_dir)

src/crates/core/src/miniapp/js_worker_pool.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::util::errors::{BitFunError, BitFunResult};
77
use serde_json::Value;
88
use std::path::PathBuf;
99
use std::sync::Arc;
10-
use tokio::process::Command;
1110
use tokio::sync::Mutex;
1211

1312
const MAX_WORKERS: usize = 5;
@@ -276,7 +275,7 @@ impl JsWorkerPool {
276275
}
277276
};
278277

279-
let output = Command::new(cmd)
278+
let output = crate::util::process_manager::create_tokio_command(cmd)
280279
.args(args)
281280
.current_dir(&app_dir)
282281
.output()

src/crates/core/src/miniapp/runtime_detect.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
//! picked up regardless of the active version.
1414
1515
use std::path::{Path, PathBuf};
16-
use std::process::Command;
1716

1817
#[derive(Debug, Clone, PartialEq, Eq)]
1918
pub enum RuntimeKind {
@@ -116,7 +115,9 @@ fn is_executable(p: &Path) -> bool {
116115
}
117116

118117
fn get_version(executable: &std::path::Path) -> Result<String, std::io::Error> {
119-
let out = Command::new(executable).arg("--version").output()?;
118+
let out = crate::util::process_manager::create_command(executable)
119+
.arg("--version")
120+
.output()?;
120121
if out.status.success() {
121122
let v = String::from_utf8_lossy(&out.stdout);
122123
Ok(v.trim().to_string())

0 commit comments

Comments
 (0)