Phase 5 item #6: screenshot_responsive renders per breakpoint#13
Merged
Conversation
Before: HTML rendered once at `max(breakpoints).{width,height}`; puppeteer
just retargeted its viewport for each shot. The viewport change alone
already let @media rules fire (the responsive: "stack" verification from
PR #6 worked) but the body scaffold stayed sized for the largest
breakpoint — body.max-width = 1440 and body.min-height = 1024 on every
shot, even the 390-wide mobile one.
`takeResponsiveScreenshots` now takes a per-breakpoint render callback
instead of a single pre-built HTML string. The handler in src/index.ts
passes a closure that calls `renderToHtml(resolved, bp.width, bp.height, canvas)`
per shot, so the body scaffold matches the viewport for every breakpoint.
The viewer side of item #6 was already true reflow — on breakpoint
toggle, JS sets the iframe src to `/canvas/:id/html?w=...&h=...` and the
server route at viewer.ts:75-88 re-renders. This PR brings the
screenshot side up to the same standard.
`test-responsive-reflow.ts` asserts at each preset breakpoint that the
runtime body box (max-width, min-height, width) matches the viewport and
that the `responsive: "stack"` rule fires when expected — 12/12 pass.
The other five smokes still pass — no regression on PRs #6-12.
Found in passing: at exactly 768px the `responsive: "stack"` rule fires
because the `@media` is `max-width: 768px`. Matches Bootstrap/Tailwind
convention (768 is the start of the desktop band, not the end of mobile)
but the labelled tablet preset of 768 lands in the mobile rule. Worth a
separate PR if we want 768 to be desktop-side; out of scope here.
This was referenced May 16, 2026
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.
Summary
The viewer side of item #6 was already true reflow: on breakpoint toggle, JS sets the iframe src to
/canvas/:id/html?w=...&h=...and the server route atviewer.ts:75-88re-renders the HTML with the new dimensions.screenshot_responsivewas the half still doing the iframe-resize equivalent: HTML was rendered once at the largest breakpoint and puppeteer just retargeted its viewport per shot. The viewport change alone let@mediarules fire (PR #6's responsive: "stack" worked end-to-end), but the body scaffold stayed sized for the largest breakpoint —body.max-width = 1440andbody.min-height = 1024even on the 390-wide mobile shot.This change makes
screenshot_responsiverender per breakpoint so the scaffold matches each viewport.What lands
src/screenshot.ts—takeResponsiveScreenshotsnow takes(bp) => stringinstead of a pre-builthtml: string. The function renders inside the loop, so the body scaffold matches the viewport.src/index.ts— the handler passes(bp) => renderToHtml(resolved, bp.width, bp.height, canvas)instead of computingmax(breakpoints)and rendering once.test-responsive-reflow.ts— exercises the same closure shape the handler uses. For each preset breakpoint (mobile/tablet/desktop) assertsbody.max-width,body.min-height, runtimebody.width, and therowflex direction (column whenresponsive: "stack"fires, row otherwise). 12/12 pass.VISION.md— item Phase 5: responsive hint API + renderer mapping (items #1+#2) #6 ticked.Found in passing (separable, not fixing here)
At exactly 768px the
responsive: "stack"rule fires because the rule is@media (max-width: 768px)—max-widthis inclusive in CSS. That matches Bootstrap/Tailwind convention (768 is the start of the desktop band, so anything ≤ 767 is mobile, ≤ 1023 is tablet, etc.), but the labelledtabletpreset at exactly 768 lands in the mobile rule. If we want 768 to be desktop-side, change the renderer'sMOBILE_BREAKPOINTto 767 — but that has knock-on effects worth their own PR.Test plan
npm run buildcleannpx tsx test-responsive-reflow.ts→ 12/12 passtest-fluid-widths,test-default-font,test-root-centering,test-ops-parser,test-guidelinesall still pass — no regression on PRs Phase 5: responsive hint API + renderer mapping (items #1+#2) #6-12