Skip to content

feat(scenario): add ScreenBuffer::occupied_rows() for flood assertions - #163

Merged
Roger-luo merged 1 commit into
mainfrom
feat/scenario-occupied-rows
Jun 11, 2026
Merged

feat(scenario): add ScreenBuffer::occupied_rows() for flood assertions#163
Roger-luo merged 1 commit into
mainfrom
feat/scenario-occupied-rows

Conversation

@Roger-luo

Copy link
Copy Markdown
Owner

Summary

Adds ScreenBuffer::occupied_rows() to the scenario crate: 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() or screen[N..].iter().all(|l| l.is_empty()); occupied_rows() names the intent and lives next to the rest of the ScreenBuffer API.

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).
  • 4 unit tests: non-blank rows, blank screen, rows cleared by ESC[2J, and sparse content (only rows with text counted).

Test Plan

  • cargo nextest run -p scenario — full suite passes (incl. 4 new occupied_rows tests)
  • cargo fmt -p scenario clean
  • cargo clippy -p scenario --all-targets -- -D warnings clean

🤖 Generated with Claude Code

@Roger-luo
Roger-luo merged commit 970ff4c into main Jun 11, 2026
4 checks passed
@Roger-luo
Roger-luo deleted the feat/scenario-occupied-rows branch June 11, 2026 21:47
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