fix(core): do not hide task list with run-many if there is only 1 task (#31324)

This commit is contained in:
Jonathan Cammisuli 2025-05-23 21:28:00 -04:00 committed by GitHub
parent 85d4136811
commit e2b3acaa37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 3 deletions

View File

@ -43,6 +43,7 @@ pub struct App {
pub components: Vec<Box<dyn Component>>, pub components: Vec<Box<dyn Component>>,
pub quit_at: Option<std::time::Instant>, pub quit_at: Option<std::time::Instant>,
focus: Focus, focus: Focus,
run_mode: RunMode,
previous_focus: Focus, previous_focus: Focus,
done_callback: Option<ThreadsafeFunction<(), ErrorStrategy::Fatal>>, done_callback: Option<ThreadsafeFunction<(), ErrorStrategy::Fatal>>,
forced_shutdown_callback: Option<ThreadsafeFunction<(), ErrorStrategy::Fatal>>, forced_shutdown_callback: Option<ThreadsafeFunction<(), ErrorStrategy::Fatal>>,
@ -111,6 +112,7 @@ impl App {
let main_terminal_pane_data = TerminalPaneData::new(); let main_terminal_pane_data = TerminalPaneData::new();
Ok(Self { Ok(Self {
run_mode,
components, components,
pinned_tasks, pinned_tasks,
quit_at: None, quit_at: None,
@ -121,7 +123,7 @@ impl App {
tui_config, tui_config,
user_has_interacted: false, user_has_interacted: false,
is_forced_shutdown: false, is_forced_shutdown: false,
layout_manager: LayoutManager::new(task_count), layout_manager: LayoutManager::new_with_run_mode(task_count, run_mode),
frame_area: None, frame_area: None,
layout_areas: None, layout_areas: None,
terminal_pane_data: [main_terminal_pane_data, TerminalPaneData::new()], terminal_pane_data: [main_terminal_pane_data, TerminalPaneData::new()],
@ -154,7 +156,11 @@ impl App {
.select_task(task.clone()); .select_task(task.clone());
if pinned_tasks.len() == 1 && idx == 0 { if pinned_tasks.len() == 1 && idx == 0 {
self.display_and_focus_current_task_in_terminal_pane(self.tasks.len() != 1); self.display_and_focus_current_task_in_terminal_pane(match self.run_mode {
RunMode::RunMany => true,
RunMode::RunOne if self.tasks.len() == 1 => false,
RunMode::RunOne => true,
});
} else { } else {
self.assign_current_task_to_pane(idx); self.assign_current_task_to_pane(idx);
} }
@ -179,7 +185,7 @@ impl App {
} }
fn should_set_interactive_by_default(&self, task_id: &str) -> bool { fn should_set_interactive_by_default(&self, task_id: &str) -> bool {
self.tasks.len() == 1 matches!(self.run_mode, RunMode::RunOne)
&& self && self
.pty_instances .pty_instances
.get(task_id) .get(task_id)

View File

@ -1,5 +1,7 @@
use ratatui::layout::{Constraint, Direction, Layout, Rect}; use ratatui::layout::{Constraint, Direction, Layout, Rect};
use crate::native::tui::lifecycle::RunMode;
/// Represents the available layout modes for the TUI application. /// Represents the available layout modes for the TUI application.
/// ///
/// - `Auto`: Layout is determined based on available terminal space /// - `Auto`: Layout is determined based on available terminal space
@ -119,6 +121,18 @@ impl LayoutManager {
} }
} }
pub fn new_with_run_mode(task_count: usize, run_mode: RunMode) -> Self {
let mut layout_manager = Self::new(task_count);
layout_manager.set_task_list_visibility(match run_mode {
// nx run task with no dependent tasks
RunMode::RunOne if task_count == 1 => TaskListVisibility::Hidden,
// nx run task with dependent tasks
RunMode::RunOne => TaskListVisibility::Visible,
RunMode::RunMany => TaskListVisibility::Visible,
});
layout_manager
}
/// Sets the layout mode. /// Sets the layout mode.
pub fn set_mode(&mut self, mode: LayoutMode) { pub fn set_mode(&mut self, mode: LayoutMode) {
self.mode = mode; self.mode = mode;