mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-24 03:00:28 -05:00
Compare commits
8 Commits
dev
...
fix/ui-for
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78baf1857b | ||
|
|
d08d5dd052 | ||
|
|
1bed2a2916 | ||
|
|
04dc25f110 | ||
|
|
0c0bd2ccb6 | ||
|
|
9a048b9caf | ||
|
|
5a3e33745e | ||
|
|
8ef89ac937 |
@@ -501,27 +501,79 @@ function getFileAccordionData(
|
|||||||
"path",
|
"path",
|
||||||
"pattern",
|
"pattern",
|
||||||
) ?? "File";
|
) ?? "File";
|
||||||
const content = getStringField(output, "content", "text", "_raw");
|
const content = getStringField(
|
||||||
|
output,
|
||||||
|
"content",
|
||||||
|
"text",
|
||||||
|
"preview",
|
||||||
|
"content_preview",
|
||||||
|
"_raw",
|
||||||
|
);
|
||||||
const message = getStringField(output, "message");
|
const message = getStringField(output, "message");
|
||||||
|
|
||||||
|
// Handle base64 content from workspace files
|
||||||
|
let displayContent = content;
|
||||||
|
if (output.content_base64 && typeof output.content_base64 === "string") {
|
||||||
|
try {
|
||||||
|
const bytes = Uint8Array.from(atob(output.content_base64), (c) =>
|
||||||
|
c.charCodeAt(0),
|
||||||
|
);
|
||||||
|
displayContent = new TextDecoder().decode(bytes);
|
||||||
|
} catch {
|
||||||
|
displayContent = "[Binary content]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle MCP-style content blocks from SDK tools (Read, Glob, Grep, Edit)
|
||||||
|
if (!displayContent) {
|
||||||
|
displayContent = extractMcpText(output);
|
||||||
|
}
|
||||||
|
|
||||||
// For Glob/list results, try to show file list
|
// For Glob/list results, try to show file list
|
||||||
const files = Array.isArray(output.files)
|
// Files can be either strings (from Glob) or objects (from list_workspace_files)
|
||||||
? output.files.filter((f: unknown): f is string => typeof f === "string")
|
const files = Array.isArray(output.files) ? output.files : null;
|
||||||
: null;
|
|
||||||
|
// Format file list for display
|
||||||
|
let fileListText: string | null = null;
|
||||||
|
if (files && files.length > 0) {
|
||||||
|
const fileLines = files.map((f: unknown) => {
|
||||||
|
if (typeof f === "string") {
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
if (typeof f === "object" && f !== null) {
|
||||||
|
const fileObj = f as Record<string, unknown>;
|
||||||
|
// Workspace file format: path (size, mime_type)
|
||||||
|
const filePath =
|
||||||
|
typeof fileObj.path === "string"
|
||||||
|
? fileObj.path
|
||||||
|
: typeof fileObj.name === "string"
|
||||||
|
? fileObj.name
|
||||||
|
: "unknown";
|
||||||
|
const mimeType =
|
||||||
|
typeof fileObj.mime_type === "string" ? fileObj.mime_type : "unknown";
|
||||||
|
const size =
|
||||||
|
typeof fileObj.size_bytes === "number"
|
||||||
|
? ` (${(fileObj.size_bytes / 1024).toFixed(1)} KB, ${mimeType})`
|
||||||
|
: "";
|
||||||
|
return `${filePath}${size}`;
|
||||||
|
}
|
||||||
|
return String(f);
|
||||||
|
});
|
||||||
|
fileListText = fileLines.join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: message ?? "File output",
|
title: message ?? "File output",
|
||||||
description: truncate(filePath, 80),
|
description: truncate(filePath, 80),
|
||||||
content: (
|
content: (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{content && (
|
{displayContent && (
|
||||||
<ContentCodeBlock>{truncate(content, 2000)}</ContentCodeBlock>
|
<ContentCodeBlock>{truncate(displayContent, 2000)}</ContentCodeBlock>
|
||||||
)}
|
)}
|
||||||
{files && files.length > 0 && (
|
{fileListText && (
|
||||||
<ContentCodeBlock>
|
<ContentCodeBlock>{truncate(fileListText, 2000)}</ContentCodeBlock>
|
||||||
{truncate(files.join("\n"), 2000)}
|
|
||||||
</ContentCodeBlock>
|
|
||||||
)}
|
)}
|
||||||
{!content && !files && message && (
|
{!displayContent && !fileListText && message && (
|
||||||
<ContentMessage>{message}</ContentMessage>
|
<ContentMessage>{message}</ContentMessage>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user