[PR #7335] fix: prevent undefined values in TextNodeRenderable components #12354

Open
opened 2026-02-16 18:17:16 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7335

State: open
Merged: No


Summary

  • Fix fatal crash: TextNodeRenderable only accepts strings, TextNodeRenderable instances, or StyledText instances

Changes

  • Line 1817 (Patch component): Remove optional chaining ?. on props.output since 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 ?? "" for error.data?.message to provide empty string fallback when data is 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 checks props.output !== undefined
  • props.message.error?.data?.message ?? "" - Falls back to empty string
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7335 **State:** open **Merged:** No --- ## Summary - Fix fatal crash: `TextNodeRenderable only accepts strings, TextNodeRenderable instances, or StyledText instances` ## Changes - **Line 1817** (`Patch` component): Remove optional chaining `?.` on `props.output` since 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 `?? ""` for `error.data?.message` to provide empty string fallback when `data` is 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 checks `props.output !== undefined` - `props.message.error?.data?.message ?? ""` - Falls back to empty string
yindo added the pull-request label 2026-02-16 18:17:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12354