import { EDITOR_AGENT_ERROR_MESSAGE_PREFIX, type EditorAgentMessage, } from '@/packages/shared/src/contracts'; import AttachmentChip from '@/src/components/image-editor/EditorAgentConversation/AttachmentChip.tsx'; import { attachmentKey } from '@/src/components/image-editor/EditorAgentConversation/common.ts'; import { PendingToolCall } from '@/src/components/image-editor/EditorAgentConversation/PendingToolCall.tsx'; import ToolCallView from '@/src/components/image-editor/EditorAgentConversation/ToolCallView.tsx'; function messageRoleLabel(role: EditorAgentMessage['role']) { if (role === 'user') { return '你'; } return 'Agent'; } export function ThinkingBubble() { return (
); } type MessageBubbleProps = { message: EditorAgentMessage; busyAction: 'confirm' | 'cancel' | null; onConfirmToolCall: (messageId: number) => Promise; onCancelToolCall: (messageId: number) => Promise; onJobCompleted?: () => void; }; export function MessageBubble({ message, busyAction, onConfirmToolCall, onCancelToolCall, onJobCompleted, }: MessageBubbleProps) { const systemErrorText = message.role === 'system' && !message.toolCall && message.text.startsWith(EDITOR_AGENT_ERROR_MESSAGE_PREFIX) ? message.text.slice(EDITOR_AGENT_ERROR_MESSAGE_PREFIX.length) : null; if (message.role === 'system' && !message.toolCall && systemErrorText === null) { return null; } if ( message.role === 'system' && message.toolCall && message.toolCall.status === 'not_completed' && !message.toolCall.externalJobId ) { return ( ); } const isUser = message.role === 'user'; const isSystem = message.role === 'system'; const isSystemError = systemErrorText !== null; return (
{(!isSystem || isSystemError) && (systemErrorText ?? message.text) ? (
{systemErrorText ?? message.text}
) : null} {!isSystem && message.attachments.length ? (
{message.attachments.map((attachment) => ( ))}
) : null} {message.toolCall ? ( ) : null}
); }