fix: check for error before early return in extractContentFromMessage

Addresses Codex review feedback - ensures error messages are surfaced
even when content is missing/undefined
This commit is contained in:
Aaron
2026-01-19 10:49:52 +10:00
committed by Peter Steinberger
parent 476087f879
commit 9609a3af40

View File

@@ -44,7 +44,16 @@ export function extractContentFromMessage(message: unknown): string {
const content = record.content;
if (typeof content === "string") return content.trim();
if (!Array.isArray(content)) return "";
// Check for error BEFORE returning empty for non-array content
if (!Array.isArray(content)) {
const stopReason = typeof record.stopReason === "string" ? record.stopReason : "";
if (stopReason === "error") {
const errorMessage = typeof record.errorMessage === "string" ? record.errorMessage : "";
return formatRawAssistantErrorForUi(errorMessage);
}
return "";
}
const parts: string[] = [];
for (const block of content) {