Skip to content

Commit ae7de55

Browse files
leosvelperezFrozenPandaz
authored andcommitted
fix(core): render the correct output in the tui terminal pane when pinning task (#31975)
## Current Behavior In the TUI, opening the Terminal Pane for a task with the space bar, navigating to another task, and pressing "1" to pin it, results in the terminal pane displaying the output of the task for which the space bar was pressed initially instead of the pinned task. ## Expected Behavior Pinning tasks in the TUI should work correctly and always display the output of the pinned task. (cherry picked from commit dd57e0f)
1 parent afab529 commit ae7de55

File tree

1 file changed

+27
-0
lines changed
  • packages/nx/src/native/tui

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,9 +1158,23 @@ impl App {
11581158
.collect()
11591159
}
11601160

1161+
/// Clears PTY reference and related state for a specific pane
1162+
fn clear_pane_pty_reference(&mut self, pane_idx: usize) {
1163+
if pane_idx < 2 {
1164+
self.terminal_pane_data[pane_idx].pty = None;
1165+
self.terminal_pane_data[pane_idx].can_be_interactive = false;
1166+
self.terminal_pane_data[pane_idx].set_interactive(false);
1167+
}
1168+
}
1169+
11611170
/// Clears all output panes and resets their associated state.
11621171
fn clear_all_panes(&mut self) {
11631172
self.pane_tasks = [None, None];
1173+
1174+
// Clear PTY references for both panes
1175+
self.clear_pane_pty_reference(0);
1176+
self.clear_pane_pty_reference(1);
1177+
11641178
self.update_focus(Focus::TaskList);
11651179
self.set_spacebar_mode(false, None);
11661180
self.dispatch_action(Action::UnpinAllTasks);
@@ -1368,6 +1382,12 @@ impl App {
13681382

13691383
// If we're in spacebar mode and this is pane 0, convert to pinned mode
13701384
if self.spacebar_mode && pane_idx == 0 {
1385+
// Clear the PTY reference when converting from spacebar to pinned mode
1386+
self.clear_pane_pty_reference(pane_idx);
1387+
1388+
// Pin the currently selected task to the pane
1389+
self.pane_tasks[pane_idx] = Some(task_name.clone());
1390+
13711391
// When converting from spacebar to pinned, stay in name-tracking mode
13721392
self.set_spacebar_mode(false, Some(SelectionMode::TrackByName));
13731393
if self.layout_manager.get_pane_arrangement() == PaneArrangement::None {
@@ -1381,6 +1401,9 @@ impl App {
13811401
// Unpin the task if it's already pinned
13821402
self.pane_tasks[pane_idx] = None;
13831403

1404+
// Clear the PTY reference when unpinning
1405+
self.clear_pane_pty_reference(pane_idx);
1406+
13841407
// If this was previously pane 2 and its now unpinned and pane 1 is still set, set the pane arrangement to single
13851408
if pane_idx == 1 && self.pane_tasks[0].is_some() {
13861409
self.layout_manager
@@ -1724,6 +1747,10 @@ impl App {
17241747
if let Some(pty) = self.pty_instances.get(&task_name) {
17251748
terminal_pane_data.can_be_interactive = in_progress && pty.can_be_interactive();
17261749
terminal_pane_data.pty = Some(pty.clone());
1750+
} else {
1751+
// Clear PTY data if the task exists but doesn't have a PTY instance
1752+
terminal_pane_data.pty = None;
1753+
terminal_pane_data.can_be_interactive = false;
17271754
}
17281755
} else {
17291756
// Clear PTY data when switching to a task that doesn't have a PTY instance

0 commit comments

Comments
 (0)