fix(core): don't display fork script path in tui (#30970)

## Current Behavior
The tui displays the path to the fork script in the pty pane

## Expected Behavior
The tui displays a command that would be "close enough" to what is being
ran in the pty pane

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Craigory Coppola 2025-05-01 14:03:43 -04:00 committed by GitHub
parent 3877a43a47
commit 958985a182
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 39 additions and 13 deletions

View File

@ -89,12 +89,12 @@ export declare class RunningTasksService {
export declare class RustPseudoTerminal { export declare class RustPseudoTerminal {
constructor() constructor()
runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, execArgv?: Array<string> | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null): ChildProcess runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, execArgv?: Array<string> | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null, commandLabel?: string | undefined | null): ChildProcess
/** /**
* This allows us to run a pseudoterminal with a fake node ipc channel * This allows us to run a pseudoterminal with a fake node ipc channel
* this makes it possible to be backwards compatible with the old implementation * this makes it possible to be backwards compatible with the old implementation
*/ */
fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, execArgv: Array<string> | undefined | null, quiet: boolean): ChildProcess fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, execArgv: Array<string> | undefined | null, quiet: boolean, commandLabel?: string | undefined | null): ChildProcess
} }
export declare class TaskDetails { export declare class TaskDetails {

View File

@ -1,5 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use tracing::trace; use tracing::trace;
use watchexec::command;
use super::child_process::ChildProcess; use super::child_process::ChildProcess;
use super::os; use super::os;
@ -31,9 +32,17 @@ impl RustPseudoTerminal {
exec_argv: Option<Vec<String>>, exec_argv: Option<Vec<String>>,
quiet: Option<bool>, quiet: Option<bool>,
tty: Option<bool>, tty: Option<bool>,
command_label: Option<String>,
) -> napi::Result<ChildProcess> { ) -> napi::Result<ChildProcess> {
self.pseudo_terminal self.pseudo_terminal.run_command(
.run_command(command, command_dir, js_env, exec_argv, quiet, tty) command,
command_dir,
js_env,
exec_argv,
quiet,
tty,
command_label,
)
} }
/// This allows us to run a pseudoterminal with a fake node ipc channel /// This allows us to run a pseudoterminal with a fake node ipc channel
@ -48,6 +57,7 @@ impl RustPseudoTerminal {
js_env: Option<HashMap<String, String>>, js_env: Option<HashMap<String, String>>,
exec_argv: Option<Vec<String>>, exec_argv: Option<Vec<String>>,
quiet: bool, quiet: bool,
command_label: Option<String>,
) -> napi::Result<ChildProcess> { ) -> napi::Result<ChildProcess> {
let command = format!( let command = format!(
"node {} {} {}", "node {} {} {}",
@ -64,6 +74,7 @@ impl RustPseudoTerminal {
exec_argv, exec_argv,
Some(quiet), Some(quiet),
Some(true), Some(true),
command_label,
) )
} }
} }

View File

@ -32,9 +32,17 @@ impl RustPseudoTerminal {
exec_argv: Option<Vec<String>>, exec_argv: Option<Vec<String>>,
quiet: Option<bool>, quiet: Option<bool>,
tty: Option<bool>, tty: Option<bool>,
command_label: Option<String>,
) -> napi::Result<ChildProcess> { ) -> napi::Result<ChildProcess> {
self.pseudo_terminal self.pseudo_terminal.run_command(
.run_command(command, command_dir, js_env, exec_argv, quiet, tty) command,
command_dir,
js_env,
exec_argv,
quiet,
tty,
command_label,
)
} }
/// This allows us to run a pseudoterminal with a fake node ipc channel /// This allows us to run a pseudoterminal with a fake node ipc channel
@ -49,6 +57,7 @@ impl RustPseudoTerminal {
js_env: Option<HashMap<String, String>>, js_env: Option<HashMap<String, String>>,
exec_argv: Option<Vec<String>>, exec_argv: Option<Vec<String>>,
quiet: bool, quiet: bool,
command_label: Option<String>,
) -> napi::Result<ChildProcess> { ) -> napi::Result<ChildProcess> {
let command = format!( let command = format!(
"node {} {} {}", "node {} {} {}",
@ -65,6 +74,7 @@ impl RustPseudoTerminal {
exec_argv, exec_argv,
Some(quiet), Some(quiet),
Some(true), Some(true),
command_label,
) )
} }
} }

View File

@ -181,6 +181,7 @@ impl PseudoTerminal {
exec_argv: Option<Vec<String>>, exec_argv: Option<Vec<String>>,
quiet: Option<bool>, quiet: Option<bool>,
tty: Option<bool>, tty: Option<bool>,
command_label: Option<String>,
) -> napi::Result<ChildProcess> { ) -> napi::Result<ChildProcess> {
let command_dir = get_directory(command_dir)?; let command_dir = get_directory(command_dir)?;
@ -206,15 +207,15 @@ impl PseudoTerminal {
let (exit_to_process_tx, exit_to_process_rx) = bounded(1); let (exit_to_process_tx, exit_to_process_rx) = bounded(1);
let command_info = format!("> {}\n\n\r", command); let command_clone = command.clone();
let command_info = format!("> {}\n\n\r", command_label.unwrap_or(command));
self.stdout_tx.send(command_info.clone()).ok(); self.stdout_tx.send(command_info.clone()).ok();
self.parser self.parser
.write() .write()
.expect("Failed to acquire parser write lock") .expect("Failed to acquire parser write lock")
.process(command_info.as_bytes()); .process(command_info.as_bytes());
trace!("Running {}", command_clone);
trace!("Running {}", command);
let mut child = pair.slave.spawn_command(cmd)?; let mut child = pair.slave.spawn_command(cmd)?;
self.running.store(true, Ordering::SeqCst); self.running.store(true, Ordering::SeqCst);
@ -234,11 +235,11 @@ impl PseudoTerminal {
trace!("spawning thread to wait for command"); trace!("spawning thread to wait for command");
std::thread::spawn(move || { std::thread::spawn(move || {
trace!("Waiting for {}", command); trace!("Waiting for {}", command_clone);
let res = child.wait(); let res = child.wait();
if let Ok(exit) = res { if let Ok(exit) = res {
trace!("{} Exited", command); trace!("{} Exited", command_clone);
// This mitigates the issues with ConPTY on windows and makes it work. // This mitigates the issues with ConPTY on windows and makes it work.
running_clone.store(false, Ordering::SeqCst); running_clone.store(false, Ordering::SeqCst);
if cfg!(windows) { if cfg!(windows) {
@ -261,7 +262,7 @@ impl PseudoTerminal {
} }
exit_to_process_tx.send(exit.to_string()).ok(); exit_to_process_tx.send(exit.to_string()).ok();
} else { } else {
trace!("Error waiting for {}", command); trace!("Error waiting for {}", command_clone);
}; };
}); });

View File

@ -203,6 +203,7 @@ export class ForkedProcessTaskRunner {
execArgv: process.execArgv, execArgv: process.execArgv,
jsEnv: env, jsEnv: env,
quiet: !streamOutput, quiet: !streamOutput,
commandLabel: `nx run ${task.id}`,
}); });
p.send({ p.send({

View File

@ -106,11 +106,13 @@ export class PseudoTerminal {
execArgv, execArgv,
jsEnv, jsEnv,
quiet, quiet,
commandLabel,
}: { }: {
cwd?: string; cwd?: string;
execArgv?: string[]; execArgv?: string[];
jsEnv?: Record<string, string>; jsEnv?: Record<string, string>;
quiet?: boolean; quiet?: boolean;
commandLabel?: string;
} }
) { ) {
if (!this.initialized) { if (!this.initialized) {
@ -125,7 +127,8 @@ export class PseudoTerminal {
cwd, cwd,
jsEnv, jsEnv,
execArgv, execArgv,
quiet quiet,
commandLabel
), ),
id, id,
this.pseudoIPC this.pseudoIPC