Skip to content

fix: refresh Taffy root size when scaled margin changes#1632

Open
nikicat wants to merge 1 commit into
raphamorim:mainfrom
nikicat:fix/taffy-root-size
Open

fix: refresh Taffy root size when scaled margin changes#1632
nikicat wants to merge 1 commit into
raphamorim:mainfrom
nikicat:fix/taffy-root-size

Conversation

@nikicat

@nikicat nikicat commented May 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1495 — on opening a new tab the bottom of the terminal is hidden until the
window is resized.

Details

When a second tab is created and the tab bar transitions from hidden to visible,
update_scaled_margin updated only the stored margin — Taffy's root size still
reflected the old, larger available area. The subsequent layout pass then kept the
panel at its old height and the PTY was never reflowed, so the bottom rows ended up
clipped behind the freshly appeared tab bar. update_scaled_margin now refreshes
the Taffy root size so the next layout pass uses the correct available area.

Testing

cargo test -p rioterm — adds a regression test asserting the panel height shrinks
by the new top margin after update_scaled_margin.

Closes #1495

🤖 Generated with Claude Code

When a second tab is created and the tab bar transitions from hidden
to visible, `update_scaled_margin` updated only the stored margin —
Taffy's root size still reflected the old, larger available area.
The subsequent layout pass then kept the panel at its old height and
the PTY was never reflowed, so the bottom rows ended up clipped
behind the freshly appeared tab bar.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
(cherry picked from commit 8cd7ea6)
@cmoron

cmoron commented Jul 4, 2026

Copy link
Copy Markdown

Independently hit this (as #1495) and diagnosed the same root cause: the terminal margin is tracked in two places that must stay in sync — the scaled_margin field (render offset) and the Taffy root-node size, from which the row count / PTY winsize is derived. update_scaled_margin updated only the field, so the grid kept its full-height row count and the bottom rows overflowed off-window until the next window resize (the one path that runs try_update_size). Reproduced and verified the fix behaviour on Linux (WSLg), including the reverse transition (closing back to a single tab).

Fixing at the setter is the right call — every update_scaled_margin caller stays correct — and the regression test is a nice touch. I've closed my duplicate (#1699) in favour of this one. 👍

cmoron added a commit to cmoron/rio that referenced this pull request Jul 5, 2026
Adopte la PR upstream raphamorim#1632 (nikicat) : update_scaled_margin ne mettait à
jour que la marge stockée, laissant le root Taffy sur l'ancienne aire dispo.
Le hot-reload de conf recalculait alors les lignes contre un root périmé
(rows fausses jusqu'au prochain resize fenêtre). Complète ee589ea, qui
ne couvrait que le chemin resize_top_or_bottom_line (toggle barre d'onglets
/ barre de recherche). À dropper quand raphamorim#1632 est mergé upstream.
cmoron added a commit to cmoron/rio that referenced this pull request Jul 5, 2026
close_tab lisait ctx().len() *après* que close_current_context ait déjà
retiré le contexte, puis re-soustrayait 1 — donc fermer de 3 à 2 onglets
passait num_tabs=1 à resize_top_or_bottom_line. Sur Linux/Windows ça prend
la branche hide_if_single et retire la bande ISLAND_HEIGHT de la marge top :
la grille garde ~2 lignes de trop (débordent hors fenêtre). On passe le vrai
compte restant, comme tous les autres appelants.

Bug latent aussi upstream ; ne se réveille qu'une fois le recompute des
lignes actif (ee589ea / raphamorim#1632). Inerte sur macOS (branche num_tabs
compilée hors binaire).
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.

on opening new tab the bottom of the terminal is hidden until window resize

2 participants