-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Update screenshot collector #1373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: c0131eb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 4 files
Greptile OverviewGreptile SummaryUpdates the
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Caller
participant ScreenshotCollector
participant Page
participant Sharp
Caller->>ScreenshotCollector: start()
ScreenshotCollector->>Page: screenshot() [initial]
Page-->>ScreenshotCollector: Buffer
ScreenshotCollector->>ScreenshotCollector: store screenshot
loop Every interval (5000ms default)
ScreenshotCollector->>Page: screenshot()
Page-->>ScreenshotCollector: Buffer
ScreenshotCollector->>Sharp: resize & compare (MSE)
Sharp-->>ScreenshotCollector: MSE value
alt MSE >= threshold
ScreenshotCollector->>Sharp: calculate SSIM
Sharp-->>ScreenshotCollector: SSIM value
alt SSIM < threshold (different enough)
ScreenshotCollector->>ScreenshotCollector: store screenshot
end
end
end
Caller->>ScreenshotCollector: stop()
ScreenshotCollector->>Page: screenshot() [final, async]
ScreenshotCollector-->>Caller: Buffer[]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 1 comment
| // Capture final screenshot without blocking | ||
| this.captureScreenshot("final").catch((error) => { | ||
| console.error("Failed to capture final screenshot:", error); | ||
| }); | ||
| return this.getScreenshots(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The final screenshot capture is fire-and-forget, so getScreenshots() returns before the final screenshot is captured. If the caller needs the final screenshot included, this won't work as expected. Consider making stop() async and awaiting the capture, or document that the final screenshot is best-effort.
| // Capture final screenshot without blocking | |
| this.captureScreenshot("final").catch((error) => { | |
| console.error("Failed to capture final screenshot:", error); | |
| }); | |
| return this.getScreenshots(); | |
| // Capture final screenshot without blocking | |
| this.captureScreenshot("final").catch((error) => { | |
| console.error("Failed to capture final screenshot:", error); | |
| }); | |
| // Note: final screenshot may not be included as it's captured asynchronously | |
| return this.getScreenshots(); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/evals/utils/ScreenshotCollector.ts
Line: 81:85
Comment:
**logic:** The final screenshot capture is fire-and-forget, so `getScreenshots()` returns before the final screenshot is captured. If the caller needs the final screenshot included, this won't work as expected. Consider making `stop()` async and awaiting the capture, or document that the final screenshot is best-effort.
```suggestion
// Capture final screenshot without blocking
this.captureScreenshot("final").catch((error) => {
console.error("Failed to capture final screenshot:", error);
});
// Note: final screenshot may not be included as it's captured asynchronously
return this.getScreenshots();
```
How can I resolve this? If you propose a fix, please make it concise.
why
what changed
test plan
Summary by cubic
Updated the evals CLI screenshot collector to the latest version, adding image-diff filtering and compatibility with v3 Stagehand pages where navigation events are disabled by default. This reduces duplicate screenshots and stabilizes capture during eval runs.
New Features
Dependencies
Written for commit c0131eb. Summary will update automatically on new commits.