Zero WordPress's default root block gap in Studio Code scaffolded themes - #4053
Merged
Conversation
…h the agent about it Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…fore Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
📊 Performance Test ResultsComparing dc2a21d vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
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.
Related issues
How AI was used in this PR
Built with Claude Code: it explored how the agent scaffolds themes and where spacing guidance lives, proposed the options, and implemented the chosen approach. Changes were human-directed and reviewed.
Proposed Changes
When the Studio Code agent builds a site, an unexpected gap often appears between the header and the content, and between the content and the footer. The agent designs those sections as self-contained bands with their own padding, but WordPress inserts
margin-block-start: var(--wp--style--block-gap)between the template's top-level children — with a 24px core default that applies even when the theme never declares a block gap. The agent doesn't model that injected gap, so generated sites render with mystery spacing the design never asked for.This PR makes reality match the agent's mental model instead of asking the agent to compensate:
scaffold_themenow zero that root-level gap instyle.css, so top-level sections butt edge-to-edge and own their vertical rhythm through their padding. Spacing between sections becomes something the agent adds deliberately rather than something core injects silently. The reset is scoped to the template root only — block-gap behavior inside nested layouts (paragraph rhythm, flex gaps) is untouched.block-contentskill now explains the mechanism proactively (it was previously only mentioned in the reactivevisual-polishskill), including how to handle non-scaffolded themes and why zeroingstyles.spacing.blockGapintheme.jsonis the wrong fix (it cascades into every flow layout and collapses content rhythm site-wide).User impact: sites generated by the Studio Code agent should come out with the header/content/footer spacing the design intended, with fewer polish iterations spent diagnosing the injected gap.
The data-liberation agent's existing per-section margin zeroing is intentionally left unchanged — its sections live inside page content where a template-root reset doesn't reach, and its fix is deterministic engine code that keeps patterns theme-agnostic.
Testing Instructions
npm test -- apps/cli/ai/tests/tools.test.ts— includes a new assertion that the scaffoldedstyle.cssships the reset.npm run cli:build), ask the Studio Code agent to create a new site with a custom theme, and inspect the rendered page — the header should sit flush against the first content section and the footer flush against the last, with no ~24px gap. Also worth confirming in the editor view (the reset ridesadd_editor_style) that the front end and editor agree.Pre-merge Checklist
🤖 Generated with Claude Code