Repository navigation
feat: add wait_for_change and screen_diff (#116) - #144
Merged
Merged
Conversation
wait_for_change polls a target with ~0.2 s low-res grabs and returns when it changes or settles, with the changed regions and a final screenshot, so agents stop guessing sleeps. screen_diff compares two images: SSIM, changed share, and bounding boxes of the changes, outlined inline. Both share a pure cell-grid differ in utils/diff.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Closes #116.
What
wait_for_change{ target, mode: change | settle, timeoutSec, settleSec, intervalMs, pixelThreshold }change: returns as soon as the target differs from the starting frame.settle: returns once consecutive frames have been still forsettleSec.outcome(changed/settled/timeout/cancelled),elapsedSec, changedregionsin screen coordinates, window match info forwindow:targets, and a final screenshot inline. A timeout is a normal result; cancellation (extra.signal) stops the loop.screen_diff{ a, b, pixelThreshold }ssimfilter, plusmeanDiff,changedFraction, and bounding boxes of changed areas inb's pixel coordinates;bcomes back inline with the boxes outlined (drawbox).Shared
src/utils/diff.ts(pure): analysis sizing, target → screen rect (full= union of monitors), an 8 px cell grid with mean-abs-diff threshold (default 12/255, which catches a caret and ignores encoder noise), 8-neighbour grouping into boxes (largest first), scaling and offsetting back to source pixels. A newrunFfmpegBufferreturns raw stdout bytes;runCapturedecodes text and would corrupt them.I used a cell grid rather than the
blend=difference+ connected-components-in-ffmpeg route the issue sketched: it's one tiny raw frame per check and pure, testable JS.Tests
diff.test.ts): sizing, full/monitor/region rects, identical frames, sub-threshold noise ignored, a box landing on the expected cells with scale + origin, two separate changes as two boxes (largest first), size mismatches, arg builders, SSIM parsing.wait_for_changereportschangedwith regions inside it, thensettlereportssettledwith an inline screenshot. Alsoscreen_diffof a screenshot with itself → identical, SSIM ≈ 1. Harness 12/12.Version 0.18.0; README (29 tools), Pages,
mcp-tools.json, CHANGELOG.🤖 Generated with Claude Code