docs(visuals): document renderer clear-highlights contract at end of playback#234
Merged
Merged
Conversation
…playback The README's "Example: playing a snippet" walked through the auto-play loop but didn't say what the renderer must do once the player stops advancing. machines-demo hit this as #108 — the residual halt-iter highlight stayed painted on the graph forever after `forward()` returned false, reading as "playback froze before halt" rather than "the machine halted." Adds a "Renderer contract" subsection that: - Names recordSnippet's faithful one-frame-per-iter shape (NO synthetic "settled" frame is appended; the last frame is the halt iter with highlight.toId === 0, strong: 'from'). - Tells consumers to clear highlight classes when `forward()` stops returning true (and in any equivalent settled-on-final-frame path). - Notes that the recorder leaves the clear-step to the renderer on purpose — animation-loop concern, not a recording concern. - Calls out reduced-motion: keeping or clearing the halt-iter highlight is a consumer choice (recorder doesn't dictate). No source change — recordSnippet behavior is unchanged. Docs-only.
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.
Doc-only follow-up to machines-demo#108 / machines-demo PR #109.
Why
The README's "Example: playing a snippet" walked through the auto-play loop but didn't say what the renderer must do once the player stops advancing. machines-demo hit this in production — the residual halt-iter highlight stayed painted on the graph forever after `forward()` returned `false`, reading as "playback froze before halt" rather than "the machine halted."
That's actually a renderer-loop concern, not a recording concern: `recordSnippet` faithfully captures one Frame per iter (the last one IS the halt iter with `highlight.toId === 0`); whether to clear the highlight when the animation loop stops is up to the consumer. machines-demo fixed it consumer-side in PR #109. This PR documents the contract upstream so future consumers know the same.
What
Adds a "Renderer contract: clearing highlights at end of playback" subsection between the `SnippetPlayer` pure-state paragraph and the Versioning section. The new prose:
Includes the diff-shaped code snippet showing the `clearHighlightClasses(ops)` call inside the `if (!player.forward()) { ... }` branch.
Rejected alternative — append a `highlight: null` settled frame to `recordSnippet`
Tempting because it would auto-fix any future consumer without them reading docs. But:
The "faithful recording + documented consumer contract" framing is cleaner.
No source change
`recordSnippet.ts`, `snippetPlayer.ts`, and the snippet `.spec.ts` files are unchanged. No version bump. CHANGELOG unchanged. Docs-only.
Verification