Skip to content

test: avoid false failures in desktop OCR checks - #12828

Open
jdx wants to merge 2 commits into
omacom:quattrofrom
jdx:codex/acceptance-ocr-text
Open

jdx wants to merge 2 commits into
omacom:quattrofrom
jdx:codex/acceptance-ocr-text

Conversation

@jdx

@jdx jdx commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Desktop acceptance checks can report a missing prompt even when it is clearly visible. Tesseract's sparse-text output sometimes splits “Reminder message” across lines; capturing at double resolution can also distort text that reads correctly at native resolution, as happened with “Acceptance notification”. The previous helper searched for a phrase on one output line and always captured at 2× scale.

Normalize OCR whitespace before matching and try native resolution first, with a 2× fallback for small captions. Matching still requires the requested words; there is no fuzzy matching or change to the desktop UI.

Validation

  • Reproduced the reminder false negative from the saved failure screenshot and the notification recognition error from a live disposable Omarchy VM.
  • The complete in-guest acceptance suite passed in 68 seconds with this helper. The VM was installed from the feat(mise): install default CLI tools through native lazy shims #9596 candidate ISO; the affected UI and original acceptance helper are identical to quattro. That local ISO omitted an unavailable Apple T2 firmware package for QEMU testing.
  • All 11 helper checks pass, including five OCR regressions for split phrases, native-resolution recognition, doubled-resolution fallback, absent text, and failed captures. The original helper fails the new split-phrase regression.
  • Bash syntax and git diff --check pass.

This is a standalone test-infrastructure fix, separate from #9596's mise changes.

AI-assisted — Tool: Codex; model: openai/unavailable; version: unavailable.

@llstrk

llstrk commented Sep 21, 2026

Copy link
Copy Markdown

Verified: No actionable issue found in the tested scope at 24e25ec9. All 11 helper checks pass. Isolated tests of screen_contains confirm whitespace normalization and scale-1-first capture with scale-2 fallback:

Synthetic OCR/capture condition Previous helper PR helper
Reminder\n\nmessage... at both scales Misses Reminder message Matches
Requested text recognized only at scale 1 Misses Matches
Requested text recognized only at scale 2 Matches Matches after fallback
Text absent, or both captures fail Rejects Rejects

The head regression test fails against the previous helper. Separate call traces confirm scale ordering and temporary-snapshot cleanup. Matching remains case-insensitive and literal, not fuzzy.


Review information

Test scope: Baseline/head source inspection and deterministic helper tests with substituted capture/OCR commands; additional real Tesseract testing used synthetic images. No live compositor, VM, or full desktop acceptance run was performed. The reported overlay reproductions and 68-second suite result were not independently verified.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra initial inspection, independent Fable 5.1 and separate Astra reviews, followed by verification of claims against targeted evidence.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Oct 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 24e25ec9 against quattro. I found nothing to change.

What ran, on a disposable Omarchy VM with a live desktop:

  • test/shell.d/acceptance-helpers-test.sh: 11 of 11 pass at the head. With screen_contains put back to the quattro version, "OCR matches a phrase split across lines" fails.
  • The real overlays, using the VM's own grim and tesseract. I opened the reminder message prompt and sent "Acceptance notification" seven times, and ran both versions of screen_contains against each. Once, the 2× capture read the notification title as Acceptance notifica!ior; while the native capture read it correctly. The quattro helper missed it and this one found it. In the other six runs both versions found both phrases. The reminder prompt never split across lines in these runs, so that case is shown only by the stubbed regression test.
  • ./test/cli passes. ./test/shell has two failures, ascii-test.sh ("Hi is 18 columns wide") and branding-about-animation-test.sh. Both fail the same way on this PR's base, so they are not caused by this change.

Read, not run: the full graphical acceptance suite. I checked the loop by reading it: it tries native then 2×, deletes the snapshot on every path, and only returns success on a literal, case-insensitive match. Joining OCR lines does mean a phrase could match across two adjacent text blocks. For the short labels the existing callers look for, that trade is worth the false failures it removes.

Second opinion: none. Codex Medium answers its health check, but omabot's daily review budget was used up, so this is one reviewer's reading (Claude Opus 5.5).

Related: #11032 changes screen_contains differently, with a native capture resized by magick as a fallback, and #7406 adds capture-failure messages to the same helper. Neither replaces this PR, but whichever lands second will conflict here.

This now waits on the maintainer. The PR has no CI run and still needs a second-opinion review before it can be called ready.

screen_contains must not pass when tesseract itself fails, and must remove its snapshot whether or not the text was found. Both checks come from omacom#16028's acceptance-ocr-test.sh, folded in here in this file's stub style.

The failing tesseract stub still prints the phrase, and the check runs under pipefail as every acceptance caller does, so it fails if the helper ever stops honouring tesseract's exit status; a stub that printed nothing would pass on the missing text alone. The cleanup check runs straight after a match and straight after a miss, so a missing rm on either path is caught rather than masked by a later call reusing the same path.

Co-Authored-By: GBerfield <89108862+Gberfield@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed one commit here, bc2c866, which adds two checks to test/shell.d/acceptance-helpers-test.sh. Both come from @Gberfield's acceptance-ocr-test.sh in #16028 and are credited to them as co-author. Nothing in screen_contains itself changed.

  • An OCR failure does not pass an assertion. The failing tesseract stub still prints the phrase, and the check runs under pipefail as every acceptance test that calls screen_contains does. So it fails if the helper ever stops honouring tesseract's exit status, rather than passing only because the text was missing.
  • The snapshot is removed after a match and after a miss. Each path is checked straight after its own call, so a later call reusing the same /tmp path cannot hide a missing rm.

What ran, on a disposable Omarchy VM, at bc2c866 merged with current quattro (7075b61):

  • acceptance-helpers-test.sh: 13 of 13 pass. With quattro's screen_contains in place, "OCR matches a phrase split across lines" fails. Each new check also fails against a deliberately broken copy of the helper: one without the rm after a match, one without the rm after a miss, and one ignoring tesseract's exit status.
  • ./test/cli passes. ./test/shell has seven failures, and all seven also fail on quattro itself on the same VM: ascii-test.sh ("Hi is 18 columns wide"), the two background-cover checks, "a logo of plain block art animates", da/menu.json, the lock view startup timing, and the keepLoaded IPC check. An eighth, "same source leaked FDs" in windows-vm-compose-test.sh, failed once and passed three reruns on both trees.

Read, not run: the graphical acceptance suite. Joining OCR lines still means a phrase could match across two adjacent text blocks, as noted before. That is a trade-off for the maintainer, not a defect.

Second opinion: Codex Medium reviewed the whole pull request in two rounds. In the first round it found that my first draft of the OCR-failure check could never fail, because the stub printed nothing and this test file does not run under pipefail. The check above is the version that addresses this. Its second round, on bc2c866, found nothing open. Codex can read this session's notes, so its agreement is not guaranteed to be independent; the first-round finding was its own.

Related: #16028 changes the same helper to try 2× before native and keeps line-by-line matching, which misses phrases split at both resolutions that this one catches. Its checks are now part of this pull request. #11032 and #7406 also change screen_contains, so whichever of these lands second will conflict.

This is verified at bc2c866 and now waits on the maintainer. It is not marked ready because ./test/shell is not green on quattro itself, for the failures listed above.

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This PR appears safe to merge; no actionable issues were found.

Summary

Updates screen_contains to match phrases split across OCR lines and try native resolution before a doubled-resolution fallback.

  • Desktop checks find visible text across OCR line breaks.

Reviews (1) · Last reviewed commit: "test: check that OCR errors fail and cap..." · Reviewed by Greptile

@Gberfield

Copy link
Copy Markdown

Additional Weather reproduction supporting this older PR, carried over from #16028: #16028 (comment).

That retained offline replay used real Tesseract 5.5.3 with native/2× Weather captures. The unchanged upstream helper missed the visible SAN FRANCISCO label; this PR's helper recognized it and WIND, rejected absent San Diego, and removed its temporary capture. Capture was substituted with retained images; this was not a new live compositor run.

I have now checked bc2c8662e1a4bde21ae5b4f8ed556e6daecefff8 and rerun bash test/shell.d/acceptance-helpers-test.sh locally: 13/13 pass, including the transferred OCR-error and match/miss cleanup checks. The source includes those checks and the co-author credit. #16028 is being closed as superseded; there is no competing OCR-only PR from this work.

Whitespace normalization's possible cross-block phrase match remains the documented trade-off for maintainer review. This comment does not claim a fresh full graphical-suite pass.

@Gberfield

Copy link
Copy Markdown

The remaining reminder OCR failure is a segmentation issue: the retained failure image visibly contains “Reminder message”, but real Tesseract PSM 11 omits it. PSM 3 recognizes it. A follow-up tries PSM 3 on the same capture after PSM 11, at each existing native/doubled scale; matching, capture cleanup and capture-error behavior remain unchanged.

The proposed follow-up branch rebases this PR's two original commits onto upstream 967bbdd7 by cherry-picking them with their original authors, followed by 2e2e4cfd. It is intended for consolidation into this existing PR, not a competing OCR PR.

Evidence:

  • All 15 focused helper cases pass; the new fallback case fails against the original helper. Real-Tesseract replay of the retained reminder image fails on the parent and passes on the candidate, rejects absent phrases and cleans up captures. Replay substitutes capture, so it is not live compositor acceptance.
  • The retained integration with only this OCR function and the separately validated monitor-test correction passes shell-surfaces 24/24 and overlay-monitor 22/22 in the disposable guest. That composite has the older bar revision; it is not acceptance of every latest related PR together.
  • Exact test: verify panel fade reopen keyboard lifecycle #16182 source with only the proposed OCR function passes the unchanged strict panels file, including WIND and its original Escape assertion. The unchanged helper fails earlier at WIND in matched installed/control/candidate runs.
  • A final standalone run of the complete current-upstream follow-up at 2e2e4cfd98b6a9be82b99cef82852aca169979f9 also passes the unchanged strict panels file. All 5,215 source entries/modes match; this is separate from the older dependency-overlay run.
  • The current-upstream shared-helper offscreen aggregate remains RED: 38/476 shell files and the CLI suite fail. In one pristine-upstream control per failed file, 37 shell failures and the CLI failure recur. t3code-install passes isolated on the base; its aggregate failure remains a variability limitation, with no proven cause. It does not consume the graphical OCR helper. Every failure is retained; this is not an all-green aggregate or proof of graphical timing.
  • Bash syntax and diff checks pass. Standalone ShellCheck reports unused ROOT (SC2034) in the shared sourced helper on both pristine base and candidate; no unrelated source change was made to silence it.

No production focus change, fresh-ISO/full graphical-suite or physical acceptance is claimed. The whitespace normalization trade-off already documented on this PR remains. Keep this PR open and unmerged.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants