Skip to content

Wait+Screen regex fails to match text in the viewport after scrolling #659

@runesoerensen

Description

@runesoerensen

Describe the bug

When a .tape file generates enough output to cause the terminal to scroll, the Wait+Screen /regex/ command fails to find text that is printed/currently visible on the screen.

It appears that instead of searching the visible lines on the screen, the command searches the lines at the top of the terminal's scrollback buffer. This makes it impossible to use Wait+Screen to match new command output once a terminal has scrolled.

This issue is related to #657. and likely stems from the VHS.Buffer method, which appears to not account for the scroll position.

Setup

  • OS: macOS (15.6.1)
  • Shell: zsh, bash, nu

To Reproduce

  1. Create a file named wait-screen-test.tape with the following content.

    Set Height 300
    
    Type "seq 10"
    Enter
    Wait+Screen /9/
    
    Type "echo foo"
    Enter
    
  2. Run the tape file: vhs wait-screen-test.tape.

Actual Behavior

The vhs command execution halts and exits with a timeout error because the regex only matches against output in the beginning of the terminal buffer.

% vhs wait-screen-test.tape     
File: wait-screen-test.tape
Set Height 300
Type seq 10
Enter 1
Wait Screen 9
failed to execute command: timeout waiting for "Screen 9" to match 9; last value was: > seq 10
1                                                                                             
2                                                                                             
3                                                                                             
4                                                                                             
5                                                                                             
recording failed

Expected Behavior

The Wait+Screen command should match the regex by searching the terminal buffer visible on the screen. The tape execution should then continue.

% vhs wait-screen-test.tape
File: wait-screen-test.tape
Set Height 300
Type seq 10
Enter 1
Wait Screen 9
Type echo foo
Enter 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions