mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix(frontend): fileeditorobservationevent rendering issue (#11820)
This commit is contained in:
parent
5ef45cfec2
commit
2e295073ae
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user