fix(core): correct TUI sidebar viewport height off-by-one#34682
fix(core): correct TUI sidebar viewport height off-by-one#34682comp615 wants to merge 1 commit intonrwl:masterfrom
Conversation
✅ Deploy Preview for nx-docs canceled.
|
4ffe6af to
6ddcac7
Compare
✅ Deploy Preview for nx-dev canceled.
|
6ddcac7 to
a3e1759
Compare
6092e30 to
70f3a2c
Compare
|
View your CI Pipeline Execution ↗ for commit 8fa6f29
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud is proposing a fix for your failed CI:
These changes fix the nx:format-native failure by reformatting the assert_eq! macro in the newly added viewport growth test to comply with Rust's cargo fmt standards. The multi-line assertion was condensed to a single line, which is the expected format for this macro signature, ensuring the code passes formatting validation without altering the test's behavior or the PR's core viewport fix.
Tip
✅ We verified this fix by re-running nx:format-native.
diff --git a/packages/nx/src/native/tui/components/task_selection_manager.rs b/packages/nx/src/native/tui/components/task_selection_manager.rs
index 0606acc26a..f30175effe 100644
--- a/packages/nx/src/native/tui/components/task_selection_manager.rs
+++ b/packages/nx/src/native/tui/components/task_selection_manager.rs
@@ -928,8 +928,7 @@ mod tests {
// scroll_offset should reset to 0 because task-1 (selected, index 0) fits
assert_eq!(
- manager.scroll_offset,
- 0,
+ manager.scroll_offset, 0,
"scroll_offset should reset to 0 when viewport grows from placeholder"
);
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Because this branch comes from a fork, it is not possible for us to apply fixes directly, but you can apply the changes locally using the available options below.
Apply changes locally with:
npx nx-cloud apply-locally TBaO-24o5
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
✅ Deploy Preview for nx-dev canceled.
|
The viewport height calculation subtracted 4 rows for header overhead, but the actual overhead is only 3 rows (top_margin + header content + spacing row). This caused the task list to appear scrolled down by one entry on initial render. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019cb994-7041-720d-a299-402ff210e978
70f3a2c to
8fa6f29
Compare
This PR description was generated by Amp.
Current Behavior
The TUI task sidebar appears scrolled down by one entry on render, hiding the first continuous task from view.
Here you can see that
watch-depsis running in addition todev.Expected Behavior
All continuous tasks should be visible in the sidebar without any initial scroll offset.
Related Issue(s)
N/A (discovered via visual inspection)
Details
The viewport height calculation in
tasks_list.rssubtracted 4 rows for header overhead, but the actual overhead is only 3 rows:top_margin(1 row)This off-by-one caused the viewport to be 1 row too small, making the task list appear scrolled down by one entry on initial render.
Changes
Unified overhead constant: Introduced
TABLE_HEADER_OVERHEAD_ROWS = 3andSCROLLBAR_Y_OFFSET = 2, replacing scattered hardcoded values. The scrollbar y-offset is 2 (not 3) because the scrollbar visually spans from the spacing row downward, while the viewport only counts content rows.Stale scroll correction: Added logic in
set_viewport_heightto resetscroll_offsetto 0 when the viewport grows from a small placeholder size (≤ 5) to the real terminal size, provided the selected item is still visible from the top. This prevents stale scroll positions set during initialization from hiding top items.Regression tests: Added
test_viewport_growth_resets_stale_scroll_offsetandtest_viewport_growth_preserves_scroll_when_selection_not_visibleto cover the stale scroll correction.Snapshot updates: 14 snapshot files updated to reflect one additional visible row.
History
The
4originated in commit6541751a(James Henry, Apr 2025) with the comment "Reserve space for pagination and borders." However, the table had no borders (Block::default()withoutBorders), and pagination lived in its own layout chunk. The4was a rough estimate that was never precisely derived from the actual header structure. When scrolling replaced pagination in commit1782e8c7(Leosvel Perez Espinola, Sep 2025), the value was carried forward unchanged. The same commit also introduced a separateheader_and_spacing_rows = 2for the scrollbar y-offset, confirming these values were set independently without unified accounting.Also documents the
copy-built-packagescript inAGENTS.mdfor AI-assisted development workflows.