feat(scenario): add ScreenBuffer::occupied_rows() for flood assertions - #163
Merged
Conversation
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
Adds
ScreenBuffer::occupied_rows()to thescenariocrate: the number of screen rows containing at least one non-space character.This is a reusable primitive for asserting that transient terminal output — a status line, a progress/log tail, an in-place spinner — stays bounded and doesn't flood the screen. Today callers hand-roll this with
visible_screen().iter().filter(|l| !l.is_empty()).count()orscreen[N..].iter().all(|l| l.is_empty());occupied_rows()names the intent and lives next to the rest of theScreenBufferAPI.Motivating use case: a downstream CLI (autotune) renders a dimmed rolling "tail" of subprocess output via cursor-up + erase escape sequences. A regression there let the tail flood the screen when lines wrapped.
occupied_rows()lets a PTY test assert the rendered screen never fills up — the kind of "no-flood" check the raw output stream can't express (only the vte-rendered screen reflects the erases).Changes
ScreenBuffer::occupied_rows(&self) -> usize— counts rows with non-space content (post-vte, so cleared/erased rows don't count).ESC[2J, and sparse content (only rows with text counted).Test Plan
cargo nextest run -p scenario— full suite passes (incl. 4 newoccupied_rowstests)cargo fmt -p scenariocleancargo clippy -p scenario --all-targets -- -D warningsclean🤖 Generated with Claude Code