- 新增 LoadTaskMessages 命令,加载子智能体任务的历史消息 - SubAgentEmitter 通过 MessageBus 实时广播子智能体工具调用 - 前端新增子智能体视图,支持导航进入/退出子智能体会话 - 外部渠道过滤子智能体事件,避免推送到飞书/微信 - ToolCall/ToolResult 新增 subagent_task_id 字段 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import { useEffect, useRef } from 'react'
|
|
import { MessageBubble } from './MessageBubble'
|
|
import type { ChatMessage } from '../../types/protocol'
|
|
import { Sparkles } from 'lucide-react'
|
|
|
|
interface MessageListProps {
|
|
messages: ChatMessage[]
|
|
onNavigateToSubAgent?: (taskId: string, description: string) => void
|
|
}
|
|
|
|
export function MessageList({ messages, onNavigateToSubAgent }: MessageListProps) {
|
|
const bottomRef = useRef<HTMLDivElement>(null)
|
|
const containerRef = useRef<HTMLDivElement>(null)
|
|
|
|
useEffect(() => {
|
|
if (bottomRef.current) {
|
|
bottomRef.current.scrollIntoView({ behavior: 'smooth' })
|
|
}
|
|
}, [messages])
|
|
|
|
if (messages.length === 0) {
|
|
return (
|
|
<div className="flex h-full items-center justify-center">
|
|
<div className="text-center animate-fade-in">
|
|
<div className="mb-6 inline-flex h-20 w-20 items-center justify-center rounded-full bg-gradient-to-br from-[#00f0ff]/20 to-[#3b82f6]/20 shadow-2xl shadow-[#00f0ff]/20">
|
|
<Sparkles className="h-10 w-10 text-[#00f0ff]" />
|
|
</div>
|
|
<h2 className="mb-2 text-2xl font-bold text-white">开始新的对话</h2>
|
|
<p className="text-zinc-500">在下方输入消息开始与 AI 助手聊天</p>
|
|
<div className="mt-8 flex items-center justify-center gap-4 text-sm text-zinc-600">
|
|
<span className="px-3 py-1 rounded-full bg-zinc-800/50 border border-zinc-700">/new 创建话题</span>
|
|
<span className="px-3 py-1 rounded-full bg-zinc-800/50 border border-zinc-700">/list 查看列表</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div
|
|
ref={containerRef}
|
|
className="h-full overflow-y-auto p-6 space-y-6"
|
|
>
|
|
{messages.map((message) => (
|
|
<MessageBubble key={message.id} message={message} onNavigateToSubAgent={onNavigateToSubAgent} />
|
|
))}
|
|
<div ref={bottomRef} />
|
|
</div>
|
|
)
|
|
}
|