feat(ui): display agent name in message header

This commit is contained in:
2025-12-16 10:43:02 +08:00
parent a6c1e792fa
commit e698ec2a64
6 changed files with 72 additions and 6 deletions
+13 -5
View File
@@ -19,6 +19,7 @@ import { motion, AnimatePresence } from 'framer-motion';
import { useState, forwardRef } from 'react';
import { cn } from '../utils/cn';
import { fadeInUp, smoothTransition } from '../utils/animations';
import { getAgentDisplayName } from '../utils/agent';
import { Markdown } from './Markdown';
import { FileMentionText } from './FileMentionTag';
import type { Message, ToolCallInfo, ToolCallStatus, ToolMessagePart } from '../api/types.js';
@@ -137,7 +138,7 @@ export const ChatMessage = forwardRef<HTMLDivElement, ChatMessageProps>(
<div className="flex-1 min-w-0 overflow-hidden">
<div className="flex items-center justify-between mb-1">
<span className="text-sm text-fg-muted">
{isUser ? 'You' : 'AI Assistant'}
{isUser ? 'You' : getAgentDisplayName(message.metadata?.agentName)}
</span>
<button
onClick={handleCopy}
@@ -156,9 +157,11 @@ export const ChatMessage = forwardRef<HTMLDivElement, ChatMessageProps>(
interface StreamingMessageProps {
content: string;
/** 当前 Agent 名称 */
agentName?: string;
}
export function StreamingMessage({ content }: StreamingMessageProps) {
export function StreamingMessage({ content, agentName }: StreamingMessageProps) {
return (
<motion.div
initial={{ opacity: 0, y: 10 }}
@@ -170,7 +173,7 @@ export function StreamingMessage({ content }: StreamingMessageProps) {
<Bot size={18} />
</div>
<div className="flex-1 min-w-0 overflow-hidden">
<div className="text-sm text-fg-muted mb-1">AI Assistant</div>
<div className="text-sm text-fg-muted mb-1">{getAgentDisplayName(agentName)}</div>
<div className="message-content text-fg-secondary">
<Markdown content={content} />
<motion.span
@@ -184,7 +187,12 @@ export function StreamingMessage({ content }: StreamingMessageProps) {
);
}
export function TypingIndicator() {
interface TypingIndicatorProps {
/** 当前 Agent 名称 */
agentName?: string;
}
export function TypingIndicator({ agentName }: TypingIndicatorProps) {
return (
<motion.div
initial={{ opacity: 0, y: 10 }}
@@ -196,7 +204,7 @@ export function TypingIndicator() {
<Bot size={18} />
</div>
<div className="flex-1">
<div className="text-sm text-fg-muted mb-1">AI Assistant</div>
<div className="text-sm text-fg-muted mb-1">{getAgentDisplayName(agentName)}</div>
<div className="flex items-center gap-1 h-6">
{[0, 1, 2].map((i) => (
<motion.span