fix(tui): guard degenerate scroll region when one row remains above viewport#519
Open
ritammehta wants to merge 2 commits into
Open
fix(tui): guard degenerate scroll region when one row remains above viewport#519ritammehta wants to merge 2 commits into
ritammehta wants to merge 2 commits into
Conversation
…iewport insert_history_lines emitted ESC[1;1r when area.top() == 1 — an invalid DECSTBM region (bottom margin must exceed top) that terminals ignore, falling back to a full-screen scroll region. Every inserted history line then scrolled the live viewport itself, and ratatui's diff buffer never repaired the damage because it believed the viewport was intact. Large completed-turn outputs made this state both more reachable (tall viewports) and more destructive (one full-screen scroll per line). Extend the existing top()==0 guard (#358) to top() <= 1: warn, keep the call cursor-position-neutral, persist any viewport move made by the scroll-down branch, and return false so the caller retains pending lines for retry. The deferral is self-healing: the next insert scrolls the viewport down further, opening a valid region. Adds four VT100-backed regression tests: static top()==1 corruption and return contract, the scroll-down-into-y==1 path, and retry convergence. 🤖 Generated with [Nori](https://noriagentic.com) Co-Authored-By: Nori <contact@tilework.tech>
- bump anyhow 1.0.100 -> 1.0.103 (RUSTSEC-2026-0190, unsound downcast_mut) - ignore RUSTSEC-2026-0194/0195: quick-xml <0.41 is pinned transitively by plist (via os_info; latest plist still uses 0.39) and tauri-winrt-notification, and both parse locally-generated XML only - ignore RUSTSEC-2026-0189: rmcp <1.4 DNS rebinding targets its HTTP server transport; our only rmcp HTTP server binds loopback and requires a per-session random bearer token on every request. rmcp 0.12 -> 1.4 is a major upgrade tracked separately 🤖 Generated with [Nori](https://noriagentic.com) 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_linesemitted an invalidESC[1;1rDECSTBM when exactly one row remained above the inline viewport (area.top() == 1). Terminals ignore invalid DECSTBM and fall back to a full-screen scroll region, so each inserted history line scrolled the live viewport itself — persistent display corruption, since ratatui's diff buffer believed the viewport was intact and never repainted it. Large completed-turn outputs make this state both more reachable (tall viewports) and more destructive (one full-screen scroll per line). This is the unguarded sibling of thetop()==0fix from fix(tui): Guard against degenerate scroll region when viewport fills screen #358.area.top() <= 1: warn, stay cursor-position-neutral, persist any viewport move made by the preceding scroll-down branch, and returnfalsesoTui::drawretains pending lines. The deferral is self-healing — the next insert scrolls the viewport down further and succeeds (covered by a retry-convergence test).nori-rs/tui/docs.mdupdates.Follow-ups found during investigation (not in this diff)
tui.rsscroll_region_up(0..area.top(), …)on viewport expansion emits the same invalidESC[1;1rwhenarea.top() == 1; masked by the subsequentterminal.clear(), but can push stale viewport rows into scrollback.MAX_PENDING_LINES(1000) trim inTui::drawruns on every draw before insertion is attempted, so a single >1000-line batch loses its oldest lines even when insertion succeeds — contrary to its comment ("while blocked").Test Plan
cargo test -p nori-tui— 1349 passed, 0 failed; no pending insta snapshotsjust fmt/just fix -p nori-tuicleancargo build --bin nori && cargo test -p tui-pty-e2e— all runnable suites pass (requiresmock_acp_agentbinary built)./target/debug/nori --agent elizacpin an isolated tmux session — full turn completes, reply inserted into history above the viewport, no corruptionShare Nori with your team: https://www.npmjs.com/package/nori-skillsets