fix(frontend): terminal output not appearing in v1 (#11769)

This commit is contained in:
Hiep Le 2025-11-18 22:03:28 +07:00 committed by GitHub
parent 492c12693d
commit f5611c2188
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 22 additions and 15 deletions

View File

@ -55,7 +55,7 @@ const mockObservationEvent: ObservationEvent = {
tool_call_id: "call_123",
observation: {
kind: "ExecuteBashObservation",
output: "hello\n",
content: [{ type: "text", text: "hello\n" }],
command: "echo hello",
exit_code: 0,
error: false,

View File

@ -17,7 +17,7 @@ describe("handleEventForUI", () => {
tool_call_id: "call_123",
observation: {
kind: "ExecuteBashObservation",
output: "hello\n",
content: [{ type: "text", text: "hello\n" }],
command: "echo hello",
exit_code: 0,
error: false,

View File

@ -47,17 +47,19 @@ const getExecuteBashObservationContent = (
): string => {
const { observation } = event;
let { output } = observation;
// Extract text content from the observation
const textContent = observation.content
.filter((c) => c.type === "text")
.map((c) => c.text)
.join("\n");
if (!output) {
output = "";
let content = textContent || "";
if (content.length > MAX_CONTENT_LENGTH) {
content = `${content.slice(0, MAX_CONTENT_LENGTH)}...`;
}
if (output.length > MAX_CONTENT_LENGTH) {
output = `${output.slice(0, MAX_CONTENT_LENGTH)}...`;
}
return `Output:\n\`\`\`sh\n${output.trim() || i18n.t("OBSERVATION$COMMAND_NO_OUTPUT")}\n\`\`\``;
return `Output:\n\`\`\`sh\n${content.trim() || i18n.t("OBSERVATION$COMMAND_NO_OUTPUT")}\n\`\`\``;
};
// Tool Observations

View File

@ -178,7 +178,12 @@ export function ConversationWebSocketProvider({
// Handle ExecuteBashObservation events - add output to terminal
if (isExecuteBashObservationEvent(event)) {
appendOutput(event.observation.output);
// Extract text content from the observation content array
const textContent = event.observation.content
.filter((c) => c.type === "text")
.map((c) => c.text)
.join("\n");
appendOutput(textContent);
}
}
} catch (error) {

View File

@ -165,7 +165,7 @@ export const createMockExecuteBashActionEvent = (
* Creates a mock ExecuteBashObservation event for testing terminal output handling
*/
export const createMockExecuteBashObservationEvent = (
output: string = "total 24\ndrwxr-xr-x 5 user staff 160 Jan 10 12:00 .",
content: string = "total 24\ndrwxr-xr-x 5 user staff 160 Jan 10 12:00 .",
command: string = "ls -la",
) => ({
id: "bash-obs-123",
@ -175,7 +175,7 @@ export const createMockExecuteBashObservationEvent = (
tool_call_id: "bash-call-456",
observation: {
kind: "ExecuteBashObservation",
output,
content: [{ type: "text", text: content }],
command,
exit_code: 0,
error: false,

View File

@ -56,9 +56,9 @@ export interface BrowserObservation
export interface ExecuteBashObservation
extends ObservationBase<"ExecuteBashObservation"> {
/**
* The raw output from the tool.
* Content returned from the tool as a list of TextContent/ImageContent objects.
*/
output: string;
content: Array<TextContent | ImageContent>;
/**
* The bash command that was executed. Can be empty string if the observation is from a previous command that hit soft timeout and is not yet finished.
*/