Skip to content

fix(wait): name the pattern and the dropped frames in a timeout - #881

Merged
vyncint merged 2 commits into
vyncint:mainfrom
alvaroalonsoparrondo-a11y:fix/timeout-names-pattern-and-dropped-frames
Nov 27, 2026
Merged

vyncint merged 2 commits into
vyncint:mainfrom
alvaroalonsoparrondo-a11y:fix/timeout-names-pattern-and-dropped-frames

Conversation

@alvaroalonsoparrondo-a11y

Copy link
Copy Markdown
Contributor

Fixes #840

Two timeouts left out what they waited for:

  1. wait_until_matches reused wait_until's message, "the screen predicate to hold", so a failed regex wait never said which pattern it was.
  2. A wait_frame timeout after a burst longer than the 8-frame ring said "20 complete frames observed", which reads as twenty frames the predicate rejected. Only the newest eight were ever offered to it.

Changes, in crates/termlens/src/terminal.rs:

  • Pattern: wait_until_matches_for now goes through wait_screen_inner with a description, a row matching ``. wait_screen_deadline keeps its signature and passes no description, so every other wait reads as before. `wait_screen_inner` already returns the screen the predicate held on, so the method still returns the matched instant, and the `Screen::clone` the old closure made is gone.
  • Dropped frames: wait_frame_deadline tracks the next frame index past the cursor it has not offered yet. Each time it looks at the ring, any gap between that index and the oldest frame still kept is counted as dropped. On a timeout, a non-zero count is added inside the parenthesis: (20 complete frames observed; 12 of them left the ring before a wait could see them, since only the newest 8 are kept). The same note is added to the "since the last one returned" and "since the resize" forms. Frames the wait did offer are never counted, even when they leave the ring later.

Tests, each failing on main:

  • tests/search.rs, wait_until_matches_returns_the_screen_it_matched: the existing timeout now also asserts that the first line names a row matching `never \d+`.
  • tests/frames.rs, a_timeout_after_a_long_burst_says_how_many_frames_were_dropped: the issue's 20-frame burst. The timeout says 12 left the ring and only the newest 8 are kept, and the oldest frame still offered is FRAME 13. Ignored on Windows like its neighbours (Unix only: what Windows support would actually take #149).

CHANGELOG: entry under Unreleased → Fixed.

Checked on macOS: cargo fmt --all --check, cargo clippy -p termlens --all-targets --all-features -- -D warnings and with --no-default-features, cargo test -p termlens --all-features --test frames --test search --test timeouts, check-dco.sh and check-no-ai-attribution.sh.

Álvaro Alonso
242080768+alvaroalonsoparrondo-a11y@users.noreply.github.com

Fixes vyncint#840

Signed-off-by: Álvaro Alonso <242080768+alvaroalonsoparrondo-a11y@users.noreply.github.com>
vyncint
vyncint previously approved these changes Nov 27, 2026

@vyncint vyncint left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against the issue; CI is green. Thank you.

Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
@vyncint
vyncint merged commit d7c0285 into vyncint:main Nov 27, 2026
17 checks passed
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.

wait_until_matches times out without naming its pattern, and wait_frame counts frames it never offered

2 participants