Skip to content

fix(tui): align tab mouse hitboxes with rendered labels - #573

Merged
junhoyeo merged 1 commit into
junhoyeo:mainfrom
jeongjin0:fix/tui-tab-click-hitboxes
May 24, 2026
Merged

junhoyeo merged 1 commit into
junhoyeo:mainfrom
jeongjin0:fix/tui-tab-click-hitboxes

Conversation

@jeongjin0

@jeongjin0 jeongjin0 commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a TUI tab mouse hitbox alignment bug where clicking directly on the visible Daily tab label could activate the tab to its left, requiring users to click farther right than the rendered label.

The header previously rebuilt tab click areas with a hard-coded horizontal offset (area.x + 12) while Ratatui renders Tabs inside the bordered block's inner area. The registered mouse hitboxes now follow the same geometry as the rendered tab strip: block inner area, left/right tab padding, rendered label width, and the custom " │ " divider.

Changes

  • Replaced the hard-coded tab click-area start offset with Ratatui-aligned tab geometry.
  • Reused a single tab-label helper for rendered labels and hitbox width calculation.
  • Added regression coverage for clicking the rendered Daily label in the normal tab layout.
  • Added regression coverage for clicking the rendered Day short label in the very-narrow tab layout.

Verification

  • cargo fmt --check
  • cargo check -p tokscale-cli
  • cargo test -p tokscale-cli daily_label_click_uses_rendered_normal_tab_position
  • cargo test -p tokscale-cli daily_short_label_click_uses_rendered_very_narrow_tab_position
  • cargo test -p tokscale-cli
  • git diff --check

Manual QA

  • Ran cargo run -p tokscale-cli -- tui
  • Clicked directly on the visible Daily tab label and confirmed it switches to Daily without needing to click to the right of the label.

CI Notes

This touches crates/tokscale-cli/**, so the native CLI build workflow is expected to run. The broader Rust CI may also run workspace formatting, clippy, and tests.


Summary by cubic

Fixes TUI tab hitboxes so clicking directly on a label selects the correct tab. Click areas now match the rendered ratatui Tabs geometry, removing the rightward offset.

  • Bug Fixes
    • Compute click areas from the block’s inner area, label width, left/right padding, and the " │ " divider.
    • Reuse one tab-label helper for rendering and hitbox width.
    • Add regression tests for normal and very narrow layouts (clicking "Daily").

Written for commit 059b216. Summary will update on new commits. Review in cubic

@vercel

vercel Bot commented May 20, 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 May 20, 2026 6:05am

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.

No issues found across 1 file

Re-trigger cubic

@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.

Thanks a lot!

@junhoyeo
junhoyeo merged commit 2ab5f2b into junhoyeo:main May 24, 2026
5 checks passed
@junhoyeo

Copy link
Copy Markdown
Owner

@jeongjin0 this has been merged to v3.0.0: https://github.com/junhoyeo/tokscale/releases/tag/v3.0.0 thanks for the contribution!

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