Repository navigation
Hooks: ctx.topLevel runs the top-level hook a route's own replaces - #117
Merged
Merged
Conversation
A route's own before or beforeShot still replaces the top-level one, but can now run it with `await topLevel?.()`, inside the same timeout and hook error. shotId includes the top-level hook's source. Refs #59 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 2, 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.
A route's own
beforeorbeforeShotstill replaces the top-level one; that stays the default. It can now run the hook it replaced throughctx.topLevel:topLevelis set only on a route's own hook when a different top-level hook of that kind exists. Otherwise it is undefined, hence the?.(). It runs with the same page and{ side, route, width }, inside the calling hook's step. A throw or a hang there is reported as that hook's error or timeout, the same as before.Notes
shotIdincludes the top-level hooks' sources, so a--cache-rightrecording isn't replayed after only the top-level hook changes.configHashchanges for every config, because routes carry the new field. That's harmless:version()already invalidates reruns on every release. Accepted entries aren't keyed on it, so they're unaffected.Hookjsdoc, renderdiff.config.example.ts, docs/scoping.md and skills/renderdiff/reference.md.Testing
npm test(362/362) pass.shotIdassertion checks that a different top-level hook gives a different key.Refs #59
🤖 Generated with Claude Code