opencode
opencode copied to clipboard
Add Array.isArray check before .join()
Both changes are applied. The fix adds defensive type checking in the format function to handle cases where the answer might be a string instead of an array. This can happen when loading older sessions or if data gets stored in an unexpected format.
Summary of the fix:
The bug occurred because props.metadata.answers?.[i()] could sometimes be a string instead of an array (string[]), causing answer.join(", ") to fail since strings don't have a join method.
The fix adds a type check before calling .join():
- If
answeris falsy or empty, return the fallback text - If
answeris not an array, convert it to a string withString(answer) - Otherwise, call
.join(", ")as before
This makes the code resilient to data type variations that might occur when loading historical sessions.
Closes #7392
opencode session | github run