Skip to content

wait_for_change mode "text": wait until OCR text appears or disappears #318

Closed

Description

@TMHSDigital

Summary

Agents have to loop find_text themselves to wait for "Build succeeded", paying a model round trip per poll. wait_for_change has pixel polling and find_text has OCR, but nothing joins them.

Where

  • src/tools/waitForChange.ts:31-36 (mode is change|settle)
  • src/tools/findText.ts (single grab, no polling)
  • src/utils/ocr.ts

Impact

Computer-use agents, CI scripts via screencast-mcp call, and golden-flow assertions (#269) would get a one-call wait.

Suggested fix

Add mode: "text" with query, regex, gone?: boolean. Run OCR only after a pixel change (reuse the existing diff) so a static screen costs nothing. Return the match box and elapsed time. Open questions: OCR cost per poll on large targets; minimum interval.

Acceptance criteria

  • mode text returns on appear/disappear with match box
  • OCR only runs after a pixel change

Getting started

  • Relevant files: src/tools/waitForChange.ts, src/tools/findText.ts, src/utils/ocr.ts
  • How to run tests: npm run build && npm test (also npm run typecheck and npm run lint)
  • Related docs: CONTRIBUTING.md, AGENTS.md

Filed by repo-audit/full-audit at f2fda28. Severity: medium. Effort: M. audit-key: enhancement|src/tools/waitForChange.ts|mode-text

Activity

  1. added
    enhancement
    on Nov 9, 2026
  2. TMHSDigital commented on Nov 15, 2026

    @TMHSDigital
    OwnerAuthor

    Done in 0239ea9: wait_for_change mode "text" takes text (with regex and gone options). It OCRs once at the start and again only after a pixel change, then returns the match boxes, elapsed time and ocrReads. Verified with pure loop tests (src/tests/textWait.test.ts: already present, read only after a change, one read for a still screen, gone, cancel) and live calls through the tool layer: gone matched on the first read, an absent string timed out after a single read.

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

    enhancementpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions