Skip to content

fix(core): use scroll-offset-based scrollbar positioning in TUI#34689

Merged
AgentEnder merged 1 commit intonrwl:masterfrom
comp615:fix/tui-scrollbar-position
Mar 21, 2026
Merged

fix(core): use scroll-offset-based scrollbar positioning in TUI#34689
AgentEnder merged 1 commit intonrwl:masterfrom
comp615:fix/tui-scrollbar-position

Conversation

@comp615
Copy link
Copy Markdown
Contributor

@comp615 comp615 commented Mar 4, 2026

Current Behavior

The TUI sidebar scrollbar thumb position is driven by the selected task's index among tasks (selected_task_index). This means the scrollbar can appear offset from the top even when scroll_offset=0 (i.e., the viewport is showing the very beginning of the list), because the selected task might not be the first one. This makes it look like there is content above that cannot be scrolled to.

Screenshot 2026-03-03 at 8 53 00 PM

Here, it looks scrolled down...but actually all the content is in view.

Expected Behavior

The scrollbar should accurately represent which portion of the entry list is currently in view. When at the top of the list (scroll_offset=0), the thumb should be at the top. When scrolled to the bottom, the thumb should be at the bottom.

Related Issue(s)

N/A (discovered via visual inspection)

Details

Switch the scrollbar from selection-based metrics to scroll-offset-based metrics:

  • content_length = total entries (including spacer rows)
  • viewport_content_length = viewport height
  • position = scroll offset

This ensures the scrollbar reflects the actual viewport position rather than the selected task's position within the task list.

Also adds total_entries and viewport_height fields to ScrollMetrics to make these values available without additional lock acquisitions.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 4, 2026

Deploy Preview for nx-docs canceled.

Name Link
🔨 Latest commit 969c1c4
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69a793db9abb6c000806a911

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 4, 2026

Deploy Preview for nx-dev canceled.

Name Link
🔨 Latest commit 969c1c4
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69a793db06f8040008c86b66

@comp615 comp615 force-pushed the fix/tui-scrollbar-position branch from 969c1c4 to efcfb6f Compare March 4, 2026 02:19
@comp615 comp615 marked this pull request as ready for review March 4, 2026 02:32
@comp615 comp615 requested review from a team as code owners March 4, 2026 02:32
@comp615 comp615 requested a review from FrozenPandaz March 4, 2026 02:32
@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Mar 4, 2026

View your CI Pipeline Execution ↗ for commit e28d373

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 1h 2m 28s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 15s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-04 16:12:01 UTC

@comp615 comp615 force-pushed the fix/tui-scrollbar-position branch 2 times, most recently from feebf95 to 3cd9e88 Compare March 4, 2026 13:13
The scrollbar was driven by selected_task_index, which reflects where
the selection is among tasks rather than the viewport's scroll position.
This caused the scrollbar thumb to appear offset even when at the top
of the list (scroll_offset=0), because the selected task might not be
the first visible one.

Switch to scroll-offset-based metrics (total_entries, viewport_height,
scroll_offset) so the scrollbar accurately represents which portion of
the entry list is currently in view.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019cb8f0-af3f-77bb-82b6-5d8a296655a7
@comp615 comp615 force-pushed the fix/tui-scrollbar-position branch from 3cd9e88 to e28d373 Compare March 4, 2026 14:11
@AgentEnder AgentEnder merged commit 79bbe1b into nrwl:master Mar 21, 2026
24 checks passed
FrozenPandaz pushed a commit that referenced this pull request Mar 26, 2026
## Current Behavior

The TUI sidebar scrollbar thumb position is driven by the selected
task's index among tasks (`selected_task_index`). This means the
scrollbar can appear offset from the top even when `scroll_offset=0`
(i.e., the viewport is showing the very beginning of the list), because
the selected task might not be the first one. This makes it look like
there is content above that cannot be scrolled to.

<img width="1165" height="833" alt="Screenshot 2026-03-03 at 8 53 00 PM"
src="https://github.com/user-attachments/assets/43c695ad-c4a8-40c9-85b0-7677a8b83d12"
/>

Here, it looks scrolled down...but actually all the content is in view.

## Expected Behavior

The scrollbar should accurately represent which portion of the entry
list is currently in view. When at the top of the list
(`scroll_offset=0`), the thumb should be at the top. When scrolled to
the bottom, the thumb should be at the bottom.

## Related Issue(s)

N/A (discovered via visual inspection)

## Details

Switch the scrollbar from selection-based metrics to scroll-offset-based
metrics:

- `content_length` = total entries (including spacer rows)
- `viewport_content_length` = viewport height
- `position` = scroll offset

This ensures the scrollbar reflects the actual viewport position rather
than the selected task's position within the task list.

Also adds `total_entries` and `viewport_height` fields to
`ScrollMetrics` to make these values available without additional lock
acquisitions.

Co-authored-by: Amp <amp@ampcode.com>
(cherry picked from commit 79bbe1b)
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants