fix(tui): Guard against degenerate scroll region when viewport fills screen#358
Merged
Conversation
…screen When the viewport occupies the entire terminal (area.top() == 0), insert_history_lines would emit \x1b[1;0r (DECSTBM with Pb=0), which terminals interpret as "full screen" rather than "empty region". This caused history content to scroll through and overwrite viewport rows, producing frozen/stale rows that ratatui's diff renderer could not detect. Add an early return when area.top() == 0 since there is no room above the viewport for history lines. 🤖 Generated with [Nori](https://usenori.ai) Co-Authored-By: Nori <contact@tilework.tech>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
🤖 Generated with Nori
insert_history_linesemitting a degenerate DECSTBM scroll region (\x1b[1;0r) when the viewport fills the entire terminal screen (area.top() == 0)Root Cause
SetScrollRegion(1..0)emits\x1b[1;0r. In DECSTBM,Pb=0means "bottom of screen", so the scroll region covers the entire terminal instead of being empty. Subsequent\r\n+ content writes scroll and overwrite viewport rows. Ratatui's diff-based renderer doesn't know the screen was corrupted, producing frozen/stale rows.Test Plan
full_screen_viewport_does_not_corrupt_display— confirms viewport content is unchanged wheninsert_history_linesis called with a full-screen viewporthistory_lines_inserted_above_viewport_with_room— confirms normal history insertion still works correctlytui-pty-e2e)Share Nori with your team: https://www.npmjs.com/package/nori-ai