diff --git a/crates/turborepo-lib/src/run/mod.rs b/crates/turborepo-lib/src/run/mod.rs index 81e06fb41ab5b..54a2835d18491 100644 --- a/crates/turborepo-lib/src/run/mod.rs +++ b/crates/turborepo-lib/src/run/mod.rs @@ -292,6 +292,7 @@ impl Run { &self.engine, &self.env_at_execution_start, self.opts.scope_opts.pkg_inference_root.as_deref(), + self.experimental_ui, ) .await?; diff --git a/crates/turborepo-lib/src/run/summary/mod.rs b/crates/turborepo-lib/src/run/summary/mod.rs index 0da5b5f7fa055..4def93fa02742 100644 --- a/crates/turborepo-lib/src/run/summary/mod.rs +++ b/crates/turborepo-lib/src/run/summary/mod.rs @@ -278,6 +278,7 @@ impl RunTracker { engine: &'a Engine, hash_tracker: TaskHashTracker, env_at_execution_start: &'a EnvironmentVariableMap, + has_experimental_ui: bool, ) -> Result<(), Error> { let end_time = Local::now(); @@ -305,7 +306,7 @@ impl RunTracker { .await?; run_summary - .finish(end_time, exit_code, pkg_dep_graph, ui) + .finish(end_time, exit_code, pkg_dep_graph, ui, has_experimental_ui) .await } @@ -380,6 +381,7 @@ impl<'a> RunSummary<'a> { exit_code: i32, pkg_dep_graph: &PackageGraph, ui: UI, + has_experimental_ui: bool, ) -> Result<(), Error> { if matches!(self.run_type, RunType::DryJson | RunType::DryText) { return self.close_dry_run(pkg_dep_graph, ui); @@ -391,10 +393,12 @@ impl<'a> RunSummary<'a> { } } - if let Some(execution) = &self.execution { - let path = self.get_path(); - let failed_tasks = self.get_failed_tasks(); - execution.print(ui, path, failed_tasks); + if !has_experimental_ui { + if let Some(execution) = &self.execution { + let path = self.get_path(); + let failed_tasks = self.get_failed_tasks(); + execution.print(ui, path, failed_tasks); + } } if let Some(spaces_client_handle) = self.spaces_client_handle.take() { diff --git a/crates/turborepo-lib/src/run/watch.rs b/crates/turborepo-lib/src/run/watch.rs index a4975422d3f73..d64f3c2e53e24 100644 --- a/crates/turborepo-lib/src/run/watch.rs +++ b/crates/turborepo-lib/src/run/watch.rs @@ -50,8 +50,8 @@ pub struct WatchClient { base: CommandBase, telemetry: CommandEventBuilder, handler: SignalHandler, - sender: Option, - handle: Option>>, + ui_sender: Option, + ui_handle: Option>>, } #[derive(Debug, Error, Diagnostic)] @@ -130,8 +130,8 @@ impl WatchClient { handler, telemetry, persistent_tasks_handle: None, - sender, - handle, + ui_sender: sender, + ui_handle: handle, }) } @@ -141,7 +141,9 @@ impl WatchClient { let mut events = client.package_changes().await?; - self.run.print_run_prelude(); + if !self.run.has_experimental_ui() { + self.run.print_run_prelude(); + } let signal_subscriber = self.handler.subscribe().ok_or(Error::NoSignalHandler)?; @@ -264,7 +266,7 @@ impl WatchClient { .build(&signal_handler, telemetry) .await?; - Ok(run.run(self.sender.clone()).await?) + Ok(run.run(self.ui_sender.clone()).await?) } ChangedPackages::All => { let mut args = self.base.args().clone(); @@ -296,6 +298,20 @@ impl WatchClient { .build(&self.handler, self.telemetry.clone()) .await?; + if self.run.has_experimental_ui() { + if let Some(handle) = &self.ui_handle { + handle.abort(); + } + + let (sender, handle) = self + .run + .has_experimental_ui() + .then(|| self.run.start_experimental_ui()) + .unzip(); + self.ui_sender = sender; + self.ui_handle = handle; + } + if self.run.has_persistent_tasks() { // Abort old run if let Some(run) = self.persistent_tasks_handle.take() { @@ -303,7 +319,7 @@ impl WatchClient { } let mut persistent_run = self.run.create_run_for_persistent_tasks(); - let ui_sender = self.sender.clone(); + let ui_sender = self.ui_sender.clone(); // If we have persistent tasks, we run them on a separate thread // since persistent tasks don't finish self.persistent_tasks_handle = @@ -313,9 +329,9 @@ impl WatchClient { // But we still run the regular tasks blocking let mut non_persistent_run = self.run.create_run_without_persistent_tasks(); - Ok(non_persistent_run.run(self.sender.clone()).await?) + Ok(non_persistent_run.run(self.ui_sender.clone()).await?) } else { - Ok(self.run.run(self.sender.clone()).await?) + Ok(self.run.run(self.ui_sender.clone()).await?) } } } diff --git a/crates/turborepo-lib/src/task_graph/visitor.rs b/crates/turborepo-lib/src/task_graph/visitor.rs index c6c07c54f404c..9f0546661948f 100644 --- a/crates/turborepo-lib/src/task_graph/visitor.rs +++ b/crates/turborepo-lib/src/task_graph/visitor.rs @@ -346,6 +346,7 @@ impl<'a> Visitor<'a> { engine: &Engine, env_at_execution_start: &EnvironmentVariableMap, pkg_inference_root: Option<&AnchoredSystemPath>, + has_experimental_ui: bool, ) -> Result<(), Error> { let Self { package_graph, @@ -374,6 +375,7 @@ impl<'a> Visitor<'a> { engine, task_hasher.task_hash_tracker(), env_at_execution_start, + has_experimental_ui, ) .await?) } diff --git a/crates/turborepo-ui/src/tui/app.rs b/crates/turborepo-ui/src/tui/app.rs index cf43d185b4455..cb1c4c993944a 100644 --- a/crates/turborepo-ui/src/tui/app.rs +++ b/crates/turborepo-ui/src/tui/app.rs @@ -99,6 +99,7 @@ impl App { pub fn run_app(tasks: Vec, receiver: AppReceiver) -> Result<(), Error> { let mut terminal = startup()?; let size = terminal.size()?; + terminal.clear()?; // Figure out pane width? let task_width_hint = TaskTable::width_hint(tasks.iter().map(|s| s.as_str()));