Skip to content

Commit e9fb446

Browse files
Cammisulijaysoo
authored andcommitted
fix(core): do not hide task list with run-many if there is only 1 task (#31324)
1 parent a12fff2 commit e9fb446

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

packages/nx/src/native/tui/app.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub struct App {
4343
pub components: Vec<Box<dyn Component>>,
4444
pub quit_at: Option<std::time::Instant>,
4545
focus: Focus,
46+
run_mode: RunMode,
4647
previous_focus: Focus,
4748
done_callback: Option<ThreadsafeFunction<(), ErrorStrategy::Fatal>>,
4849
forced_shutdown_callback: Option<ThreadsafeFunction<(), ErrorStrategy::Fatal>>,
@@ -111,6 +112,7 @@ impl App {
111112
let main_terminal_pane_data = TerminalPaneData::new();
112113

113114
Ok(Self {
115+
run_mode,
114116
components,
115117
pinned_tasks,
116118
quit_at: None,
@@ -121,7 +123,7 @@ impl App {
121123
tui_config,
122124
user_has_interacted: false,
123125
is_forced_shutdown: false,
124-
layout_manager: LayoutManager::new(task_count),
126+
layout_manager: LayoutManager::new_with_run_mode(task_count, run_mode),
125127
frame_area: None,
126128
layout_areas: None,
127129
terminal_pane_data: [main_terminal_pane_data, TerminalPaneData::new()],
@@ -154,7 +156,11 @@ impl App {
154156
.select_task(task.clone());
155157

156158
if pinned_tasks.len() == 1 && idx == 0 {
157-
self.display_and_focus_current_task_in_terminal_pane(self.tasks.len() != 1);
159+
self.display_and_focus_current_task_in_terminal_pane(match self.run_mode {
160+
RunMode::RunMany => true,
161+
RunMode::RunOne if self.tasks.len() == 1 => false,
162+
RunMode::RunOne => true,
163+
});
158164
} else {
159165
self.assign_current_task_to_pane(idx);
160166
}
@@ -179,7 +185,7 @@ impl App {
179185
}
180186

181187
fn should_set_interactive_by_default(&self, task_id: &str) -> bool {
182-
self.tasks.len() == 1
188+
matches!(self.run_mode, RunMode::RunOne)
183189
&& self
184190
.pty_instances
185191
.get(task_id)

packages/nx/src/native/tui/components/layout_manager.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use ratatui::layout::{Constraint, Direction, Layout, Rect};
22

3+
use crate::native::tui::lifecycle::RunMode;
4+
35
/// Represents the available layout modes for the TUI application.
46
///
57
/// - `Auto`: Layout is determined based on available terminal space
@@ -119,6 +121,18 @@ impl LayoutManager {
119121
}
120122
}
121123

124+
pub fn new_with_run_mode(task_count: usize, run_mode: RunMode) -> Self {
125+
let mut layout_manager = Self::new(task_count);
126+
layout_manager.set_task_list_visibility(match run_mode {
127+
// nx run task with no dependent tasks
128+
RunMode::RunOne if task_count == 1 => TaskListVisibility::Hidden,
129+
// nx run task with dependent tasks
130+
RunMode::RunOne => TaskListVisibility::Visible,
131+
RunMode::RunMany => TaskListVisibility::Visible,
132+
});
133+
layout_manager
134+
}
135+
122136
/// Sets the layout mode.
123137
pub fn set_mode(&mut self, mode: LayoutMode) {
124138
self.mode = mode;

0 commit comments

Comments
 (0)