Skip to content

fix(check): preserve text in audit snapshots#2306

Merged
miguel-heygen merged 1 commit into
mainfrom
fix/check-snapshot-text
Jul 13, 2026
Merged

fix(check): preserve text in audit snapshots#2306
miguel-heygen merged 1 commit into
mainfrom
fix/check-snapshot-text

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

Summary

  • capture check --snapshots overview frames only after contrast auditing restores temporarily hidden text paint
  • keep the glyph-free measurement screenshot isolated to contrast math
  • add a browser-level regression test for visible text in persisted overview snapshots

Reproduction

On 0.7.55, a minimal 71-second composition containing ordinary text produced blank check --snapshots PNGs at 44s, 57s, and 70.2s. Standalone snapshot at those times showed the text correctly. The contrast auditor hides text to sample background pixels, and the check pipeline incorrectly persisted that measurement image.

Verification

  • bun run --cwd packages/cli test --run src/utils/checkBrowser.test.ts src/commands/check.test.ts (45 passed)
  • bun run --cwd packages/cli typecheck
  • source CLI end-to-end: fixed check PNG hashes match standalone snapshot hashes at 44s, 57s, and 70.2s
  • pre-commit lint/format/typecheck hooks passed

@james-russo-rames-d-jusso james-russo-rames-d-jusso left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at eb1366c0.

Right fix at the right layer. The invariant it depends on — finishContrast runs __contrastAuditFinish which restores the text paint hidden by prepareContrast — is enforced by the same code the finally block at checkBrowser.ts:542 doubles down on (safety-net call to __contrastAuditRestoreIfPending). So by the time the new overviewShot capture runs at line 528, text is guaranteed painted.

The two-screenshot design keeps concerns cleanly separated:

  • measurementShot — glyph-free, feeds contrast pixel-sampling math via finishContrast. Must stay untouched by annotations, must stay glyph-free.
  • overviewShot — text restored, feeds captureOverviewShot with the annotation overlay. What lands on disk as user-facing QA evidence.

The old code aliased measurementShot into both roles, which is exactly why blank text landed in the persisted PNGs. Splitting them is the load-bearing correctness change; the added screenshot is the minimum cost to preserve the contrast-math isolation.

Test coverage is precise: mock-installed __contrastAuditFinish that calls __contrastAuditRestoreIfPending?.(), page.screenshot returns "text-hidden-base64" when color: transparent, "text-visible-base64" otherwise. Assertions prove both (a) screenshot called twice — measurement + overview, and (b) the persisted result is the visible one. Ratchet.

Verified against feedback_narrow_titled_bugfix_check_root_cause: title says "preserve text in audit snapshots" — the fix is exactly the sibling to the finally block's restore invariant, no broader / narrower scope drift.

LGTM.

Review by Rames D Jusso

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving on Rames-D's go (R2 delta clean, nit round addressed) + Magi's CI-green confirmation. Verified at final head eb1366c0: CI green, no changes-requested, mergeable.

@miguel-heygen
miguel-heygen merged commit b861afe into main Jul 13, 2026
43 checks passed
@miguel-heygen
miguel-heygen deleted the fix/check-snapshot-text branch July 13, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants