Skip to content

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

Fix set_layout padding reset, enforce final describe after fixes

Anton A S417aaedcb315
diff --git a/packages/core/src/iconify.ts b/packages/core/src/iconify.ts
index c495d9c2f..d5d7a1f0b 100644
--- a/packages/core/src/iconify.ts
+++ b/packages/core/src/iconify.ts
@@ -338,8 +338,10 @@ export async function searchIcons(query: string, options?: {
const response = await fetchWithTimeout(`${ICONIFY_API}/search?${params}`)
if (!response.ok) throw new Error(`Iconify search error: ${response.status}`)
const data = await response.json()
+ const icons: string[] = data.icons ?? []
+ const limit = options?.limit ?? 5
return {
- icons: data.icons ?? [],
+ icons: icons.slice(0, limit),
total: data.total ?? 0,
collections: data.collections ?? {}
}
diff --git a/packages/core/src/tools/modify.ts b/packages/core/src/tools/modify.ts
index 325ad2ac8..00a2acfd8 100644
--- a/packages/core/src/tools/modify.ts
+++ b/packages/core/src/tools/modify.ts
@@ -175,20 +175,18 @@ export const setLayout = defineTool({
description: 'Layout direction (keeps current if omitted)',
enum: ['HORIZONTAL', 'VERTICAL']
},
- spacing: { type: 'number', description: 'Gap between items', default: 0, min: 0 },
- padding: { type: 'number', description: 'Equal padding on all sides', min: 0 },
+ spacing: { type: 'number', description: 'Gap between items (only changes if provided)', min: 0 },
+ padding: { type: 'number', description: 'Equal padding on all sides (only changes if provided)', min: 0 },
padding_horizontal: { type: 'number', description: 'Horizontal padding', min: 0 },
padding_vertical: { type: 'number', description: 'Vertical padding', min: 0 },
align: {
type: 'string',
- description: 'Primary axis alignment',
- default: 'MIN',
+ description: 'Primary axis alignment (only changes if provided)',
enum: ['MIN', 'CENTER', 'MAX', 'SPACE_BETWEEN']
},
counter_align: {
type: 'string',
- description: 'Cross axis alignment',
- default: 'MIN',
+ description: 'Cross axis alignment (only changes if provided)',
enum: ['MIN', 'CENTER', 'MAX', 'STRETCH']
}
},
@@ -197,18 +195,26 @@ export const setLayout = defineTool({
if (!node) return { error: `Node "${args.id}" not found` }
if (args.direction) node.layoutMode = args.direction as 'HORIZONTAL' | 'VERTICAL'
- node.itemSpacing = args.spacing ?? 0
- node.primaryAxisAlignItems = args.align ?? 'MIN'
- node.counterAxisAlignItems = args.counter_align ?? 'MIN'
+ if (args.spacing !== undefined) node.itemSpacing = args.spacing
+ if (args.align !== undefined) node.primaryAxisAlignItems = args.align
+ if (args.counter_align !== undefined) node.counterAxisAlignItems = args.counter_align
- const ph = args.padding_horizontal ?? args.padding ?? 0
- const pv = args.padding_vertical ?? args.padding ?? 0
- node.paddingLeft = ph
- node.paddingRight = ph
- node.paddingTop = pv
- node.paddingBottom = pv
+ if (args.padding !== undefined) {
+ node.paddingTop = args.padding
+ node.paddingRight = args.padding
+ node.paddingBottom = args.padding
+ node.paddingLeft = args.padding
+ }
+ if (args.padding_horizontal !== undefined) {
+ node.paddingLeft = args.padding_horizontal
+ node.paddingRight = args.padding_horizontal
+ }
+ if (args.padding_vertical !== undefined) {
+ node.paddingTop = args.padding_vertical
+ node.paddingBottom = args.padding_vertical
+ }
- return { id: args.id, direction: args.direction, spacing: args.spacing ?? 0 }
+ return { id: args.id, spacing: node.itemSpacing }
}
})
diff --git a/src/ai/system-prompt.md b/src/ai/system-prompt.md
index c3e653ba2..4861c227b 100644
--- a/src/ai/system-prompt.md
+++ b/src/ai/system-prompt.md
@@ -92,14 +92,22 @@ No style={{}}, className, CSS. No named colors or rgb(). No percentage values. N
4. `render` into section A
5. `describe` root with `depth=2` — verify
6. `render` into section B
-7. `describe` root with `depth=2` — final check
-8. Fix with `set_*` / `update_node`
+7. `describe` root with `depth=2` — check issues
+8. Fix ALL issues from `describe` with `set_*` / `update_node`
+9. `describe` root with `depth=2` — **MANDATORY final verify after fixes**
-Typically **3 renders + 3 describes**. `describe` the root with `depth=2` — shows sections AND their children in one call. Read the `issues` array — it catches layout bugs automatically.
+Typically **3 renders + 3–4 describes**. `describe` the root with `depth=2` — shows sections AND their children in one call.
+
+⚠ **Issues from `describe` are NOT advisory — they are bugs.** Fix every issue before finishing. Common ones:
+- "gap N not on 8px grid" → fix the gap
+- "grow inside HUG parent" → set parent to fixed size or use h="fill"
+- "nested flex may collapse" → add w="fill" or grow
+- "duplicate sibling names" → rename
+- "near-invisible fill" → increase alpha
🧮 Before filling fixed containers, `calc` total height: children + gaps + padding. Compare to available space from `describe`.
-🚫 Do NOT put everything in one render. Do NOT skip `describe`. Do NOT `describe` individual children when `depth=2` covers them.
+🚫 Do NOT put everything in one render. Do NOT skip `describe`. Do NOT `describe` individual children when `depth=2` covers them. Do NOT skip the final describe after fixes.
🚫 **Never use `export_image`** — slow and wastes tokens. Use `describe` instead.