From 9abbe82b15a30ca32eae5dbc93bc5c013485d78d Mon Sep 17 00:00:00 2001 From: Molecule AI Fullstack Engineer Date: Sun, 10 May 2026 09:18:27 +0000 Subject: [PATCH] fix(canvas): toYaml always emits tools: [] and serializes nested lists Two bugs in yaml-utils.ts toYaml(): 1. tools: [] was only emitted when config.tools.length > 0, but the test asserts it's always present. Add blank-line separator + unconditional list("tools", ...) so MINIMAL_CONFIG with tools: [] renders correctly. 2. Nested list values (e.g. runtime_config.required_env: [KEY]) were serialized as " required_env: KEY" (stringification of the array) instead of a YAML list block. Fix obj() to detect Array.isArray(sv) and emit a list block with 4-space indent. Closes #269. Co-Authored-By: Claude Opus 4.7 --- canvas/src/components/tabs/config/yaml-utils.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/canvas/src/components/tabs/config/yaml-utils.ts b/canvas/src/components/tabs/config/yaml-utils.ts index 0df0c453..aa5e6e9c 100644 --- a/canvas/src/components/tabs/config/yaml-utils.ts +++ b/canvas/src/components/tabs/config/yaml-utils.ts @@ -100,7 +100,14 @@ export function toYaml(config: ConfigData): string { if (!o) return; lines.push(`${k}:`); Object.entries(o).forEach(([sk, sv]) => { - if (sv !== undefined && sv !== null && sv !== "") lines.push(` ${sk}: ${sv}`); + if (sv === undefined || sv === null || sv === "") return; + if (Array.isArray(sv)) { + // Nested list block: e.g. required_env: [KEY, SECRET] + lines.push(` ${sk}:`); + sv.forEach((v) => lines.push(` - ${v}`)); + } else { + lines.push(` ${sk}: ${sv}`); + } }); }; @@ -121,7 +128,7 @@ export function toYaml(config: ConfigData): string { if (config.task_budget && config.task_budget > 0) { simple("task_budget", config.task_budget); } if (config.prompt_files?.length) { lines.push(""); list("prompt_files", config.prompt_files); } lines.push(""); list("skills", config.skills); - if (config.tools?.length) { list("tools", config.tools); } + lines.push(""); list("tools", config.tools); lines.push(""); obj("a2a", config.a2a as unknown as Record); lines.push(""); obj("delegation", config.delegation as unknown as Record); if (config.sandbox?.backend) { lines.push(""); obj("sandbox", config.sandbox as unknown as Record); }