Skip to content

fix(companion): anchor screenshot-gallery fixtures to noon, not the wall clock - #665

Merged
dylanneve1 merged 1 commit into
mainfrom
fix/companion-screenshot-hermetic
Jul 26, 2026
Merged

fix(companion): anchor screenshot-gallery fixtures to noon, not the wall clock#665
dylanneve1 merged 1 commit into
mainfrom
fix/companion-screenshot-hermetic

Conversation

@claudiusthebot

Copy link
Copy Markdown
Collaborator

Follow-up #1 from #664.

The defect

test/screenshots/gallery_test.dart built its fixture timestamps straight from DateTime.now(). The sidebar buckets chats by calendar day against the real clock, so goldens generated at 21:45Z and re-checked after midnight came back 7 redTODAYYESTERDAY, PREVIOUS 7 DAYSPREVIOUS 30 DAYS, 3d→a hard date. Pure clock drift, and at a glance indistinguishable from a layout regression. I spent a chunk of last night's run proving that's all it was.

The fix

Anchor fixtures to noon of the current day, which keeps every offset far from both day boundaries.

Measured, not asserted

Simulated a date boundary by generating goldens under TZ=Etc/GMT+12 (local date 25 Jul) and checking them under TZ=Pacific/Kiritimati (local date 26 Jul):

drift
before 1.11% / 14383px
after 0.04% / 1041px

What this does not fix — stated plainly

The residual 0.04% is the relative age labels (3m, 2h), which sidebar.dart computes against the real clock, so they move by a digit as the hour advances. Removing that would mean injecting a clock into the production UI. Not worth it: the gallery's own header says it is a visual review tool, not a regression suite, its goldens are gitignored, and it does not run in CI. Regenerate them, don't diff them across hours. That tradeoff is documented in the file.

While verifying this I also confirmed the second follow-up offered in #664 — a ~0.02% flake where unmodified main fails against goldens generated from unmodified main minutes earlier. Not addressed here; it's real but separate, and the same "not a gate" reasoning applies.

flutter analyze clean, dart format on the touched file only. Test-only change — no production code touched.

…all clock

The gallery built its fixture timestamps from DateTime.now(), and the
sidebar buckets chats by calendar day against the real clock. Goldens
generated at 21:45Z and re-checked after midnight came back 7 red with
TODAY->YESTERDAY, PREVIOUS 7 DAYS->PREVIOUS 30 DAYS and 3d->a hard date:
pure clock drift, indistinguishable at a glance from a layout regression.

Anchor the fixtures to noon of the current day so every offset sits far
from both day boundaries. Measured across a simulated date boundary
(TZ=Etc/GMT+12 -> TZ=Pacific/Kiritimati): 1.11% / 14383px of drift down
to 0.04% / 1041px.

The residual is the relative age labels ("3m", "2h"), computed against
the real clock in the sidebar; killing that would mean injecting a clock
into production UI, which is not worth it for a gallery that is
explicitly not a regression gate. Documented in the file instead.
@dylanneve1
dylanneve1 merged commit 419f255 into main Jul 26, 2026
52 checks passed
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.

2 participants