Skip to content

fix(php-transformer): hoist viewport-partitioned chrome into shared parts - #2243

Merged
chubes4 merged 3 commits into
trunkfrom
fix/hoist-responsive-variant-chrome
Sep 26, 2026
Merged

chubes4 merged 3 commits into
trunkfrom
fix/hoist-responsive-variant-chrome

Conversation

@chubes4

@chubes4 chubes4 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Captures with desktop and mobile document variants shipped no shared header or footer template parts. #2241 stopped the double-rendered chrome by keeping those landmarks page-owned, so every route carried its own copy and templates were only <!-- wp:post-content /-->.

Root cause

ShellExtraction::retainsResponsiveVariantLandmark refused a shared shell whenever another responsive document still contained that landmark. Identical chrome was already removed from every variant, so that path still hoisted. Divergent viewport chrome was not: the clustered copy was extracted, the other variant's landmark remained, and the guard discarded the part. Variant scope classes also live on layout-shell wrappers, which the landmark walk did not read, so the two copies never compared as one viewport partition.

Fix

When the remaining landmarks are a consistent per-viewport set, hoist one header/footer part that wraps each variant in its existing document-variant class (data-liberation-*-document / site-document-variant-*) and strip those landmarks from page content. The template part itself is a div, so only the active variant's landmark is visible. Menu selection state, generated block hashes, and in-page URL fragments are ignored for identity so current-route differences do not split the cluster. A route whose chrome does not match stays on an exclusion template.

Regression test

php tests/contract/shared-shell-plan.php

Fails before:

Fatal error: Uncaught RuntimeException: index.html hoists viewport-partitioned header chrome into the template and leaves no header landmark in page content.
UNFIXED_EXIT:255

Passes after:

shared-shell-plan contract passed
FIXED_EXIT:0

Also passed: wordpress-site-plan, viewport-hidden-document-variants, entry-point-transform-parity, shared-chrome-stylesheet-scope.

Verification

Fresh import with Static Site Importer origin/main @ db49134b packaged against c8d1d2cfd. parts/header.html and parts/footer.html exist. front-page, page, index, and search reference both.

Visible landmarks (1 header / 1 footer at 390, 768, and 1440) and document height versus the loop-3 baseline:

route 390 base / fix 768 base / fix 1440 base / fix
shop 995 / 1025 1664 / 1664 1664 / 1664
services-1 1275 / 1275 1398 / 1398 1398 / 1398
home 4813 / 4813 5847 / 5847 6290 / 6290

Home, shop, services, and blog post_content contain no header or footer landmarks. Mobile menu at 390 still opens (Home, Blog, Shop, Events, Contact).

Residual: cart-page mobile chrome is structurally different, so its header stays page-owned (one visible header, exclusion template). Shop at 390 is 30px taller because a page-background layer starts below the hoisted header and keeps a 900px box. The post route already showed two visible headers and footers in the baseline; heights there are unchanged.

Fixes #1945

AI disclosure: implemented by xAI Grok 4.7 via OpenCode (opencode run), orchestrated and reviewed by Claude (Anthropic).

…arts

When desktop and mobile landmarks match across routes but differ from each
other, keep one template-bound header or footer and hide the inactive
variant with the existing document-variant class instead of leaving both
copies page-owned.
Viewport classes on layout-shell wrappers were invisible to shell identity,
so a matching desktop and mobile pair stayed page-owned. Ignore menu
selection and generated block hashes when comparing that chrome.
… not cover

A trailing shell candidate can sit beside the footer landmark. Strip the
viewport landmarks anyway, and ignore in-page URL fragments when comparing
header identity so the front page joins the shared part.
@chubes4
chubes4 marked this pull request as ready for review September 26, 2026 09:04
@chubes4
chubes4 merged commit 554a7c1 into trunk Sep 26, 2026
10 checks passed
@chubes4
chubes4 deleted the fix/hoist-responsive-variant-chrome branch September 26, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shared chrome stays inline in post_content when a capture has responsive document variants

1 participant