opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Add Array.isArray check before .join()

Open opencode-agent[bot] opened this issue 1 week ago • 0 comments

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():

  1. If answer is falsy or empty, return the fallback text
  2. If answer is not an array, convert it to a string with String(answer)
  3. Otherwise, call .join(", ") as before

This makes the code resilient to data type variations that might occur when loading historical sessions.

Closes #7392

New%20session%20-%202026-01-09T00%3A15%3A38.209Z opencode session  |  github run

opencode-agent[bot] avatar Jan 09 '26 00:01 opencode-agent[bot]