diff --git a/src/pages/TaskAssistant.tsx b/src/pages/TaskAssistant.tsx index 3de904f..5b0ee48 100644 --- a/src/pages/TaskAssistant.tsx +++ b/src/pages/TaskAssistant.tsx @@ -1,8 +1,8 @@ import { useState, useRef, useEffect, useCallback } from 'react' -import { Input, Button, Avatar, theme, Typography, App, Collapse } from 'antd' +import { Input, Button, Avatar, theme, Typography, App } from 'antd' import { SendOutlined, RobotOutlined, UserOutlined, PlusOutlined, - DeleteOutlined, StopOutlined, MessageOutlined, BulbOutlined, ToolOutlined, LoadingOutlined, + DeleteOutlined, StopOutlined, MessageOutlined, } from '@ant-design/icons' import { streamChat, type StreamEvent } from '@/services/ai-chat' import { @@ -18,8 +18,6 @@ interface Message { role: 'user' | 'assistant' content: string timestamp: number - thinking?: string - toolCalls?: { name: string; result?: string }[] streaming?: boolean } @@ -103,8 +101,6 @@ function ChatPage() { setMessages(prev => [...prev, streamMsg]) let currentContent = '' - let currentThinking = '' - const currentTools: { name: string; result?: string }[] = [] let completedConvId: string | undefined const update = (updates: Partial) => @@ -118,25 +114,12 @@ function ChatPage() { switch (event.event) { case 'meta': completedConvId = event.conversationId - if (event.conversationId && event.conversationId !== activeId) { - setActiveId(event.conversationId); loadConversations() - } + if (event.conversationId && event.conversationId !== activeId) { setActiveId(event.conversationId); loadConversations() } break case 'message.delta': currentContent += event.delta || '' update({ content: currentContent, streaming: true }) break - case 'reasoning.available': - currentThinking = event.text || '' - update({ thinking: currentThinking }) - break - case 'tool.start': - currentTools.push({ name: event.toolName || 'unknown' }) - update({ toolCalls: [...currentTools] }) - break - case 'tool.result': - if (currentTools.length > 0) { currentTools[currentTools.length - 1].result = event.output || ''; update({ toolCalls: [...currentTools] }) } - break case 'run.completed': if (event.output) currentContent = event.output update({ content: currentContent, streaming: false }) @@ -164,7 +147,6 @@ function ChatPage() { return (
- {/* Sidebar */}
@@ -190,14 +172,13 @@ function ChatPage() {
- {/* Chat */}
{messages.length === 0 && (
{activeId ? '开始新对话' : '点击「新对话」开始'} - Hermes Agent · 流式响应 · 思考过程可见 + Hermes Agent · 流式响应 · xhigh 推理
)} @@ -206,31 +187,11 @@ function ChatPage() { : } style={{ backgroundColor: msg.role === 'user' ? token.colorPrimary : token.colorSuccess, flexShrink: 0 }} />
- {/* Thinking — auto expand during streaming */} - {msg.thinking && msg.thinking !== msg.content && ( - 思考过程{msg.streaming ? : null}, - children:
{msg.thinking}
, - }]} style={{ marginBottom: 8, background: 'transparent' }} /> - )} - {/* Tools */} - {msg.toolCalls && msg.toolCalls.length > 0 && ( - 工具调用 ({msg.toolCalls.length}), - children: msg.toolCalls.map((t, i) => ( -
- {t.name} - {t.result &&
{t.result}
} -
- )), - }]} style={{ marginBottom: 8, background: 'transparent' }} /> - )} - {/* Content */}
{msg.role === 'assistant' ? (msg.content ? - : 思考中...) + : 思考中...) : msg.content}
@@ -239,23 +200,15 @@ function ChatPage() {
- {/* Input */}
- setInput(e.target.value)} + setInput(e.target.value)} onCompositionStart={() => { composingRef.current = true }} onCompositionEnd={() => { composingRef.current = false }} - onKeyDown={e => { - if (composingRef.current) return - if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSend() } - }} - placeholder={activeId ? '输入消息,Enter 发送,Shift+Enter 换行' : '请先新建或选择对话'} - autoSize={{ minRows: 1, maxRows: 5 }} - disabled={streaming || !activeId} - variant="borderless" - style={{ flex: 1, resize: 'none', padding: '4px 0', fontSize: 14 }} - /> + onKeyDown={e => { if (composingRef.current) return; if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSend() } }} + placeholder={activeId ? '输入消息,Enter 发送' : '请先新建或选择对话'} + autoSize={{ minRows: 1, maxRows: 5 }} disabled={streaming || !activeId} + variant="borderless" style={{ flex: 1, resize: 'none', padding: '4px 0', fontSize: 14 }} /> {streaming ? ( ) : (