diff --git a/crates/tui/src/tools/shell/tests.rs b/crates/tui/src/tools/shell/tests.rs index 7bcd643c..c460f230 100644 --- a/crates/tui/src/tools/shell/tests.rs +++ b/crates/tui/src/tools/shell/tests.rs @@ -241,6 +241,40 @@ fn test_write_stdin_streams_output() { assert!(delta2.result.stdout.is_empty()); } +#[test] +#[cfg(unix)] +fn background_tty_command_has_controlling_terminal() { + let tmp = tempdir().expect("tempdir"); + let mut manager = ShellManager::new(tmp.path().to_path_buf()); + + let result = manager + .execute_with_options( + "sh -c 'exec 3<>/dev/tty && printf tty-ok && exec 3>&-'", + None, + 5000, + true, + None, + true, + Some(ExecutionSandboxPolicy::DangerFullAccess), + ) + .expect("execute tty command"); + + let task_id = result + .task_id + .expect("background tty execution should return task_id"); + + let done = manager + .get_output(&task_id, true, 10_000) + .expect("get tty command output"); + + assert_eq!(done.status, ShellStatus::Completed); + assert_eq!(done.exit_code, Some(0)); + assert!( + done.stdout.contains("tty-ok"), + "tty output should confirm /dev/tty opened; got {done:?}" + ); +} + #[test] fn test_job_list_poll_cancel_and_stale_snapshot() { let tmp = tempdir().expect("tempdir");