fix(engine): filter invalid choices before slicing to preserve valid ones

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yuanzonghao
2026-06-24 18:51:23 +08:00
parent 6f8125570a
commit b5f5ebc353
+1 -1
View File
@@ -611,8 +611,8 @@ export async function directInsertBeat(
}
const choices = Array.isArray(parsed.choices)
? parsed.choices
.slice(0, 2)
.filter((c) => c && typeof c.label === "string" && c.label.trim() && typeof c.effect === "string" && c.effect.trim())
.slice(0, 2)
.map((c) => ({ label: c.label.trim(), effect: c.effect.trim() }))
: undefined;
return { beats, choices: choices?.length ? choices : undefined };