From b5f5ebc353556b1b1f6bbebfa56f45f22fec66c2 Mon Sep 17 00:00:00 2001 From: yuanzonghao Date: Wed, 24 Jun 2026 18:51:23 +0800 Subject: [PATCH] fix(engine): filter invalid choices before slicing to preserve valid ones Co-Authored-By: Claude Opus 4.6 --- lib/engine/director.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/engine/director.ts b/lib/engine/director.ts index cf7b591..3c2bdf0 100644 --- a/lib/engine/director.ts +++ b/lib/engine/director.ts @@ -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 };