Skip to content

feat(get_design_context): surface mixed-text segments + WRAP cross-axis spacing, omit no-op defaults#14

Merged
awdr74100 merged 1 commit into
mainfrom
feat/get-design-context-fidelity
Jun 27, 2026
Merged

feat(get_design_context): surface mixed-text segments + WRAP cross-axis spacing, omit no-op defaults#14
awdr74100 merged 1 commit into
mainfrom
feat/get-design-context-fidelity

Conversation

@awdr74100

Copy link
Copy Markdown
Owner

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-run characters + fontName + fontSize + fills (hex) + textDecoration + textCase. 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 a single style (the classic "Terms and Privacy Policy with no underline" miss). 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 like everything else in this view. Zero extra compute at full detail.

  • Auto-layout now captures WRAP cross-axis geometrycounterAxisSpacing (the gap between wrapped rows) and counterAxisAlignContent. A wrapping flex (tag cloud / chip group) kept its primary itemSpacing but lost the row gap entirely, forcing a guess. Emitted only when layoutWrap === 'WRAP' and non-default (Figma reports counterAxisSpacing: null under SPACE_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; mixed corners are a symbol, never 0). Identical generated code, smaller payload; cornerRadius = 0 is the highest-volume of these — every frame/shape carries it.

A candidate to drop in-flow children's x/y was rejected: under WRAP it's currently the only row-gap signal, so it would regress — which is what surfaced the WRAP gap above.

Verification

  • Full gate green: typecheck / lint / format:check / knip / build / test (693 tests), incl. new unit tests for all three (segments with hex fills, WRAP spacing across three cases, no-op omission).
  • Live-verified on real designs: a genuine consent-label link (Bold + underline + coloured) recovered exactly via 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-zero counterAxisSpacing).

Files

shared/serialized-node.ts (WRAP schema), shared/design-context.ts (segments type + schema), shared/design-context-dedupe.ts (export simplifyPaint), plugin/serializer.ts (WRAP emit), plugin/handlers/get-design-context.ts (segments copy + no-op omission), tests, and skills/figma-codegen/references/grounding.md (how to read segments + WRAP row gap).

…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.
@awdr74100 awdr74100 merged commit 6691671 into main Jun 27, 2026
2 checks passed
@awdr74100 awdr74100 deleted the feat/get-design-context-fidelity branch June 27, 2026 18:19
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.

1 participant