Repository navigation
fix(cli): snapshot warns when self-closed audio or video clips have swallowed the page - #6915
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
There was a problem hiding this comment.
Verdict: REQUEST CHANGES · 2 blocker · 1 important · 0 nits
The root cause is right, but lint on main already catches it. self_closing_media_tag (media.ts:656-674, docs lint-rules.mdx:688, tests media.test.ts:1525) is an error on every self-closed <audio>/<video>. I ran your 20-clip report shape at this head and got self_closing_media_tag ×20 plus media_element_holds_elements ×1. So the blank stills were never a lint gap, and the tests on the fails without the fix: line only fail because they filter on the new code. ↓ inline
- important:
Commentsfails (not a required check). The checker's line scanner already loses template-literal state above line 1152 onmain, so the old 13-line carve docblock atmedia.ts:1211is hidden there. Your new lines bring it back into view, and the checker charges it to this PR as +9 comment lines and a new 12+ line block. This PR only adds a one-line comment. Please note this in the PR body.
Scope
Read the full diff, parseHtmlStructure (utils.ts), the existing self_closing_media_tag and audio_group_holds_elements, and scripts/comment-ratchet.mjs / check-comment-citations.mjs. The media.test.ts suite passes (149 tests). With the registration commented out, the 2 named tests fail. Probes: a self-closed clip as the last child is quiet, a chain is reported once, and a clip inside a <template> is flagged.
|
|
||
| // audio_group_holds_elements | ||
| findAudioGroupHoldsElementsFindings, | ||
| findMediaHoldsElementsFindings, |
There was a problem hiding this comment.
blocker: This duplicates self_closing_media_tag (line 656), which is already an error on every self-closed <audio>/<video>. A self-closed clip now gets two errors for one mistake. The PR body says lint had "nothing for the media elements", but that rule already covers them. If the extra context is useful (how many elements were swallowed, a chain reported once), add it to the existing rule's message rather than adding a second code. The blank-stills report is better handled where the user was: snapshot/render could fail fast or warn when lint errors exist (the PR's "Not done" item).
There was a problem hiding this comment.
✅ Fixed in 6a35790: the duplicate rule is gone.
| const first = readAttr(held[0]!.raw, "id"); | ||
| findings.push({ | ||
| code: "media_element_holds_elements", | ||
| severity: "error", |
There was a problem hiding this comment.
blocker: For a properly closed media element, held is legitimate fallback content. For example, <video id="v" src="v.mp4" ...><p>Your browser does not support video.</p></video> (probed at this head) gets this error, so check fails. The message also says "everything after a self-closed clip disappears", which is false here. This is the only case the new rule adds beyond self_closing_media_tag. Either drop the rule or limit it to the swallowed-siblings shape (for example, when closeIndex is the parent's implied close).
There was a problem hiding this comment.
✅ Fixed in 6a35790: the duplicate rule is gone.
Edit accuracy: accurate 271 (base branch 271), smooth 100 of thoseThe gate passes. Quarantined, measured but not gated (0) |
…wallowed the page
6e0eba6 to
6a35790
Compare
|
You are right, and I missed self_closing_media_tag (media.ts:656): I searched lint for 'self-clos', found only the audio-group rule, and wrote a duplicate. Replaced at 6a35790: the lint rule, its docs entry and tests are gone (so the false positive on fallback content and the Comments failure go with them); snapshot now runs the existing lint on the entry file and warns with the count and ids when self_closing_media_tag fires, which is where the report came from. Test red at main, 98 green x3, and a real snapshot of a 21-clip project prints the warning. |
There was a problem hiding this comment.
Verdict: APPROVE · 3 resolved, 0 open, 0 new · 6e0eba6 → 6a35790
Scope
The duplicate lint rule and its docs entry are gone, and media.ts is untouched; Comments is green. snapshot now repeats the existing self_closing_media_tag finding as a warning. @hyperframes/lint is already a CLI dependency, used the same way by studioServer.ts:580. The 2 new tests pass here, and snapshot.ts has no type errors. Optional follow-up: run() already gets lintProject(project.dir), which covers sub-compositions too. Reusing that result would close the PR's "only index.html" gap and save a second lint pass, but diff calls captureSnapshots without it, so that's a design choice, not a blocker. CI was still running when I reviewed.
What
snapshotprints a warning (and adds it to the result'swarnings) when the project'sindex.htmlhas self-closed<audio>or<video>tags, naming how many and the first few ids:index.html has 21 self-closed <audio>/<video> tags (#a1, #a2, #a3): HTML leaves them open, so everything after the first one is hidden and stills come out blank. Write <audio ...></audio>.Why
snapshotgave fully blank stills on projects with many root<audio>clips (about 20 sound effects). HTML does not close a non-void element with/>, so each self-closed clip stays open and takes in everything after it, including the visible scenes; elements inside a media element never paint. Reproduced on the Linux devbox: 20 self-closed<audio ... />clips followed by a headline gave a background-only PNG at every time, the same project with closing tags rendered the headline.An earlier version of this PR added a second lint rule for it. That was my miss: lint already reports
self_closing_media_tagas an error on every self-closed audio/video (media.ts:656), the reporter simply never ran lint, becausesnapshotnever reads it. This version drops the duplicate rule and the docs entry, and surfaces the existing finding where the report came from.How
selfClosedMediaWarning(source)insnapshot.tsrunslintHyperframeHtmlon the entry file and keeps theself_closing_media_tagfindings;captureSnapshotsprints and records the result before capturing. No new lint code and no change to the lint package.Not done: only
index.htmlis read, not sub-composition files;renderdoes not warn.Test plan
fails without the fix:
snapshot.selfClosedMedia.test.ts"names the self-closed clips and what they do to the still" (and its closed-tag counterpart:selfClosedMediaWarning is not a functionat main).snapshot.test.ts: 98 passed, 3 runs in a row (devbox); both new tests fail withsnapshot.tsat main.snapshotof a 21-clip self-closed project prints the warning before the first frame (devbox).snapshot.ts.Commentscheck failure on the earlier version came from the lint file's line scanner re-exposing an older docblock; this version does not touchmedia.ts.Size
About 55 changed lines: one helper, one call and one test file.