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:
@@ -611,8 +611,8 @@ export async function directInsertBeat(
|
|||||||
}
|
}
|
||||||
const choices = Array.isArray(parsed.choices)
|
const choices = Array.isArray(parsed.choices)
|
||||||
? parsed.choices
|
? parsed.choices
|
||||||
.slice(0, 2)
|
|
||||||
.filter((c) => c && typeof c.label === "string" && c.label.trim() && typeof c.effect === "string" && c.effect.trim())
|
.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() }))
|
.map((c) => ({ label: c.label.trim(), effect: c.effect.trim() }))
|
||||||
: undefined;
|
: undefined;
|
||||||
return { beats, choices: choices?.length ? choices : undefined };
|
return { beats, choices: choices?.length ? choices : undefined };
|
||||||
|
|||||||
Reference in New Issue
Block a user