Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): always start tasks #7758

Merged
merged 4 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion crates/turborepo-lib/src/task_graph/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,12 @@ impl ExecContext {
self.pretty_prefix.clone(),
);

if self.experimental_ui {
if let TaskOutput::UI(task) = output_client {
task.start();
}
}

match self
.task_cache
.restore_outputs(prefixed_ui.output_prefixed_writer(), telemetry)
Expand Down Expand Up @@ -916,9 +922,9 @@ impl ExecContext {
return ExecOutcome::Internal;
}
};

if self.experimental_ui {
if let TaskOutput::UI(task) = output_client {
task.start();
if let Some(stdin) = process.stdin() {
task.set_stdin(stdin);
}
Expand Down
2 changes: 2 additions & 0 deletions crates/turborepo-ui/src/tui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use ratatui::{
widgets::Widget,
Frame, Terminal,
};
use tracing::debug;

const HEIGHT: u16 = 60;
const PANE_HEIGHT: u16 = 40;
Expand All @@ -26,6 +27,7 @@ pub struct App<I> {

impl<I> App<I> {
pub fn new(rows: u16, cols: u16, tasks: Vec<String>) -> Self {
debug!("tasks: {tasks:?}");
let mut this = Self {
table: TaskTable::new(tasks.clone()),
pane: TerminalPane::new(rows, cols, tasks),
Expand Down
5 changes: 4 additions & 1 deletion crates/turborepo-ui/src/tui/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ratatui::{
style::Style,
widgets::{Block, Borders, Widget},
};
use tracing::debug;
use tui_term::widget::PseudoTerminal;
use turborepo_vt100 as vt100;

Expand Down Expand Up @@ -45,7 +46,9 @@ impl<W> TerminalPane<W> {
}

pub fn process_output(&mut self, task: &str, output: &[u8]) -> Result<(), Error> {
let task = self.task_mut(task)?;
let task = self
.task_mut(task)
.inspect_err(|_| debug!("cannot find task on process output"))?;
task.parser.process(output);
Ok(())
}
Expand Down
11 changes: 9 additions & 2 deletions crates/turborepo-ui/src/tui/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use ratatui::{
Block, BorderType, Borders, Cell, Paragraph, Row, StatefulWidget, Table, TableState, Widget,
},
};
use tracing::debug;

use super::{
task::{Finished, Planned, Running, Task},
Expand Down Expand Up @@ -78,7 +79,10 @@ impl TaskTable {
let planned_idx = self
.planned
.binary_search_by(|planned_task| planned_task.name().cmp(task))
.map_err(|_| Error::TaskNotFound { name: task.into() })?;
.map_err(|_| {
debug!("no task found on start");
chris-olszewski marked this conversation as resolved.
Show resolved Hide resolved
Error::TaskNotFound { name: task.into() }
})?;
let planned = self.planned.remove(planned_idx);
let old_row_idx = self.finished.len() + self.running.len() + planned_idx;
let new_row_idx = self.finished.len() + self.running.len();
Expand Down Expand Up @@ -107,7 +111,10 @@ impl TaskTable {
.running
.iter()
.position(|running| running.name() == task)
.ok_or_else(|| Error::TaskNotFound { name: task.into() })?;
.ok_or_else(|| {
debug!("can't find task on finish");
chris-olszewski marked this conversation as resolved.
Show resolved Hide resolved
Error::TaskNotFound { name: task.into() }
})?;
let old_row_idx = self.finished.len() + running_idx;
let new_row_idx = self.finished.len();
let running = self.running.remove(running_idx);
Expand Down