Repository navigation
perf(docsite): render the landing templates card previews at build time - #11292
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Thanks for splitting this cleanly and keeping it in draft for the decision it needs. Approval waits on an owner decision, not on a code fix.
- Owner decision needed: no current spec record governs the docsite templates card, so moving it from live template renders to committed light and dark screenshots, with a manual
capture:landing-previewsstep after template edits, needs an engineering owner to approve that approach or name the record that should own it. An engineering owner records the decision by commenting/approve-spec <full head SHA>on this pull request; as an engineering owner, the author may do so too.
Two non-blocking suggestions:
- The freshness test hashes only each template's
page.tsx, but four of the seven templates bake/template-assets/photos into their screenshots; hashing those files too (in the test and the capture script), or naming fixture photos in the known gap, would keep a swapped photo from going stale silently. FeaturesShowcase.tsxstill describes the card as live renders that stay in sync with the templates; updating that comment to describe the pre-captured previews and the recapture command would keep it accurate.
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about how the docsite templates card renders, and one fix is needed.
No current spec record governs the landing and community templates card, so replacing its live template renders with pages that every docsite build renders through the CLI's experimental render() and shows in iframes needs an engineering owner to approve that approach or name the record that should own it. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner.
- The generator renders the templates outside the docsite's Webpack icon loader, so a build with
DOCSITE_ICON_SETshows this card in Heroicons while every other template preview uses the chosen set; passing each template throughrewriteTemplatePreviewbefore rendering would fix it (apps/docsite/scripts/generate-landing-template-previews.mjs:133).
Worth a look, but not blocking: the frame pages lose the tile-height normalization the live tiles had, so taller templates may scroll and show a scrollbar on systems with always-visible scrollbars (headless screenshots hide them), and a colour mode picked by hand reaches a frame only after it finishes loading.
Claims and files checked
- Claim: the generator runs in the docsite's generate step. Verified:
apps/docsite/package.json:7. - Claim: each tile's template renders inside the neutral theme with the CLI's experimental page renderer into one self-contained file. Verified:
generate-landing-template-previews.mjs:55-69,:133. - Claim: the script drops the embedded source, sends photos through the image optimizer and links the theme fonts. Verified:
generate-landing-template-previews.mjs:92-105and the new test. - Claim: the card shows each file in a lazy, same-origin sandboxed iframe that is in the server HTML. Verified:
TemplatesPreview.tsx:208-218, statically imported by the landing and community pages. - Claim: CSS scales each frame, with a fixed scale as a fallback. Verified:
TemplatesPreview.tsx:128-138. - Claim: a preview follows the OS scheme, and an Effect plus the load handler apply the site's mode. Verified in the code (
TemplatesPreview.tsx:166-188,:216); not run in a browser here. - Claim: one rows file serves the card and the script. Verified:
landingTemplateRows.json. - Claim: the screenshots, capture script, manifest, freshness test, cache header and live switch are removed. Verified: none is in the net diff.
- Claim: the previews follow template, theme and shared-component changes with no manual step. Verified for those; false for the icon-set build setting (finding above).
- Claim: the docsite build fails when a preview fails to render. Verified:
render()throws, and the script awaits it at the top level. - Claim: the thumbnail and image-optimizer changes are in separate pull requests. Verified: both are open, and this diff touches neither.
- Claims: render time, byte sizes and the timing table. Not reproduced here; they are the author's measurements.
- File
apps/docsite/.gitignore: clear. - File
apps/docsite/package.json: clear. - File
apps/docsite/scripts/generate-landing-template-previews.mjs: icon-set fix needed (line 133); frame-height note (lines 93-104). - File
apps/docsite/src/__tests__/landing-template-previews.test.ts: clear. - File
apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsx: clear. - File
apps/docsite/src/app/(site)/_landing/TemplatesPreview.tsx: colour-mode note (lines 183-188). - File
apps/docsite/src/app/(site)/_landing/landingTemplateRows.json: clear.
The landing "Ready to ship templates" card rendered seven page templates live. Those renders run one after another, cost seconds of main-thread work on slower machines, and load about 8.5 MB of full-size template photos for tiles about 200px wide. The card now shows light and dark WebP screenshots of the same renders, about 110 KB for all seven tiles. The images are in the server HTML and load lazily, so they do not wait for hydration or the render queue. Their file names carry a content hash, and they are served as immutable. `pnpm capture:landing-previews` captures the images from a running docsite through `?template-previews=live`, which renders the live tiles. A test fails when a landing template changes after its capture.
The card showed committed screenshots, which someone had to recapture by hand after a template changed. `pnpm generate` now renders each tile's template to a static page with the CLI's page renderer: markup and styles inside the neutral theme, no script. The card shows each page in a lazy-loaded frame that CSS scales to its tile, and gives the frame the site's color mode. Template photos in a preview load through the image optimizer at preview size. The previews are build output, so they follow every change to a template, the theme, or a component. The screenshots, the capture script, the freshness test, and the `?template-previews=live` switch are gone.
…, and take the color mode from the URL The generator rendered templates outside the Webpack icon loader, so a build with DOCSITE_ICON_SET drew this card with the default icons. With a set named, the generator now renders a copy of each template that the loader's own rewrite has changed. A preview page now fills its frame and never scrolls, as a live tile does, so a tall template shows no scrollbar. The card set the color mode from script after a frame loaded, so a tile showed the OS mode until then. The frame URL now carries `#light` or `#dark`, and the page follows it with `:target` rules. The card no longer reads the frame, so the frame is fully sandboxed and the Effect is gone.
6b81b0f to
6d8bbda
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about how the docsite templates card renders, and two fixes are needed.
No current spec record governs the landing and community templates card, so replacing its live template renders with pages that every docsite build renders through the CLI's experimental render() and shows in sandboxed iframes needs an engineering owner to approve that approach or name the record that should own it. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner.
- Each colour-mode change sets every frame's
src, which adds one browser history entry per loaded frame and reloads it, so after a toggle Back stays on the landing page for up to seven presses, flipping one tile each; remounting the frame when the mode changes (akeythat includes the mode) or navigating it withcontentWindow.location.replace()adds no entry (apps/docsite/src/app/(site)/_landing/TemplatesPreview.tsx:185). - The description still says the frames use
sandbox="allow-same-origin"and an Effect with a load handler for the colour mode, while this head uses a fully sandboxed frame and the URL fragment, so please update it before an owner decides from it.
Not blocking: Miss: generate now needs @astryxdesign/theme-neutral built, but check-workspace-build.mjs checks only Core and says theme CSS is not a generate prerequisite.
Claims and files checked
- Claim: the generator runs in the docsite's generate step. Verified:
apps/docsite/package.json:7. - Claim: each tile's template renders inside the neutral theme with the CLI's experimental page renderer into one self-contained file. Verified:
generate-landing-template-previews.mjs:77-90,:203. - Claim: the script drops the embedded source, sends photos through the image optimizer and links the theme fonts. Verified:
generate-landing-template-previews.mjs:115-130and the new test. - Claim: the card shows each file in a lazy iframe with
sandbox="allow-same-origin". False: the head usessandbox=""(TemplatesPreview.tsx:189). - Claim: the frames are in the server HTML, so they do not wait for hydration. Verified: both pages import the card statically; after hydration each frame's URL changes once to carry the mode.
- Claim: CSS scales each frame, with a fixed scale for a browser without the functions. Verified:
TemplatesPreview.tsx:127-137. - Claim: a preview follows the OS scheme, and an Effect plus the frame's load handler give it the site's mode. First part verified; second part false: the URL fragment does it, with no Effect or handler (
TemplatesPreview.tsx:164). - Claim: one rows file serves the card and the script. Verified:
landingTemplateRows.json. - Claim: the screenshots, capture script, manifest, freshness test, cache header and live switch are removed. Verified: none is in the net diff.
- Claim: the previews follow template, theme and shared-component changes with no manual step. Verified: they are rendered at every build, and the icon-set setting reaches them (
generate-landing-template-previews.mjs:145-175). - Claim: the docsite build fails when a preview fails to render. Verified for render errors, which the script awaits at the top level; render warnings are not checked.
- Claim: the thumbnail and image-optimizer changes are separate pull requests. Verified: this diff touches neither.
- Claims: render time, byte sizes, the timing table, the real-browser checks and the pre-review run. Not reproduced here; they are the author's results.
- File
apps/docsite/.gitignore: clear. - File
apps/docsite/package.json: preflight note (line 7). - File
apps/docsite/scripts/generate-landing-template-previews.mjs: clear apart from the preflight note (its theme imports, lines 78-80). - File
apps/docsite/src/__tests__/landing-template-previews.test.ts: clear. - File
apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsx: clear. - File
apps/docsite/src/app/(site)/_landing/TemplatesPreview.tsx: history-entry fix needed (line 185); the comment at lines 161-163 says a fragment change does not reload, which is false for these frames. - File
apps/docsite/src/app/(site)/_landing/landingTemplateRows.json: clear.
The card changed the URL of each loaded frame to pass the color mode. Each change added a browser history entry, so Back stayed on the landing page, once per tile, after every page load and every toggle. A frame URL now carries a color mode only when a visitor set one that differs from the OS, and the card shows a new frame for it. A new frame adds no history entry. The generate preflight now also requires the neutral theme's built stylesheet and module, which the preview step reads.
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about how the docsite templates card renders, and one fix is needed.
No current spec record governs the landing and community templates card, so replacing its live template renders with pages that every docsite build and dev start renders through the CLI's experimental render(), shown in sandboxed iframes, needs an engineering owner to approve that approach or name the record that should own it. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner.
TemplatesPreview.tsxadds its ownprefers-color-schemelistener anduseSyncExternalStore(lines 151-157 and 171-175) for a concern the shareduseMediaQueryhook in@astryxdesign/core/hooksalready owns, so calluseMediaQuery('(prefers-color-scheme: dark)')and delete the local subscription.
The earlier history-entry, description and preflight findings are fixed at this head.
Claims and files checked
- Claim: the card is decorative and renders seven templates live on the base: verified (base
TemplateThumbnail,inertcontainer). - Claim: a
generatestep renders each tile inside the neutral theme into one self-contained HTML file with the experimental page renderer: verified (generate-landing-template-previews.mjs:77-91,:203). - Claim: the step drops the embedded source, sends template photos through the image optimizer and links the theme fonts: verified (
:115-130, tests). - Claim: with the icon-set setting it renders a rewritten copy, and an unusable set fails with the setting's message: verified (
:145-175,template-icon-loader.mjspreviewIconSets). - Claim: a preview fills its frame and never scrolls: verified from the rules (
:55-58); not run. - Claim: each tile is a lazy, fully sandboxed frame in the server HTML, scaled by CSS with a fixed fallback: verified (
TemplatesPreview.tsx:195-209, static import from the landing page). - Claim: pages follow the OS scheme, a differing site mode mounts a new frame with a fragment, no loaded frame changes URL, and the card needs no Effect: verified (
TemplatesPreview.tsx:168-176,:200-201,templatePreviewColorMode.ts). - Claim: the preflight now requires the neutral theme build: verified (
check-workspace-build.mjs:45-49). - Claim: one rows file serves the card and the script: verified (
landingTemplateRows.json). - Claim: the first commit's screenshots, capture script, manifest, freshness test, cache header and live switch are gone: verified (absent from the net diff).
- Claim: previews follow template, theme and shared-component changes, and the build fails when a preview fails to render: verified (regenerated by every
generate; a render error stops the chain). - Claim: timings, byte counts, history length, request counts and pixel differences: not reproduced (author's measurements).
- Claim: the tests cover the rows, wrapper page, preview document, staging and colour-mode fragment: verified (
landing-template-previews.test.ts). - File
apps/docsite/.gitignore: clear. - File
apps/docsite/package.json: clear. - File
apps/docsite/scripts/check-workspace-build.mjs: clear. - File
apps/docsite/scripts/generate-landing-template-previews.mjs: clear (approach awaits the owner decision). - File
apps/docsite/src/__tests__/landing-template-previews.test.ts: clear. - File
apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsx: clear. - File
apps/docsite/src/app/(site)/_landing/TemplatesPreview.tsx: finding (own colour-scheme listener). - File
apps/docsite/src/app/(site)/_landing/landingTemplateRows.json: clear. - File
apps/docsite/src/app/(site)/_landing/templatePreviewColorMode.ts: clear.
…with useMediaQuery
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about how the docsite templates card renders; no code fix is needed at this head.
No current spec record governs the landing and community templates card, so replacing its live template renders with pages that every docsite build and dev start renders through the CLI's experimental render(), shown in sandboxed lazy iframes that take the colour mode from a #light or #dark fragment, needs an engineering owner to approve that approach or name the record that should own it. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner.
- Non-blocking:
generate-landing-template-previews.mjsdiscards the warningsrender()returns for a degraded page (no Astryx styles, a missing stylesheet, dropped children), so a renderer change could ship unstyled tiles with the build still green; failing on any warning except the expected missing/template-assets/images would catch that.
The earlier colour-scheme listener finding is fixed: the card now reads the OS scheme through Core's useMediaQuery.
Claims and files checked
- Claim: the card is decorative and renders seven templates live on the base: verified (base
TemplatesPreview.tsxinert container withTemplateThumbnailtiles). - Claim: a
generatestep renders each tile inside the neutral theme into one self-contained HTML file with the experimental page renderer: verified (package.json:7,generate-landing-template-previews.mjs:77-91,:203). - Claim: the step drops the embedded source, sends template photos through the image optimizer and links the theme fonts: verified (
generate-landing-template-previews.mjs:115-130, tests). - Claim: seven previews take about 16 s: not reproduced.
- Claim: with the icon-set setting it renders a rewritten copy, and a set that is not installed fails with the setting's message: verified (
generate-landing-template-previews.mjs:145-175,template-icon-loader.mjs:94-96). - Claim: a preview fills its frame and never scrolls: verified from the rules (
generate-landing-template-previews.mjs:55-58); not run. - Claim: each tile is a lazy, fully sandboxed frame in the server HTML, scaled by CSS with a fixed fallback: verified (
TemplatesPreview.tsx:129-139,:183-197; static import from the landing page). - Claim: pages follow the OS scheme, a differing site mode mounts a new frame with a fragment, and no loaded frame changes URL: verified (
TemplatesPreview.tsx:160-164,:188-189,templatePreviewColorMode.ts:16-25). - Claim: the card reads the OS scheme with Core's
useMediaQueryand needs no Effect and no access to the frame: verified (TemplatesPreview.tsx:13,:163). - Claim: the preflight now requires the neutral theme's built stylesheet and module: verified (
check-workspace-build.mjs:45-49). - Claim: one rows file serves the card and the script: verified (
landingTemplateRows.json,TemplatesPreview.tsx:20). - Claim: the first commit's screenshots, capture script, manifest, freshness test, cache header and live switch are gone: verified (absent from the net diff and the head).
- Claim: previews follow template, theme and shared-component changes: verified (regenerated by every
generate; underpnpm devonly at the nextgenerate). - Claim: the docsite build fails when a preview fails to render: verified for a thrown render error; a degraded render reported as warnings does not fail it (non-blocking note).
- Claim: the preview pages carry no script: verified (the renderer's only script is the source block, which is removed).
- Claim: timings, byte counts, history length, request counts and pixel differences: not reproduced (author's measurements).
- Claim: the last commit only replaces the card's own OS listener with
useMediaQuery: verified (its diff touchesTemplatesPreview.tsx,templatePreviewColorMode.tsand the test). - Claim: the thumbnail and image-optimizer changes are in separate pull requests: verified (neither file changes here).
- Claim: the tests cover the rows, wrapper page, preview document, staging with and without an icon set, and the colour-mode fragment: verified (
landing-template-previews.test.ts). - Claim: the pre-review checklist reports 0 findings: not reproduced.
- File
apps/docsite/.gitignore: clear. - File
apps/docsite/package.json: clear. - File
apps/docsite/scripts/check-workspace-build.mjs: clear. - File
apps/docsite/scripts/generate-landing-template-previews.mjs: non-blocking note (render warnings discarded); approach awaits the owner decision. - File
apps/docsite/src/__tests__/landing-template-previews.test.ts: clear. - File
apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsx: clear. - File
apps/docsite/src/app/(site)/_landing/TemplatesPreview.tsx: clear (earlier finding fixed). - File
apps/docsite/src/app/(site)/_landing/landingTemplateRows.json: clear. - File
apps/docsite/src/app/(site)/_landing/templatePreviewColorMode.ts: clear.
| iconSets, | ||
| projectDir: docsiteDir, | ||
| }); | ||
| await render('page.tsx', {cwd: pageDir, out: 'page.html'}); |
There was a problem hiding this comment.
Non-blocking: render() returns a degraded page as warnings rather than an error (no-astryx-styles, a stylesheet missing-asset, dropped-children, page-output), and this call discards them, so after a renderer change a tile can ship unstyled with the build still green. Keeping the result and throwing on any warning except the expected /template-assets/… was not found next to the page ones would surface that at build time.
|
/approve-spec 8ac53b7 |
|
Owner decision on the approach: I'm approving build-rendered previews for the landing and community templates card.
|
|
I'll run a full review to re-check this with your note. |
There was a problem hiding this comment.
Changes requested: an engineering owner has approved the build-rendered approach on this head, and one fix remains.
- Miss:
apps/docsite/scripts/generate-landing-template-previews.mjsfinds template photos with its ownTEMPLATE_IMAGEregex and builds the/_next/imageURL by hand, which duplicatesapps/docsite/scripts/template-image-loader.mjsonmain(optimizeTemplateImages()andtemplateImageUrl(), built on the CLI's shared fixture scanner) and already differs from it on missing files, upper-case extensions, query strings, sub-folders and the quality setting, so please mergemainand route the landing pages through that module with a 640 px width.
The owner decision settles the approach, so no spec question remains. Failing the build on unexpected render() warnings stays the non-blocking follow-up the description names.
Claims and files checked
- Claim: the base card renders seven templates live inside an inert container: verified (base
TemplatesPreview.tsxandTemplateThumbnail.tsx). - Claim: a
generatestep renders each tile inside the neutral theme into one self-contained HTML file with the experimental page renderer: verified (package.json:7,generate-landing-template-previews.mjs:77-91and:203; CI rendered all seven at this head). - Claim: the step drops the source block, loads photos through the image optimizer at 640 px and links the theme fonts: verified (
generate-landing-template-previews.mjs:115-130and the tests). - Claim: seven previews take about 16 s: not reproduced; CI rendered them in about 9 s.
- Claim: seven HTML files of about 800 KB with no script: verified (784 KB in the CI log; the source block is the renderer's only script and is removed).
- Claim: with the icon-set setting a rewritten copy renders, and a set that is not installed fails with the setting's message: verified (
generate-landing-template-previews.mjs:145-176,template-icon-loader.mjspreviewIconSets). - Claim: a preview fills its frame and never scrolls: verified from the rules (
generate-landing-template-previews.mjs:55-64); the measured root height is the author's. - Claim: each tile is a lazy, fully sandboxed frame in the server HTML, scaled by CSS with a fixed fallback: verified (
TemplatesPreview.tsx:120-140and:184-196). - Claim: pages follow the OS scheme, a differing site mode mounts a new frame with a fragment, and no loaded frame changes URL: verified (
TemplatesPreview.tsx:188-189,templatePreviewColorMode.ts). - Claim: the card reads the OS scheme with Core's
useMediaQueryand needs no Effect and no access to the frame: verified (TemplatesPreview.tsx:13and:163). - Claim: the preflight now requires the neutral theme's built stylesheet and module: verified (
check-workspace-build.mjs:45-49). - Claim: one rows file serves the card and the script: verified (
landingTemplateRows.json). - Claim: the first commit's screenshots, capture script, manifest, freshness test, cache header and live switch are removed: verified (absent from the net diff).
- Claim: previews follow template, theme and shared-component changes with nothing to recapture: verified (regenerated by every
generate; underpnpm devonly at the nextgenerate). - Claim: the build fails when the renderer throws but not yet on a warning: verified (
generate-landing-template-previews.mjs:203). - Claim: today the previews return only the expected warnings: not reproduced.
- Claim: timings, request counts, history length, pixel differences and chunk sizes: not reproduced (author's measurements); the referenced photos total about 8.7 MB, in line with the stated 8.5 MB.
- Claim: the thumbnail change and the image optimizer are separate pull requests: verified (neither file changes here); the optimizer change has since landed on
main, which the finding above is about. - Claim: no current spec record governs this card, so an engineering owner decides: verified; that decision is now recorded on this head.
- Claim: the tests cover the rows, wrapper page, preview document, staging and the colour-mode fragment: verified; 21 tests passed in CI.
- Claim: the pre-review checklist reports 0 findings: not reproduced.
- File
apps/docsite/.gitignore: clear. - File
apps/docsite/package.json: clear. - File
apps/docsite/scripts/check-workspace-build.mjs: clear. - File
apps/docsite/scripts/generate-landing-template-previews.mjs: blocking (duplicate optimizer path); non-blocking (render warnings discarded). - File
apps/docsite/src/__tests__/landing-template-previews.test.ts: clear. - File
apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsx: clear. - File
apps/docsite/src/app/(site)/_landing/TemplatesPreview.tsx: clear. - File
apps/docsite/src/app/(site)/_landing/landingTemplateRows.json: clear. - File
apps/docsite/src/app/(site)/_landing/templatePreviewColorMode.ts: clear.
…ding-template-previews
The generate step found template photos in the rendered HTML with its own pattern and built the optimizer URL by hand. That repeated `template-image-loader.mjs`, and the two disagreed on a missing file, an upper-case suffix, a query, and a sub-folder. The step now stages a copy of each template and runs `optimizeTemplateImages` over it, at 640 px, before the render. `templateImageUrl` and `optimizeTemplateImages` take a width for that. The preview files are the same, except that the renderer now writes `&` in the optimizer URLs of `src` attributes.
|
/approve-spec 11c4462 |
There was a problem hiding this comment.
Approved pending CI: the CI re-run on this head has passed the docsite build and its tests, and the docsite browser contracts are still running.
The duplicated template-image path from the last review is fixed: the landing previews now go through the shared optimizeTemplateImages() at 640 px, and an engineering owner has approved the build-rendered approach on this head. Failing the build on unexpected render() warnings stays the non-blocking follow-up the description names.
Claims and files checked
- Claim: the base card renders seven templates live inside an inert container: verified (base
TemplatesPreview.tsxandTemplateThumbnail.tsx). - Claim: a
generatestep stages a copy of each tile's template with the rewrites the Webpack loaders give other template previews: verified (generate-landing-template-previews.mjs:142-176; both loader rules match.tsx, the extension the copy rewrites). - Claim: each photo the docsite serves loads through the image optimizer at 640 px via the shared image module: verified (
generate-landing-template-previews.mjs:158-162,template-image-loader.mjs:36and:54-67); all 14 photos the templates name are served. - Claim: with the icon-set setting the icons come from the named sets, and a set that is not installed fails with the setting's own message: verified (
generate-landing-template-previews.mjs:163-169,template-icon-loader.mjs:95); all seven templates declare icons. - Claim: the step renders inside the neutral theme into one self-contained HTML file, drops the source block and links the theme fonts: verified (
generate-landing-template-previews.mjs:77-91,:114-124and:204). - Claim: seven previews take about 16 s: not reproduced; CI rendered them in about 10 s at this head.
- Claim:
templateImageUrlandoptimizeTemplateImagestake a width so the landing and other previews share one rewrite, and the branch mergesmainfor that module: verified (template-image-loader.mjs, merge ofmainwith no conflict resolution). - Claim: a preview fills its frame and never scrolls: verified from the rules (
generate-landing-template-previews.mjs:57-65); the measured root height is the author's. - Claim: each tile is a lazy, fully sandboxed frame in the server HTML, scaled by CSS with a fixed fallback: verified (
TemplatesPreview.tsx:129-139and:184-196). - Claim: pages follow the OS scheme, a differing site mode mounts a new frame with a fragment, no loaded frame changes URL, and the card reads the OS scheme with Core's
useMediaQuerywith no Effect: verified (TemplatesPreview.tsx:160-164and:188-189,templatePreviewColorMode.ts). - Claim: the preflight now requires the neutral theme's built stylesheet and module: verified (
check-workspace-build.mjs:45-49). - Claim: one rows file serves the card and the script: verified (
landingTemplateRows.json). - Claim: the first commit's screenshots, capture script, manifest, freshness test, cache header and live switch are removed: verified (absent from the net diff).
- Claim: previews follow template, theme and shared-component changes with nothing to recapture: verified (regenerated by every
generate; underpnpm devonly at the nextgenerate). - Claim: the build fails when the renderer throws but not yet on a warning: verified (
generate-landing-template-previews.mjs:204). - Claim: today the previews return only the expected warnings: not reproduced.
- Claim: with the shared image rewrite the seven files are unchanged apart from the renderer version and
&in image URLs: consistent but not compared byte for byte; CI's render at this head gives every file the same size as at the previous revision, and the 14 photos get the same URLs from both rewrites. - Claim: timings, request counts, history length, pixel differences and byte counts: not reproduced (author's measurements).
- Claim: the thumbnail change and the image optimizer are separate pull requests: verified; the optimizer change is on
mainand reached this branch by the merge. - Claim: no current spec record governs this card, so an engineering owner decides: verified; that decision is recorded on this head (the description's draft note is superseded).
- Claim: the tests cover the rows, wrapper page, preview document, staged copy (optimizer width, missing and vector images, icons after the image rewrite) and the colour-mode fragment, and the loader test covers the width: verified (
landing-template-previews.test.ts,template-image-loader.test.ts:70-80). - Claim: the pre-review checklist reports 0 findings: not reproduced.
- File
apps/docsite/.gitignore: clear. - File
apps/docsite/package.json: clear. - File
apps/docsite/scripts/check-workspace-build.mjs: clear. - File
apps/docsite/scripts/generate-landing-template-previews.mjs: non-blocking (render warnings discarded). - File
apps/docsite/scripts/template-image-loader.mjs: clear. - File
apps/docsite/src/__tests__/landing-template-previews.test.ts: clear. - File
apps/docsite/src/__tests__/template-image-loader.test.ts: clear. - File
apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsx: clear. - File
apps/docsite/src/app/(site)/_landing/TemplatesPreview.tsx: clear. - File
apps/docsite/src/app/(site)/_landing/landingTemplateRows.json: clear. - File
apps/docsite/src/app/(site)/_landing/templatePreviewColorMode.ts: clear.
…f frames Main now renders the landing templates card previews at build time with the CLI's page renderer and shows each one in a lazy-loaded frame (#11292). This merge keeps that generate step and renderer and puts each preview's rendered markup into the page instead: same document, no frame, no script. The markup uses the site's own StyleX classes, so the page's stylesheet styles it, and the page's color mode reaches it through CSS variables. - generate-landing-template-previews.mjs writes the markup to src/generated/landingPreviews.ts instead of public HTML files, keeps the live preview's preview-viewport wrapper, and also renders the themes card's Butter store, so one step renders every landing preview. - The preview images load at low priority instead of lazily, so they are in place when the visitor reaches the card, as they were in frames. - The tiles keep the wrappers of the live tiles they replace. - The frame color-mode helper is no longer needed. Co-authored-by: nynexman4464 <[email protected]>
…ames (#11339) * perf(docsite): render decorative homepage previews once at build time The homepage templates card rendered seven live page templates one at a time after each tile entered the viewport, so visitors scrolled past blank tiles. The themes card hydrated the whole Butter store. pnpm generate now renders each decorative preview once with react-dom/static, compiled with the docsite's own StyleX Babel plugins and template image loader, and writes src/generated/previewSnapshots.ts. A server component injects each snapshot; CSS scales it and its Theme wrapper inherits the page's color scheme, so dark mode needs no second render and no preview code ships to the browser. Tiles keep each template's desktop layout at every viewport width. * fix(docsite): keep the search function trace off public/ The CLI doctor's authoring audit, which /api/search traces, reaches the docsite test files. The new snapshot test imported the generation script, whose public folder path made the tracer add all of public/ to the search function (318 MB, over the 150 MB budget). The tested function moves to scripts/lib/preview-snapshot-html.mjs, which reads no files, and the test imports only that module. The trace is 21.0 MB again. * fix(docsite): give the snapshot icon rewrite its set list; reuse the template registry With DOCSITE_ICON_SET set, the preview snapshot step passed the setting as iconSet, but rewriteTemplatePreview reads a list, so pnpm generate threw a TypeError. The snapshot source rewrites now live in scripts/lib/preview-source-transform.mjs, which passes the list the way the Webpack loader does, and rewritten icon imports resolve from the docsite's node_modules. A test covers the setting on. The snapshot sources now take the templates card's components from TEMPLATE_COMPONENTS, and the card's slugs live in one module that TemplatesPreview also reads. The snapshots are byte-identical. Two file headers now point at HomePage.tsx. * fix(docsite): keep the template preview wrappers of the live tiles The frozen template tiles now have the same wrapper elements as the live tiles they replace: the frame is inert, FrozenPreview renders as the scaler itself instead of adding a wrapper, and each snapshot keeps the preview-viewport wrapper between its Theme wrapper and the template. FrozenPreview.module.css gives that wrapper the height rules of the live preview surface. Two differences stay because the scale comes from CSS instead of script: the frame is a size container, and the scale matches the script's within 0.0005. * Merge remote-tracking branch 'origin/main' into perf/docsite-frozen-template-previews # Conflicts: # apps/docsite/src/app/(site)/_landing/ThemesPreview.tsx * refactor(docsite): share the preview viewport rules with the live preview surface FrozenPreview.module.css repeated the .viewport height rules of TemplatePreviewSurface.module.css. That stylesheet now also matches the snapshot's preview-viewport wrapper under a snapshotHost class, which FrozenPreview applies, and the copy is gone. * Merge origin/main: build the landing previews into the page instead of frames Main now renders the landing templates card previews at build time with the CLI's page renderer and shows each one in a lazy-loaded frame (#11292). This merge keeps that generate step and renderer and puts each preview's rendered markup into the page instead: same document, no frame, no script. The markup uses the site's own StyleX classes, so the page's stylesheet styles it, and the page's color mode reaches it through CSS variables. - generate-landing-template-previews.mjs writes the markup to src/generated/landingPreviews.ts instead of public HTML files, keeps the live preview's preview-viewport wrapper, and also renders the themes card's Butter store, so one step renders every landing preview. - The preview images load at low priority instead of lazily, so they are in place when the visitor reaches the card, as they were in frames. - The tiles keep the wrappers of the live tiles they replace. - The frame color-mode helper is no longer needed. Co-authored-by: nynexman4464 <[email protected]> * Merge remote-tracking branch 'origin/main' into perf/docsite-frozen-template-previews * fix(docsite): give the themes card store the template preview rewrites The generate step rendered the themes card's Butter store from the store template itself, so with DOCSITE_ICON_SET set the store kept the template's own icons, unlike every other template preview. The step now stages a copy of the store template with the same image and icon rewrites as each tile, and ThemesStorePreview receives the staged store component. Tests cover the setting set and unset. * fix(docsite): scale the in-page template tiles in browsers without length division The tile scale divided two lengths in calc(), which Firefox before 158 does not support, so it dropped the declaration and showed each tile's page unscaled. The scale uses tan(atan2(100cqw, 1100px)) again, with a fixed scale(0.25) for a browser without it, as main did. The docsite also ignores the frame pages that earlier builds wrote under public/landing/template-previews.
Primary intent
Make the landing page "Ready to ship templates" card appear at once, with nothing to maintain by hand. The card is decorative (
inert, no pointer events), but it renders seven page templates live. This PR shows static pages that the build renders from those same templates.visual-update.mddoes not fit: the intended pixels do not change.maintenance.mddoes not fit: the card's runtime behavior changes.User or maintainer impact
Landing page visitors on slower machines or connections see empty skeleton tiles fill in one by one for many seconds. Measured in headless Chromium on a production build (
next start), median of 3 runs unless stated. Times run from the moment the card scrolls into view; "before" means the previews were complete that long before it.The last row is the cost. The browser loads the seven preview pages during page load, because the card is close to the first screen. The live tiles spent 2.5 to 3 s of main-thread time on the same profile later, while the visitor looked at the card.
Bytes for the card: live tiles download 22 extra chunks (about 158 KB gzip) and 19 template photos (8.5 MB of PNG). The previews are seven HTML files (about 800 KB, 127 KB gzip) with no script, and the same photos at 640 px wide through the image optimizer (about 0.4 MB).
On the 1.6 Mbps profile the previews are complete about 70 s after navigation. The rest of the landing page sets that time: its load event comes at about 108 s.
Nobody has to recapture anything. The previews are build output.
Problem and solution fit
The card is decorative and identical for every visitor, so it does not need React at run time. Every delta maps to that:
scripts/generate-landing-template-previews.mjsruns inpnpm generate. For each tile it stages a copy of the template with the rewrites that the Webpack loaders give every other template preview.optimizeTemplateImagesfromscripts/template-image-loader.mjspoints each photo that the docsite serves at the image optimizer, here at 640 px. WithDOCSITE_ICON_SETset,rewriteTemplatePreviewdraws the icons from the named sets, and a set that is not installed fails the script with the setting's own message.@astryxdesign/cli/api/experimental), which writes one self-contained HTML file: markup and the CSS rules the page uses. It then drops the embedded source block and links the theme's font stylesheet. Seven previews take about 16 s.templateImageUrlandoptimizeTemplateImagestake a width, so the landing previews and the other previews share one image rewrite. The branch mergesmainfor that module.html, body { height: 100%; overflow: hidden }, and the template root takes the frame's height.TemplatesPreviewshows each file in an<iframe loading="lazy" sandbox="">. The frames are in the server HTML, so they do not wait for hydration. CSS scales each frame to its tile:scale(tan(atan2(100cqw, 1100px))), with a fixed scale for a browser without those functions.#lightor#dark, and the page follows it with:targetrules on two hidden anchors. The card never changes the URL of a loaded frame, because that adds one browser history entry per frame. It reads the OS scheme with Core'suseMediaQuery, and needs no Effect and no access to the frame.scripts/check-workspace-build.mjs, the preflight ofpnpm generate, now also requires the neutral theme's built stylesheet and module, which the new step reads.landingTemplateRows.jsonholds the tile rows for the component and the script.?template-previews=liveswitch are removed.Because the previews come from the build, they follow a change to a template, the neutral theme, or a shared component. The committed screenshots did not.
Risk: the page renderer is experimental and can change in a patch release. It ships from this repository, and the docsite build fails when the renderer throws. The build does not fail on a renderer warning for a degraded page. Today the seven previews return no warning except
remote-assetfor the payment form's remote logos.Authority
The live previews came from #3064 so that the card re-themes for dark mode and stays in sync with the templates. This keeps both properties with no manual step. No current spec record governs the docsite templates card, so the approach needs an engineering owner's decision. Draft for that reason.
Change and evidence
Live tiles on
main(left) and build-rendered previews (right), 1440×900, device scale 2. The dark pair uses the site's manual toggle with the OS in light mode.Checked in a real browser on a local production build of this head:
history.lengthstays at 2 after load, hydration, scrolling to the card, and two color mode toggles, and one Back press leaves the page. With the previous commit, which changed the URL of a loaded frame, the same steps took it to 9, 16 and 23, and Back stayed on the page.mainreplaces the card's elements in the same way on that profile, and its live tiles start again. The timings in the table include this, andhistory.lengthstays at 2.sandbox=""the card cannot read a frame's document. Against frames that share the page's origin, 0.3% of the card's pixels differ, in both modes.sandbox=""andsandbox="allow-same-origin"cost the same main-thread time during page load (8.1 and 8.0 s against 8.1 and 8.4 s), so the frame gets no permission.Checked on the previous commit, with frames that share the page's origin so that a script can read them:
scrollHeightequalsclientHeight), and each template root is 791 px high, the frame's height.The timings in the table above come from an earlier commit of this PR, which changed the frame URL after hydration. The default path now does less work.
With the shared image rewrite, the seven preview files are the same as before, except for the renderer's version string and
&in the optimizer URLs, which the renderer now writes intosrcattributes.Preview deployment of this head (
11c44622a7, deploymentdpl_FFAdczooEXwfFHA4gLFrx3NMkFtq), headless Chromium at 1440×900 with the OS in light mode, two runs:sandboxhistory.length/_next/imageat 640 px""image/webp""#darkimage/webpThe deployment's build ran the generate step. Screenshots of the card show light tiles as loaded and dark tiles after the toggle.
On an earlier commit, the first request to a fresh deployment was slow, and the page replaced the card's elements once while it loaded, as on the throttled profile above: each frame's HTML was requested twice, and 12 photo requests were cancelled and repeated.
history.lengthstayed at 2.Scope
Components: docsite landing TemplatesPreview, docsite generate scripts
TemplateThumbnailchanges are perf(docsite): render template thumbnails without the Suspense reveal delay, and download them ahead of the scroll #11291, and the image optimizer for template previews is perf(docsite): serve template preview images through the image optimizer #11320.Testing
landing-template-previews.test.tscovers the tile rows, the wrapper page, the preview document (source block, fonts, frame-filling rules, color mode rules and anchors), the staged copy (photos through the optimizer at an allowed width, a missing file and a vector image left as written, icons after the image rewrite), and when a frame URL carries a color mode.template-image-loader.test.tscovers the width parameter.pnpm review:prereports 0 findings.Not tested: Safari and Firefox, and a build with a real icon set installed (none is installed in the docsite).