From 32cb1c9d92baf337769258e878b4fee622255e20 Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Mon, 8 Jun 2026 00:58:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=B8=83=E5=B1=80=20-=20AGENT=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E5=9C=A8=E5=B7=A6=E4=BE=A7=EF=BC=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=A4=B4=E5=83=8F=E5=9C=A8=E5=8F=B3=E4=BE=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/chat/components/ChatBody.tsx | 132 ++++++++------ .../chat/components/messages/MessageItem.tsx | 172 ++++++++++-------- 2 files changed, 171 insertions(+), 133 deletions(-) diff --git a/src/pages/chat/components/ChatBody.tsx b/src/pages/chat/components/ChatBody.tsx index d17c022..dcf9942 100644 --- a/src/pages/chat/components/ChatBody.tsx +++ b/src/pages/chat/components/ChatBody.tsx @@ -70,71 +70,83 @@ export default function ChatBody(props: { {streaming.active && (
- {(() => { - const streamingAgentId = streaming.targetAgentId || currentAgentId; - const streamingAgent = agentList.find(a => a.id === streamingAgentId); - if (streamingAgent) { - return ( -
- - - {streamingAgent.name} - -
- ); - } - return null; - })()} -
-
- {!!streaming.retryInfo?.message && ( -
-
- {streaming.retryInfo.stage === 'fallback_model' ? '自动切换模型' : '自动重试'} - {streaming.retryInfo.stage === 'fallback_model' ? ( - - {String(streaming.retryInfo.fromModel || '')} → {String(streaming.retryInfo.toModel || '')} - - ) : ( - - {String(streaming.retryInfo.model || '')} - {streaming.retryInfo.attempt ? ` · 第${streaming.retryInfo.attempt}次` : ''} - - )} -
-
{String(streaming.retryInfo.message)}
- {!!streaming.retryInfo.reason && ( -
{String(streaming.retryInfo.reason)}
+
+ {(() => { + const streamingAgentId = streaming.targetAgentId || currentAgentId; + const streamingAgent = agentList.find(a => a.id === streamingAgentId); + if (streamingAgent) { + return ( + + ); + } + return null; + })()} +
+ {(() => { + const streamingAgentId = streaming.targetAgentId || currentAgentId; + const streamingAgent = agentList.find(a => a.id === streamingAgentId); + if (streamingAgent) { + return ( +
+ + {streamingAgent.name} + +
+ ); + } + return null; + })()} +
+
+ {!!streaming.retryInfo?.message && ( +
+
+ {streaming.retryInfo.stage === 'fallback_model' ? '自动切换模型' : '自动重试'} + {streaming.retryInfo.stage === 'fallback_model' ? ( + + {String(streaming.retryInfo.fromModel || '')} → {String(streaming.retryInfo.toModel || '')} + + ) : ( + + {String(streaming.retryInfo.model || '')} + {streaming.retryInfo.attempt ? ` · 第${streaming.retryInfo.attempt}次` : ''} + + )} +
+
{String(streaming.retryInfo.message)}
+ {!!streaming.retryInfo.reason && ( +
{String(streaming.retryInfo.reason)}
+ )} +
)} +
+
推理过程
+ {streaming.reasoningText ? {streaming.reasoningText + '▍'} : 等待推理…} +
+ +
+
正式回答
+ {streaming.answerText ? {streaming.answerText + '▍'} : 等待输出…} +
+
+
+ {(streaming.retrieved.length > 0 || streaming.toolCalls.length > 0) && ( +
+ {streaming.retrieved.length > 0 && } + {streaming.toolCalls.length > 0 && }
)} -
-
推理过程
- {streaming.reasoningText ? {streaming.reasoningText + '▍'} : 等待推理…} -
- -
-
正式回答
- {streaming.answerText ? {streaming.answerText + '▍'} : 等待输出…} -
- {(streaming.retrieved.length > 0 || streaming.toolCalls.length > 0) && ( -
- {streaming.retrieved.length > 0 && } - {streaming.toolCalls.length > 0 && } -
- )}
)} diff --git a/src/pages/chat/components/messages/MessageItem.tsx b/src/pages/chat/components/messages/MessageItem.tsx index 0bcffca..22aa24f 100644 --- a/src/pages/chat/components/messages/MessageItem.tsx +++ b/src/pages/chat/components/messages/MessageItem.tsx @@ -43,87 +43,113 @@ export default function MessageItem(props: {
- {hasAnswerAgent && ( -
- - - {answerAgent!.name} - -
- )} -
- {message.role === 'assistant' ? ( - {message.content} - ) : message.content.includes('![image](') ? ( - {message.content} - ) : ( - @$1') - }} /> - )} -
- - {message.role === 'assistant' && ( -
- {hasBranches && ( - - - - {activeIdx + 1} / {total} - - - + {message.role === 'assistant' ? ( +
+ {/* AGENT: 头像在左侧 */} + {hasAnswerAgent && ( + )} - {message.meta?.aborted && 已停止} - onCopy?.(message.content, 'plain') }, - { key: 'markdown', label: '复制 Markdown', onClick: () => onCopy?.(message.content, 'markdown') } - ] - }} - > - - - - - - - - - +
+ {hasAnswerAgent && ( +
+ + {answerAgent!.name} + +
+ )} +
+ {message.content} +
+
+ {hasBranches && ( + + + + {activeIdx + 1} / {total} + + + + )} + {message.meta?.aborted && 已停止} + onCopy?.(message.content, 'plain') }, + { key: 'markdown', label: '复制 Markdown', onClick: () => onCopy?.(message.content, 'markdown') } + ] + }} + > + + + + + + + + + +
+ {message.meta && ( +
+ {!!message.meta.reasoning && } + {!!message.meta.retrieved?.length && } + {!!message.meta.toolCalls?.length && } +
+ )} +
- )} - - {message.role === 'assistant' && message.meta && ( -
- {!!message.meta.reasoning && } - {!!message.meta.retrieved?.length && } - {!!message.meta.toolCalls?.length && } + ) : ( +
+
+
+ + 我 + +
+
+ {message.content.includes('![image](') ? ( + {message.content} + ) : ( + @$1') + }} /> + )} +
+
+ {/* 用户: 头像在右侧 */} +
)}