Repository navigation
feat(tooling): variant sheets, version comparison and pixel-offset diagrams - #705
Merged
Merged
Conversation
…agrams Three more things the screenshot harness could not do, each one a question that gets asked about a release: - **`variants-*`** renders one scenario once per declared style variant (an `inject` script each) and composes a labelled sheet, for "show me a few options so I can pick". The injection runs as a *step*, because React re-renders and would restore what a boot-time mutation changed. Purely visual: it edits the DOM in the browser, the product is untouched. - **`compare-*`** takes two captures of the same screen (two style options, or two versions) and produces a three-panel sheet: A with changed regions boxed in red, B boxed in blue and numbered, plus a difference panel with unchanged content faded and changes red. `--threshold` keeps anti-aliasing noise out. - **`offsets` steps + `measure-*`** draw an element's box (name and size) and the pixel distance to its neighbours (`mode: gap`) or to the viewport edge (`mode: edge`). With `--baseline` (an earlier `measure-*` run) each element also shows how far it moved and how its size changed. Numbers are CSS pixels at the emulated viewport, matching what a design file quotes. Element matching is now **ranked** rather than first-hit: an element whose own text is exactly the wanted name beats one whose aria-label merely contains it. This was a real bug — `技能` matched the composer's `选择技能` button, which silently produced a wrong measurement in an offset diagram (and would have clicked the wrong control elsewhere). Every measurement logs the element it actually hit, so a wrong match is visible instead of silent. Composed sheets needed two fixes of their own: Pillow's default bitmap font is unreadable next to a 1200px panel and renders CJK as tofu boxes, so a real CJK font is loaded and panels are downscaled; and the compare panel offsets were computed from the wrong assumption about the title row. Video quality: Chrome emits screencast frames at the CSS viewport size (it ignores the emulated device scale factor, unlike stills), so the encode now upscales with Lanczos to the stills' pixel dimensions and encodes at crf 18 instead of the x264 default. Interpolated, not extra optical detail — the docs say so. Also: the pointer indicator now defaults to on while recording and off for stills, so a product shot no longer gains a stray dot just because its scenario had to tap something. The guide gains recipes 5-7 for the above; CLAUDE.md lists the new subcommands.
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.
Follow-up to #703/#704. Three more questions get asked about a release that the harness could not answer; now it can.
variants-*— pick one of several stylesRenders one scenario once per declared variant (an
injectscript each) and composes a labelled sheet:The
{variantInject}placeholder puts the injection inside the steps rather than at boot, because React re-renders and restores what a boot-time mutation changed. Verified: a diff of the three panels is an ~8×10px region — the icon — with the rest identical.Purely visual: it edits the DOM in the browser. Whatever is chosen still has to be implemented.
compare-*— two captures, differences highlightedThree-panel sheet: A with changed regions boxed in red, B boxed in blue and numbered, plus a difference panel (unchanged content faded, changes red).
--thresholdand--min-areakeep anti-aliasing noise out. Works for two style options or two versions; the docs cover the two-version workflow (older checkouts need the harness copied in).Verified on a known pair: 1 changed region, red outline on the left panel, blue on the right, red marks on the diff panel.
offsets+measure-*— pixel spacing and movementDraws each element's box (name + size) and the pixel distance to its neighbour (
mode: gap) or to the viewport edge (mode: edge);axispicks vertical/horizontal. Numbers are CSS pixels at the emulated viewport. With--baseline(an earliermeasure-*run) each element gains a green label stating its movement and size change — verified with a simulated 8px shift producing位移 +0, +8px · 宽 +4pxon all four rows.Bug fixed along the way
Element matching is now ranked instead of first-hit: an element whose own text is exactly the wanted name beats one whose
aria-labelmerely contains it.技能was matching the composer's选择技能button — a silently wrong measurement in an offset diagram, and a wrong click elsewhere. Every measurement now logs the element it actually hit.Two more fixes this surfaced: composed sheets needed a real CJK font (Pillow's default bitmap font is unreadable beside a 1200px panel and renders Chinese as tofu boxes) and panel downscaling; and the compare panel offsets were computed from a wrong assumption about the title row.
Video quality
Chrome emits screencast frames at the CSS viewport size (it ignores the emulated device scale factor, unlike stills), so a mobile clip was 390×844 while stills were 780×1688. The encode now upscales with Lanczos to the stills' pixel dimensions and uses crf 18 instead of the x264 default. That is interpolation, not extra optical detail, and the docs say so. Verified: the mp4 is 780×1688 h264 and the upscaled text is crisp and legible.
Also
The pointer indicator now defaults to on while recording, off for stills — a product shot should not gain a stray dot because its scenario had to tap something.
--pointer trueor a{"pointer": [x, y]}step asks for it explicitly.Guide gains recipes 5–7; CLAUDE.md lists the new subcommands.
Makefilestill untouched.Verification
node --checkon the driver and every inject script;ast.parseoncapture.py; scenario JSON parses.check-docs.pyclean for the changed docs. No media committed.