fix(core): improve pinned tasks annotation on narrow width (#31175)

This is intended to be a super quick improvement until I can work on
something a bit more substantial.

## Current Behavior
<!-- This is the behavior we have today -->

We always try and render `[Pinned output {}]`.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

We only render `[{}]` on narrow widths.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
James Henry 2025-05-12 23:06:14 +04:00 committed by GitHub
parent 29d9d154e9
commit 07c8b4f41b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,19 @@
---
source: packages/nx/src/native/tui/components/tasks_list.rs
expression: terminal.backend()
---
" "
" NX Running Test Task Duration"
" "
" "
"> · task1 [1] ..."
" · task2 ..."
" · task3 ..."
" "
" "
" "
" "
" "
" "
" "
" ← 1/1 → quit: q help: ?"

View File

@ -1001,7 +1001,11 @@ impl TasksList {
.enumerate()
.filter_map(|(idx, task)| {
if task.as_deref() == Some(task_name.as_str()) {
Some(format!("[Pinned output {}]", idx + 1))
Some(if has_narrow_area_width {
format!("[{}]", idx + 1)
} else {
format!("[Pinned output {}]", idx + 1)
})
} else {
None
}
@ -2781,4 +2785,15 @@ mod tests {
render_to_test_backend(&mut terminal, &mut tasks_list);
insta::assert_snapshot!(terminal.backend());
}
#[test]
fn test_pinned_tasks_with_narrow_width() {
let (mut tasks_list, test_tasks) = create_test_tasks_list();
let mut terminal = create_test_terminal(40, 15);
tasks_list.pin_task(test_tasks[0].id.clone(), 0);
render_to_test_backend(&mut terminal, &mut tasks_list);
insta::assert_snapshot!(terminal.backend());
}
}