fix(cli): prevent crash in AnsiOutputText when handling non-array data (#24498)

This commit is contained in:
Sehoon Shon
2026-04-02 07:48:17 -04:00
committed by GitHub
parent 242afd49a1
commit 44c8b43328
3 changed files with 44 additions and 7 deletions
@@ -158,7 +158,7 @@ export const ToolResultDisplay: React.FC<ToolResultDisplayProps> = ({
terminalWidth={childWidth}
/>
);
} else {
} else if (Array.isArray(contentData)) {
const shouldDisableTruncation =
isAlternateBuffer ||
(availableTerminalHeight === undefined && maxLines === undefined);
@@ -175,6 +175,15 @@ export const ToolResultDisplay: React.FC<ToolResultDisplayProps> = ({
disableTruncation={shouldDisableTruncation}
/>
);
} else if (typeof contentData === 'object' && contentData !== null) {
// Render as JSON for other non-null objects
content = (
<Text wrap="wrap" color={theme.text.primary}>
{JSON.stringify(contentData, null, 2)}
</Text>
);
} else {
content = null;
}
// Final render based on session mode