Skip to content

fix(tui): align scrollbar position with viewport - #694

Merged
junhoyeo merged 1 commit into
junhoyeo:mainfrom
astkaasa:fix/tui-scrollbar-position
Jun 9, 2026
Merged

fix(tui): align scrollbar position with viewport#694
junhoyeo merged 1 commit into
junhoyeo:mainfrom
astkaasa:fix/tui-scrollbar-position

Conversation

@astkaasa

@astkaasa astkaasa commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a shared TUI scrollbar state helper that maps list scroll offsets to Ratatui's full content-position range.
  • Set viewport content length for scrollbars so thumbs reach the end of the track on the last visible page.
  • Apply the helper across TUI list/detail scrollbars, including Overview and Hourly's effective data-row viewport.

Tests

  • cargo test -p tokscale-cli scrollbar_state
  • cargo test -p tokscale-cli test_overview_scroll_keeps_rendered_capacity_after_resize
  • cargo test -p tokscale-cli

Summary by cubic

Fixes TUI scrollbars so the thumb matches the visible viewport across all screens and edge cases. The thumb now reaches the end of the track on the last page and stays at zero on single-page lists.

  • Bug Fixes
    • Added a shared scrollbar helper to map scroll offsets to ratatui content positions, set viewport content length, and clamp overscroll using wide math for large lists.
    • Applied across Agents, Daily (table and detail), Hourly (uses data-row viewport), Minutely, Models, Overview top models, and Stats breakdown.

Written for commit 52ee94a. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
tokscale Ignored Ignored Preview Jun 8, 2026 11:25pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread crates/tokscale-cli/src/tui/ui/widgets.rs Outdated
@astkaasa
astkaasa force-pushed the fix/tui-scrollbar-position branch from 7624878 to 52ee94a Compare June 8, 2026 23:24
@astkaasa

astkaasa commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author
image

unknown is the last item and is selected.

Left: my fix — the scrollbar is at the bottom.
Right: npx tokscale@latest — the scrollbar is in the middle.

@junhoyeo junhoyeo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: scrollbar rescaling math verified against ratatui 0.29 part_lengths(); all 8 ScrollbarState call sites consistent; cargo check/clippy/tests (709 passed incl. 5 new scrollbar tests) verified locally. Merging.

@junhoyeo
junhoyeo merged commit e37b818 into junhoyeo:main Jun 9, 2026
4 checks passed
@junhoyeo

junhoyeo commented Jun 9, 2026

Copy link
Copy Markdown
Owner

@astkaasa cool, thanks a lot!

t1000040 pushed a commit to tmobi-internal/tokscale that referenced this pull request Jun 30, 2026
Co-authored-by: astkaasa <2796928+astkaasa@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants