feat(get_design_context): surface mixed-text segments + WRAP cross-axis spacing, omit no-op defaults#14
Merged
Conversation
…is spacing, omit no-op defaults Three equal-or-better improvements to the hottest read tool, the codegen grounding source of truth. - Mixed-style TEXT now carries `segments`: per-run characters + font + fills (hex) + decoration + case. Previously a node with inline variation read as `fontSize: "mixed"` / `textDecoration: "mixed"` with no way to locate the bold word / underlined link / coloured span, so codegen flattened it to one style. The serializer already computed these (the long-proven get_node path) — full detail just dropped them; now it copies them with paints simplified to hex. - Auto-layout now captures WRAP cross-axis geometry: `counterAxisSpacing` (the gap between wrapped rows) and `counterAxisAlignContent`. A wrapping flex kept its primary itemSpacing but lost the row gap entirely, forcing a guess. - Omit no-op defaults consistently (absent visible = true, rotation = 0, opacity = 1, cornerRadius = 0). Identical generated code, smaller payload; cornerRadius = 0 is the highest-volume of these (every frame/shape carries it). Live-verified F1 (a real Bold/underline/coloured consent-label link recovered exactly) and the no-op omission on real designs; F4 covered by unit tests.
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.
Three equal-or-better improvements to the highest-frequency read tool — the codegen grounding source of truth. Each is strictly faithful-or-smaller; no real design's generated code regresses.
What & why
Mixed-style TEXT now carries
segments— per-runcharacters+fontName+fontSize+fills(hex) +textDecoration+textCase. Previously a node with inline variation read asfontSize: "mixed"/textDecoration: "mixed"with no way to locate the bold word / underlined link / coloured span, so codegen flattened it to a single style (the classic "Terms and Privacy Policy with no underline" miss). The serializer already computed these (the long-provenget_nodepath) — full detail just dropped them; now it copies them with paints simplified to hex like everything else in this view. Zero extra compute at full detail.Auto-layout now captures WRAP cross-axis geometry —
counterAxisSpacing(the gap between wrapped rows) andcounterAxisAlignContent. A wrapping flex (tag cloud / chip group) kept its primaryitemSpacingbut lost the row gap entirely, forcing a guess. Emitted only whenlayoutWrap === 'WRAP'and non-default (Figma reportscounterAxisSpacing: nullunderSPACE_BETWEEN, so it's omitted there).Omit no-op defaults consistently — absent
visible= true,rotation= 0,opacity= 1,cornerRadius= 0. Strict equality (so a 0.99 opacity / 0.0001-rad rotation still surfaces;mixedcorners are a symbol, never 0). Identical generated code, smaller payload;cornerRadius = 0is the highest-volume of these — every frame/shape carries it.A candidate to drop in-flow children's
x/ywas rejected: under WRAP it's currently the only row-gap signal, so it would regress — which is what surfaced the WRAP gap above.Verification
segments; no-op omission confirmed clean across several frames. WRAP is unit-test-only (no wrapping flex existed in the test designs, and the write tools can't synthesize a non-zerocounterAxisSpacing).Files
shared/serialized-node.ts(WRAP schema),shared/design-context.ts(segmentstype + schema),shared/design-context-dedupe.ts(exportsimplifyPaint),plugin/serializer.ts(WRAP emit),plugin/handlers/get-design-context.ts(segments copy + no-op omission), tests, andskills/figma-codegen/references/grounding.md(how to read segments + WRAP row gap).