opencode
opencode copied to clipboard
fix: prevent undefined values in TextNodeRenderable components
Summary
- Fix fatal crash:
TextNodeRenderable only accepts strings, TextNodeRenderable instances, or StyledText instances
Changes
-
Line 1817 (
Patchcomponent): Remove optional chaining?.onprops.outputsince the<Match when={props.output !== undefined}>guard already ensures it's defined. Use non-null assertion!instead. -
Line 1232 (error message display): Add nullish coalescing
?? ""forerror.data?.messageto provide empty string fallback whendatais undefined.
Root Cause
The <text> component from @opentui/core only accepts strings, TextNodeRenderable instances, or StyledText instances. Optional chaining (?.) can return undefined even inside guarded blocks, causing the runtime error.
Testing
The fix ensures all <text> children are guaranteed to be strings:
-
props.output!.trim()- Safe because Match guard checksprops.output !== undefined -
props.message.error?.data?.message ?? ""- Falls back to empty string