Skip to content

wait_for_change and screen_diff: let agents wait for and verify on-screen changes #116

Closed

Description

@TMHSDigital

What and who

Two watch tools for agents driving a UI:

  • wait_for_change { target, region?, timeoutSec, mode: "change" | "settle" }: polls a target and returns when it changes (a dialog appears) or settles (a build or page finishes loading).
  • screen_diff { a, b }: compares two images/frames and returns a similarity score and bounding boxes of changed areas.

Why

Agents verifying their own UI work today screenshot, guess a sleep, and screenshot again. Tools like ProofShot exist just to give agents "eyes to verify the UI they build" (https://hn.svelte.dev/item/47499672), and Playwright's new screencast API streams frames to vision models (https://testdino.com/blog/playwright-screencast). Those only work inside a browser. A desktop-level "wait until the screen changes" and a pixel diff is something no screen MCP server offers, and it works for any app on Windows.

Approach

  • Polling: repeated low-res gdigrab grabs (or one long ffmpeg process with select='gt(scene,T)' writing to a pipe) so it doesn't spawn ffmpeg per frame.
  • Diff: ffmpeg ssim/blend=difference + threshold to get a mask, then bounding boxes of connected areas computed in Node from the raw mask.
  • Return { changed, ssim, regions: [{x,y,w,h}], elapsedSec, framePath }.

Done when

wait_for_change returns within ~0.5 s of a window opening in the watched region, settle mode returns after N quiet seconds, and screen_diff reports correct regions on a fixture pair. Both tools are documented in the README watch loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort: mediumfeatureimpact: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions