Skip to content

fix(tabs): recompute grid rows when the tab strip toggles#1699

Closed
cmoron wants to merge 1 commit into
raphamorim:mainfrom
cmoron:fix/tab-bar-grid-overflow
Closed

fix(tabs): recompute grid rows when the tab strip toggles#1699
cmoron wants to merge 1 commit into
raphamorim:mainfrom
cmoron:fix/tab-bar-grid-overflow

Conversation

@cmoron

@cmoron cmoron commented Jul 4, 2026

Copy link
Copy Markdown

Summary

Opening a second tab (or closing back to a single tab) shows/hides the tab strip, which changes the terminal's top margin. The grid's row count was not recomputed, so the bottom rows overflowed off-window until the next window resize.

Reproduction

  1. Launch Rio in the default Tab navigation (tab strip hidden while there is a single tab).
  2. Fill the terminal to the bottom (e.g. seq 1 200, or open vim).
  3. Open a second tab — the strip appears.
  4. The content shifts down by the strip height, but the grid keeps the same number of rows, so the bottom row (shell prompt / bottom of vim) is now clipped below the window edge. The window itself did not resize.
  5. Manually resizing the window corrects it.

Reproduced on main (2bb89d2); the report was cross-platform.

Root cause

ContextGrid represents the margin twice, and both must stay in sync:

  • scaled_margin — the render offset (origin_y = panel_rect.y + scaled_margin.top).
  • the Taffy root-node size — from which the panel height, and therefore the row count (lines, the PTY winsize), is derived. It is set by try_update_size, which subtracts scaled_margin.

ContextGrid::resize() (the window-resize path) updates both. But resize_top_or_bottom_line — the tab-strip toggle path — called update_scaled_margin() (which sets only the field) followed by resize_all_contexts() (which resends the existing, now-stale dimension). The Taffy root was never resized, so lines stayed at the full-height value: the content shifted down without dropping any rows, and only the next window resize (the one path that runs try_update_size) corrected it.

Fix

After updating the margin, re-run the same per-grid resize the window-resize path already uses (try_update_size + apply_taffy_layout), so the root shrinks by the new margin and the row count is recomputed and pushed to the PTY. This covers both directions: the strip appearing (1 → 2 tabs) and disappearing (2 → 1).

Testing

  • cargo test -p rioterm — 147/147 pass.
  • Verified manually on Linux (WSLg) with before/after builds: opening a tab no longer clips the bottom, and closing back to a single tab refills the grid instead of leaving a gap at the bottom.

Opening the second tab (or closing back to one) shows/hides the tab
strip, which changes the terminal's top margin. `resize_top_or_bottom_line`
updated the grid's `scaled_margin` — the render offset — but never resized
the Taffy root node, so the panel kept its full-window height and the row
count (PTY lines) stayed unchanged. The content simply shifted down by the
strip height while keeping the same number of rows, pushing the bottom rows
(shell prompt, bottom of vim) off-window. It only self-corrected on the next
window resize, which is the one path that runs `try_update_size`.

Re-run the same per-grid resize the window-resize path already uses
(`try_update_size` + `apply_taffy_layout`) after updating the margin, so the
root shrinks by the new margin and the line count is recomputed and pushed
to the PTY.
@cmoron

cmoron commented Jul 4, 2026

Copy link
Copy Markdown
Author

Closing as a duplicate. This is #1495, already addressed by #1632 (fixes at update_scaled_margin and adds a regression test — closes the issue) and #1687. I reached the same root cause independently — the terminal margin is tracked both in the scaled_margin field and in the Taffy root-node size, and only resize()/try_update_size kept them in sync — but those PRs got there first, so no need for a fourth. Thanks!

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.

1 participant