/** * ToolResultBlock — 工具结果块 */ import { Box, Typography, Stack } from '@mui/material'; import { FileText } from 'lucide-react'; import type { ToolCallInfo } from '@renderer/stores/agent-store'; import { formatDuration } from '@renderer/lib/formatters'; import { toDisplayResult } from '@renderer/lib/tool-result-display'; // v0.7.4 P3-1: 文案出层(字典含注册副作用,须在 t() 使用前 import) import { t } from '@renderer/lib/i18n'; import '@renderer/lib/i18n-strings'; interface ToolResultBlockProps { toolCall: ToolCallInfo; } export function ToolResultBlock({ toolCall }: ToolResultBlockProps): React.JSX.Element { if (toolCall.status !== 'success' || toolCall.result == null) return <>; // 渲染前剥离 dataUrl 等超大 base64 字段,避免 ~6.7MB/张的 dataUrl 进 DOM 导致渲染进程 OOM // store 内原始 result 不变(LLM 看图能力不受影响) const displayResult = toDisplayResult(toolCall.result); const resultStr = typeof displayResult === 'string' ? displayResult : JSON.stringify(displayResult, null, 2); return ( {t('toolResult.title', { name: toolCall.name })} {toolCall.durationMs != null && ( {formatDuration(toolCall.durationMs)} )} {resultStr} ); }