From 2e295073ae17c4350d0b54078128346d0add6115 Mon Sep 17 00:00:00 2001 From: Hiep Le <69354317+hieptl@users.noreply.github.com> Date: Wed, 26 Nov 2025 18:40:28 +0700 Subject: [PATCH] fix(frontend): fileeditorobservationevent rendering issue (#11820) --- .../get-observation-content.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/v1/chat/event-content-helpers/get-observation-content.ts b/frontend/src/components/v1/chat/event-content-helpers/get-observation-content.ts index e043142e90..c7fe0be374 100644 --- a/frontend/src/components/v1/chat/event-content-helpers/get-observation-content.ts +++ b/frontend/src/components/v1/chat/event-content-helpers/get-observation-content.ts @@ -24,6 +24,15 @@ const getFileEditorObservationContent = ( return `**Error:**\n${observation.error}`; } + // Extract text content from the observation if it exists + const textContent = + "content" in observation && Array.isArray(observation.content) + ? observation.content + .filter((c) => c.type === "text") + .map((c) => c.text) + .join("\n") + : null; + const successMessage = getObservationResult(event) === "success"; // For view commands or successful edits with content changes, format as code block @@ -35,11 +44,13 @@ const getFileEditorObservationContent = ( observation.new_content) || observation.command === "view" ) { - return `\`\`\`\n${observation.output}\n\`\`\``; + // Prefer content over output for view commands, fallback to output if content is not available + const displayContent = textContent || observation.output; + return `\`\`\`\n${displayContent}\n\`\`\``; } - // For other commands, return the output as-is - return observation.output; + // For other commands, prefer content if available, otherwise use output + return textContent || observation.output; }; // Command Observations