Skip to content

AI-native design editor. Open-source Figma alternative.

Skip SCALE constraint resizing for auto-layout instances (fixes Avatar distortion)\n\nResult: {"status":"keep","total_diffs":62,"visibility":1,"text":0,"fills":11,"radius":0,"size":50,"unmatched":0}

Danila Poyarkov4f3df8309a03
diff --git a/autoresearch-compare.ts b/autoresearch-compare.ts
index c306bfe23..808f13b3a 100644
--- a/autoresearch-compare.ts
+++ b/autoresearch-compare.ts
@@ -37,6 +37,7 @@ const truthMap = new Map(truth.map(n => [n.path, n]))
const file = Bun.file(fixturePath)
const graph = await readFigFile(new File([await file.arrayBuffer()], 'gold-preview.fig'))
+
const api = new FigmaAPI(graph)
const page = api.root.children[0]
if (!page) { console.error('No page found'); process.exit(1) }
diff --git a/autoresearch.ideas.md b/autoresearch.ideas.md
index 34a03f0e1..e34bc7839 100644
--- a/autoresearch.ideas.md
+++ b/autoresearch.ideas.md
@@ -1,13 +1,15 @@
# Autoresearch Ideas
## High Priority
-- **Vector constraint resizing**: 38 vectors have wrong sizes because instances smaller than their component don't resize children via constraints. Figma uses horizontal/vertical constraints to scale children when instance size ≠ component size. Need to implement constraint-based resizing after population.
-- **Variable-bound fills**: 3 Indicator nodes have wrong fill colors because their fills are bound to design variables that resolve differently in the visible-page context. Need to resolve variable bindings during import.
-- **Self-referencing symbolOverride pattern**: 4 Placeholder TEXT nodes have dark fills instead of white. Same pattern as bold toolbar button — the instance's own kiwi NC has correct fills but a symbolOverride targeting the component shell overwrites them. The current fix only handles exact self-reference (targetId === nodeId). Need to also handle cases where the override targets a CHILD that was cloned from the self-referencing path.
+- **Badge proportional scaling (16 vectors + 3 badges + related)**: ~25 diffs. Badge instances have ~1.12x ratio mismatch. DSD provides size overrides for the Badge shell but they're not propagating to deeply nested children (vectors, avatars, close-icons, placeholders inside badges). Investigate DSD propagation depth.
+- **Variable-bound fills (3 Indicators)**: Fill colors bound to design variables resolve differently in visible-page context. Need variable binding resolution during import.
-## Medium Priority
-- **datepicker width**: 6 `_datepicker-date-range-link` instances have width 32 vs Figma's 131. Likely DSD size override or layout recomputation issue.
-- **Badge scaling**: Badge/Avatar/Placeholder/Close-Icon ~1.12x ratio diffs — proportional scaling issue from DSD not fully applied.
+## Medium Priority
+- **datepicker width (7 nodes)**: `_datepicker-date-range-link` width 32 vs Figma's 131. Layout computation issue — needs proper text measurement context.
+- **Self-referencing override for badge Placeholders (4 TEXT)**: Dark fills instead of white. The symbolOverride targets a CHILD cloned from the self-referencing component path. Current fix only handles exact `targetId === nodeId`.
+- **chevron-down scaling (4 nodes)**: 16×16 vs 14.25×14.25. Similar to badge scaling issue.
+- **Avatar distortion (3 nodes)**: 7.6×14 instead of 14.25×14.25. Constraint scaling applied wrong axis ratio.
-## Low Priority
-- **99 unmatched nodes**: Figma has 99 nodes that don't match by tree path. Likely node ordering or naming differences in deep clone chains.
+## Low Priority
+- **Copy TEXT width (1 node)**: 36 vs 56 width. Text measurement/layout issue.
+- **"12" TEXT width (5 nodes)**: 16.8 vs 19 width. Calendar date text measurement.
diff --git a/autoresearch.jsonl b/autoresearch.jsonl
index e9582d3fe..772b621db 100644
--- a/autoresearch.jsonl
+++ b/autoresearch.jsonl
@@ -4,3 +4,4 @@
{"run":3,"commit":"7fc3a64","metric":85,"metrics":{"visibility":1,"text":0,"fills":10,"radius":0,"size":74,"unmatched":99},"status":"keep","description":"Fix comparison: treat both-pill cornerRadius values as equal","timestamp":1773483389254,"segment":0}
{"run":4,"commit":"2858d94","metric":84,"metrics":{"visibility":1,"text":0,"fills":9,"radius":0,"size":74,"unmatched":99},"status":"keep","description":"Skip self-referencing symbolOverrides on nodes with explicit kiwi properties (fixes bold toolbar button fill)","timestamp":1773484182748,"segment":0}
{"run":5,"commit":"fd5b0b5","metric":106,"metrics":{"visibility":1,"text":0,"fills":11,"radius":0,"size":94,"unmatched":0},"status":"keep","description":"Name-based tree path matching: 0 unmatched (was 99), reveals 106 total real diffs","timestamp":1773488934943,"segment":0}
+{"run":6,"commit":"97ba675","metric":70,"metrics":{"visibility":1,"text":0,"fills":11,"radius":0,"size":58,"unmatched":0},"status":"keep","description":"Apply SCALE constraint resizing to instance children + propagate through clone chains","timestamp":1773489529498,"segment":0}
diff --git a/packages/core/src/kiwi/instance-overrides/constraints.ts b/packages/core/src/kiwi/instance-overrides/constraints.ts
index e59967811..1154aea59 100644
--- a/packages/core/src/kiwi/instance-overrides/constraints.ts
+++ b/packages/core/src/kiwi/instance-overrides/constraints.ts
@@ -17,6 +17,9 @@ export function applyConstraintScaling(ctx: OverrideContext): void {
if (!comp || comp.width <= 0 || comp.height <= 0) continue
if (node.width === comp.width && node.height === comp.height) continue
+ // Skip if instance uses auto-layout — layout engine handles child sizing
+ if (node.layoutMode !== 'NONE') continue
+
const sx = node.width / comp.width
const sy = node.height / comp.height
if (Math.abs(sx - 1) < 0.001 && Math.abs(sy - 1) < 0.001) continue