Skip to content

fix(tui): Guard against degenerate scroll region when viewport fills screen#358

Merged
theahura merged 1 commit into
mainfrom
auto/glad-orb-20260225-222054
Feb 25, 2026
Merged

fix(tui): Guard against degenerate scroll region when viewport fills screen#358
theahura merged 1 commit into
mainfrom
auto/glad-orb-20260225-222054

Conversation

@theahura

Copy link
Copy Markdown
Contributor

Summary

🤖 Generated with Nori

  • Fix frozen rows / scrollback corruption caused by insert_history_lines emitting a degenerate DECSTBM scroll region (\x1b[1;0r) when the viewport fills the entire terminal screen (area.top() == 0)
  • Add early return guard when there's no room above the viewport for history lines
  • Add two tests: one proving the bug (full-screen viewport corruption) and one regression test (history insertion with room above viewport)

Root Cause

SetScrollRegion(1..0) emits \x1b[1;0r. In DECSTBM, Pb=0 means "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 when insert_history_lines is called with a full-screen viewport
  • history_lines_inserted_above_viewport_with_room — confirms normal history insertion still works correctly
  • All 920 existing nori-tui lib tests pass
  • E2E tests pass (tui-pty-e2e)
  • Manual testing in tmux to verify the frozen rows issue no longer occurs

Share Nori with your team: https://www.npmjs.com/package/nori-ai

…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>
@theahura theahura merged commit 9b56139 into main Feb 25, 2026
3 checks passed
@theahura theahura deleted the auto/glad-orb-20260225-222054 branch February 25, 2026 23:44
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