Skip to content

ci(visual): pin time on screenshots to remove clock-driven diff noise#22

Merged
afonsojramos merged 6 commits into
mainfrom
pin-time-on-screenshots
May 12, 2026
Merged

ci(visual): pin time on screenshots to remove clock-driven diff noise#22
afonsojramos merged 6 commits into
mainfrom
pin-time-on-screenshots

Conversation

@afonsojramos
Copy link
Copy Markdown
Member

Summary

Each visual-tray run currently produces a different screenshot per platform every time, dominated by the OS clock ticking. That trains reviewers to dismiss image diffs in the auto-refresh PR without looking, and defeats the point of having screenshots in PLATFORMS.md. This PR removes the clock-driven noise per platform without touching system time globally.

  • macOS: defaults write com.apple.controlcenter "NSStatusItem Visible Clock" -bool false + killall ControlCenter to hide the menu bar clock entirely. Runs once after build, before bun run test:visual.
  • Linux (8 X11 DEs): install faketime, wrap each panel_cmd with faketime "@2026-01-01 00:00:00" bash -c "...". The libfaketime LD_PRELOAD intercepts time syscalls in the panel process and its children, so clock applets in MATE/Xfce/LXQt/KDE/Cinnamon/Tint2/GNOME/Budgie all display a frozen 2026-01-01 00:00:00.
  • Linux (Sway/Waybar): no change — Waybar config already has no clock module.
  • Windows (Server 2022/2025): extend VISUAL_PREPARE_CMD to set HKCU:\…\Explorer\Advanced\HideClock = 1 before restarting explorer. Best-effort on Server 2025 where Win11-style taskbar may ignore it; can iterate if needed.

After this lands, the next auto-refresh PR diff should be empty (or close to it) on platforms that re-run with no real rendering change — making any actual regression in tray icon / window painting immediately visible.

Test plan

  • All 14 visual jobs still pass (tray + window markers still detected; clock removal doesn't break panel layout)
  • Inspect the resulting .github/visual-screenshots/*.png to confirm no clock is visible (or that it shows 00:00)
  • Run visual-tray twice on main and confirm the second run produces a zero-diff auto-refresh PR

@afonsojramos afonsojramos merged commit d06293d into main May 12, 2026
27 checks passed
afonsojramos added a commit that referenced this pull request May 12, 2026
## Summary
Followup to #22. The first time-pin attempt only worked on the Linux DEs
whose panels are single-threaded. macOS, Windows, KDE, MATE still
drifted because each used the wrong mechanism.

- **macOS**: switched to the correct Sonoma+ Control Center key
(`defaults -currentHost write com.apple.controlcenter Clock -int 16`) +
hide the dock (`autohide=true`, `autohide-delay=1000`) so the
Calendar.app icon's daily date no longer drifts. Bumped killall sleep to
8s.
- **Linux**: swapped `libfaketime.so.1` → `libfaketimeMT.so.1`. The MT
variant intercepts time syscalls in multi-threaded panels (Plasma, MATE)
that the non-MT lib was missing.
- **Windows**: extended `VISUAL_PREPARE_CMD` to `Set-Date '2026-01-01
00:00:00'` + disable `w32time`. The taskbar clock will still tick during
the ~5s of test execution but starts at the same point, so PRs only show
seconds-level drift instead of full wall-clock drift.

Tint2 looks visually identical between runs (clock shows `00:00 Thursday
01 January` both times) but PNG bytes differ — residual font-AA noise,
not chasing.

(Replaces #24, which was branched from before #22 merged.)

## Test plan
- [ ] All 14 visual jobs still pass
- [ ] Inspect each platform's new screenshot to confirm clock is hidden
(macOS/Win) or frozen at 00:00 (Linux)
- [ ] Two consecutive runs on `main` after merge produce an auto-refresh
PR with empty or trivially small diff
afonsojramos added a commit that referenced this pull request May 12, 2026
#28)

## 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 deleted the pin-time-on-screenshots branch June 4, 2026 18:57
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