Skip to content

test(visual): ROI-mask screenshots to eliminate clock and chrome drift#28

Merged
afonsojramos merged 2 commits into
mainfrom
roi-crop-screenshots
May 12, 2026
Merged

test(visual): ROI-mask screenshots to eliminate clock and chrome drift#28
afonsojramos merged 2 commits into
mainfrom
roi-crop-screenshots

Conversation

@afonsojramos
Copy link
Copy Markdown
Member

Summary

Even after #22, #25, and #26, the auto-refresh PR keeps reopening every push because residual clock/dock/wallpaper drift survives time-pinning on some platforms (macOS menu bar clock, Linux MATE/Tint2 panels, Windows taskbar clock). Suppressing every clock source per-OS is whack-a-mole; this PR sidesteps it by masking the saved screenshot to only the rects we care about.

  • Fixture: after showWindow(), emit VISUAL:bounds={"tray":{...},"window":{...},"scale":N} with mb.tray.getBounds(), mb.window.getBounds(), and the primary display's scale factor for DIP→physical-pixel conversion.
  • run.ts: pixel-check the original full-screen capture (tray detection still works on platforms like Linux SNI where tray.getBounds() returns {0,0,0,0}), then mask the on-disk PNG to keep only the tray + window rects (with 4px padding) and write the masked version. Everything outside — clock, dock, wallpaper, pre-launched File Explorer — becomes solid black.

Auto-refresh PR diffs from here on out should only fire when the actual tray icon or popover window rendering changes, not when the OS clock ticks.

Test plan

  • All 14 visual jobs pass (pixel check still operates on full screen pre-mask)
  • Inspect a sample of the new screenshots: tray-icon + cyan/yellow window visible on black background, no clock or other OS chrome
  • Two consecutive runs on main after merge → auto-refresh PR diff is empty or close to it

@afonsojramos afonsojramos merged commit 55dd44a into main May 12, 2026
27 checks passed
afonsojramos added a commit that referenced this pull request May 12, 2026
…rift (#31)

## Summary
Continuous-improvement step on the visual ROI work. The remaining drift
after #28 was 5/14 platforms showing ~1-2% pixel jitter, driven by
anti-aliasing at the cyan→yellow boundary line inside the window and the
magenta/green checker against macOS's translucent menu bar.

This PR replaces the window content with solid blocks of color:
- **Old**: 200x100 split horizontally — cyan (top) / yellow (bottom). A
subpixel AA seam where the colors meet jittered between runs.
- **New**: 200x100 white background with a centered solid 80x40 black
rectangle. No AA inside the rectangle (pure white-to-white). One sharp
AA boundary at the inner square edge, but that's between two solid
colors with no transparency, so it should render deterministically.

Tray icon stays as the magenta/green checker — it's the *backdrop*
(macOS menu bar translucency) that causes its drift, which is unfixable
without redesigning the icon altogether.

Detection logic moved from "global cyan+yellow pixel count" to
"white+black pixel count *inside* the reported `window.getBounds()`
rect", which also stops OS chrome white/black text from contributing
false-positives. Thresholds: ≥5000 white + ≥500 black inside the rect
(out of an expected ~16800 + ~3200 fully visible).

## Test plan
- [ ] All 14 visual jobs pass with the new detection
- [ ] After merge: auto-refresh PR diff shrinks from 5 → 0-1 platforms
(or close to it)
- [ ] Saved screenshots show a white "frame" where the window is (the
inner black square blends with the black mask background — that's fine,
the frame is the visual cue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant