diff --git a/src/components/trace/hat-script-graph.ts b/src/components/trace/hat-script-graph.ts index ab10f0360b..cecb0feb28 100644 --- a/src/components/trace/hat-script-graph.ts +++ b/src/components/trace/hat-script-graph.ts @@ -143,7 +143,7 @@ class HatScriptGraph extends LitElement { const trace = this.trace.trace[path] as ChooseActionTraceStep[] | undefined; const trace_path = trace?.[0].result ? trace[0].result.choice === "default" - ? [config.choose?.length || 0] + ? [Array.isArray(config.choose) ? config.choose.length : 0] : [trace[0].result.choice] : []; return html` @@ -167,31 +167,33 @@ class HatScriptGraph extends LitElement { nofocus > - ${config.choose?.map((branch, i) => { - const branch_path = `${path}/choose/${i}`; - const track_this = - trace !== undefined && trace[0].result?.choice === i; - if (track_this) { - this.trackedNodes[branch_path] = { config, path: branch_path }; - } - return html` - - - ${ensureArray(branch.sequence).map((action, j) => - this.render_node(action, `${branch_path}/sequence/${j}`) - )} - - `; - })} + ${config.choose + ? ensureArray(config.choose)?.map((branch, i) => { + const branch_path = `${path}/choose/${i}`; + const track_this = + trace !== undefined && trace[0].result?.choice === i; + if (track_this) { + this.trackedNodes[branch_path] = { config, path: branch_path }; + } + return html` + + + ${ensureArray(branch.sequence).map((action, j) => + this.render_node(action, `${branch_path}/sequence/${j}`) + )} + + `; + }) + : ""} html`