Repository navigation
Add a beforeShot hook that runs after the page settles - #85
Merged
Merged
Conversation
A before hook runs ahead of the scroll pass, so state the scroll changes (a scroll-spy nav) can't be held. beforeShot has the same signature and precedence and runs right before masks and the shot. Fixes #71 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new
beforeShothook. It works likebefore, but it runs after the page settles, right before the masks and the shot.Why
A
beforehook runs before the settle's scroll pass, so it can't keep a state that scrolling changes. A scroll-spy nav, for example, is left on its last section by the time the shot is taken (#71). AbeforeShothook sets that state after the scroll pass.Semantics
before:(page, { side, route, width }). It can be set per route (routes[i].beforeShot) or at the top level.beforeShotreplaces the top-level one. A route with its ownbeforestill gets the top-levelbeforeShot.capture()after the whole settle (scroll pass, image decode, fonts, network idle, the latefreezeVideo/neutralizeCss) and before the selector, mask and text reads and the stability shots. Nothing settles again after it, so the docs say to await what it changes. On aselectorroute, the element is still scrolled into view after it.beforeShot hook failed on <side>: …, aHookError. It is never retried. A hung hook times outat beforeShot hook, also not retried. The step label goes back tosettleafterwards, so a later read that hangs is still retried.capture, so the hook runs there too.Behaviour changes
before hookis nowhook, since it also marks beforeShot-only routes.results.jsonkeepshook: true.shotIdincludesbeforeShot, so existing--cache-rightrecordings miss once and get re-recorded (1h TTL anyway). Without that, a hook that makes requests would replay a recording that lacks them.How tested
scroll-spy: the nav keeps whichever section the last scroll event saw, and Soon's status text differs per side.beforeclicking Soon is undone by the scroll pass (diff 0). This guards the fixture.beforeShotclicking Soon shows each side's own text, overrides a throwing top-level hook, and isn't flaggedvarieson the recheck.beforeShoterrors and isn't retried.beforeShottimes outat beforeShot hookand isn't retried.beforeShot(top level and per route), the dedupe message, andshotIddiffering when a beforeShot is set.src/capture.tsreverted, the 3 beforeShot tests fail and the guard still passes. With the change, they pass.typecheck,lintandformat:checkare clean.npm testpasses (317) andnpm run test:visualpasses (341).Fixes #71
🤖 Generated with Claude Code