mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 16:24:30 +00:00
fix (tui): sanitize binary-heavy history text before render
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Box, Container, Markdown, Spacer, Text } from "@mariozechner/pi-tui";
|
||||
import { formatToolDetail, resolveToolDisplay } from "../../agents/tool-display.js";
|
||||
import { markdownTheme, theme } from "../theme/theme.js";
|
||||
import { sanitizeRenderableText } from "../tui-formatters.js";
|
||||
|
||||
type ToolResultContent = {
|
||||
type?: string;
|
||||
@@ -21,13 +22,13 @@ function formatArgs(toolName: string, args: unknown): string {
|
||||
const display = resolveToolDisplay({ name: toolName, args });
|
||||
const detail = formatToolDetail(display);
|
||||
if (detail) {
|
||||
return detail;
|
||||
return sanitizeRenderableText(detail);
|
||||
}
|
||||
if (!args || typeof args !== "object") {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(args);
|
||||
return sanitizeRenderableText(JSON.stringify(args));
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
@@ -40,7 +41,7 @@ function extractText(result?: ToolResult): string {
|
||||
const lines: string[] = [];
|
||||
for (const entry of result.content) {
|
||||
if (entry.type === "text" && entry.text) {
|
||||
lines.push(entry.text);
|
||||
lines.push(sanitizeRenderableText(entry.text));
|
||||
} else if (entry.type === "image") {
|
||||
const mime = entry.mimeType ?? "image";
|
||||
const size = entry.bytes ? ` ${Math.round(entry.bytes / 1024)}kb` : "";
|
||||
|
||||
Reference in New Issue
Block a user