diff --git a/static/src/components/chat/actions/ToolAction.vue b/static/src/components/chat/actions/ToolAction.vue index 55556a5b..e6174549 100644 --- a/static/src/components/chat/actions/ToolAction.vue +++ b/static/src/components/chat/actions/ToolAction.vue @@ -89,6 +89,10 @@ function renderToolResult(): string { .tool-result-meta > div { margin: 4px 0; + /* 参数值中的换行符(如多行 command/content)需要真实渲染, + 否则多行内容会挤成一行仅靠容器宽度被动折行 */ + white-space: pre-wrap; + word-break: break-word; } .tool-result-content { @@ -436,6 +440,16 @@ function renderToolResult(): string { line-height: 1.5; } +/* 记忆搜索匹配片段:单行展示,过长不折行直接省略号截断(hover title 看全文) */ +.search-match-snippet { + font-family: 'Monaco', 'Menlo', 'Consolas', monospace; + font-size: 12px; + line-height: 1.5; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + /* 提取片段 */ .segment-separator { text-align: center; diff --git a/static/src/components/chat/actions/toolRenderers.ts b/static/src/components/chat/actions/toolRenderers.ts index 5dbb4ce0..8786af6a 100644 --- a/static/src/components/chat/actions/toolRenderers.ts +++ b/static/src/components/chat/actions/toolRenderers.ts @@ -1029,11 +1029,14 @@ function renderSearchProjectMemory(result: any, args: any): string { } const snippets = Array.isArray(item.snippets) ? item.snippets : []; if (snippets.length > 0) { - const snippetText = snippets - .map((snippet: any) => `L${snippet.line ?? '?'}: ${snippet.text || ''}`) - .join('\n'); + // 每条匹配片段独立成行渲染(pre 整体渲染时长行不换行会溢出容器), + // 配合 .search-match-snippet 的 nowrap + ellipsis:过长片段直接省略号截断 html += '
${escapeHtml(snippetText)}`;
+ snippets.forEach((snippet: any) => {
+ const lineText = `L${snippet.line ?? '?'}: ${snippet.text || ''}`;
+ const escaped = escapeHtml(lineText);
+ html += `