fix(examples): todo renderResult returns undefined on validation errors

When a todo call fails schema validation, createErrorToolResult produces
details: {} (a truthy empty object), so renderResult skips both the
!details and details.error branches, then switch (details.action) has no
default and returns undefined. ToolExecutionComponent.updateDisplay()
then calls addChild(undefined), and the next Box.render pass crashes the
whole interactive TUI.

Add a default case that renders the validation error text.
This commit is contained in:
yzchen 2026-08-13 12:17:37 +08:00 • committed by Petr Houška
parent c55972086d
commit 3953e9ef49

View file

@ -276,6 +276,13 @@ export default function (pi: ExtensionAPI) {
case "clear":
return new Text(theme.fg("success", "✓ ") + theme.fg("muted", "Cleared all todos"), 0, 0);
default:
return new Text(
result.content[0]?.type === "text" ? theme.fg("error", result.content[0].text) : "",
0,
0,
);
}
},
});