Skip to content

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

Narrow kiwiPropertyNodes: only flag nodes whose fills/radius/visible DIFFER from component source\n\nResult: {"status":"keep","total_diffs":62,"visibility":1,"text":0,"fills":11,"radius":0,"size":50,"unmatched":0}

Danila Poyarkovd513312b54f0
diff --git a/autoresearch.jsonl b/autoresearch.jsonl
index a51eb2ad5..622f3c79e 100644
--- a/autoresearch.jsonl
+++ b/autoresearch.jsonl
@@ -8,3 +8,4 @@
{"run":7,"commit":"4f3df83","metric":62,"metrics":{"visibility":1,"text":0,"fills":11,"radius":0,"size":50,"unmatched":0},"status":"keep","description":"Skip SCALE constraint resizing for auto-layout instances (fixes Avatar distortion)","timestamp":1773490511259,"segment":0}
{"run":8,"commit":"919e4cf","metric":62,"metrics":{"visibility":1,"text":0,"fills":11,"radius":0,"size":50,"unmatched":0},"status":"discard","description":"Analysis only: remaining 11 fills are all library variable aliases, 50 sizes are layout-dependent","timestamp":1773491467403,"segment":0}
{"run":9,"commit":"4f3df83","metric":62,"metrics":{"visibility":1,"text":0,"fills":11,"radius":0,"size":50,"unmatched":0},"status":"discard","description":"Reverted kiwiPropertyNodes/extraSeeds experiments — too complex, caused regressions","timestamp":1773493300107,"segment":0}
+{"run":10,"commit":"b6a1d91","metric":62,"metrics":{"visibility":1,"text":0,"fills":11,"radius":0,"size":50,"unmatched":0},"status":"discard","description":"Reverted reapplyKiwiProperties — can't distinguish sync-overwritten from symbolOverride-set fills","timestamp":1773493747060,"segment":0}
diff --git a/packages/core/src/kiwi/instance-overrides/index.ts b/packages/core/src/kiwi/instance-overrides/index.ts
index ab3110bf3..b58ab15f2 100644
--- a/packages/core/src/kiwi/instance-overrides/index.ts
+++ b/packages/core/src/kiwi/instance-overrides/index.ts
@@ -21,6 +21,32 @@ import { applyComponentProperties } from './props'
import { applyDerivedSymbolData } from './dsd'
import { applyConstraintScaling } from './constraints'
+/**
+ * Identify nodes whose kiwi NC has explicit property values that DIFFER
+ * from their component source. Only these need protection from sync.
+ */
+function buildKiwiPropertyNodes(
+ graph: SceneGraph,
+ changeMap: Map<string, InstanceNodeChange>,
+ guidToNodeId: Map<string, string>
+): Set<string> {
+ const result = new Set<string>()
+ for (const [figmaId, nodeId] of guidToNodeId) {
+ const nc = changeMap.get(figmaId) as Record<string, unknown> | undefined
+ if (!nc) continue
+ const node = graph.getNode(nodeId)
+ if (!node?.componentId) continue
+ const comp = graph.getNode(node.componentId)
+ if (!comp) continue
+ const hasDiffFills = nc.fillPaints !== undefined && node.fills !== comp.fills
+ const hasDiffRadius = (nc.cornerRadius !== undefined || nc.rectangleCornerRadiiIndependent !== undefined) &&
+ node.cornerRadius !== comp.cornerRadius
+ const hasDiffVisible = nc.visible === false && comp.visible
+ if (hasDiffFills || hasDiffRadius || hasDiffVisible) result.add(nodeId)
+ }
+ return result
+}
+
function buildOverrideContext(
graph: SceneGraph,
changeMap: Map<string, InstanceNodeChange>,
@@ -47,17 +73,7 @@ function buildOverrideContext(
nodeIdToGuid.set(nodeId, figmaId)
}
- // Identify nodes whose kiwi NC has explicit property values that should
- // not be overwritten by transitive sync from their component source.
- const kiwiPropertyNodes = new Set<string>()
- for (const [figmaId, nodeId] of guidToNodeId) {
- const nc = changeMap.get(figmaId) as Record<string, unknown> | undefined
- if (!nc) continue
- if (nc.fillPaints !== undefined || nc.cornerRadius !== undefined ||
- nc.rectangleCornerRadiiIndependent !== undefined || nc.visible === false) {
- kiwiPropertyNodes.add(nodeId)
- }
- }
+ const kiwiPropertyNodes = buildKiwiPropertyNodes(graph, changeMap, guidToNodeId)
return {
graph,