import type { ChatHitlPart, HitlSubmissionOptions, ChatMessage as ChatMessageModel } from "@agents24/react" import type { FeedbackReason, HitlResponse } from "@agents24/client" import type { AgentChatRuntimeHitlActionState } from "@agents24/chat-react/runtime" import { AgentChatDefaultActions, AgentChatUserMessageActionRow, ChatAttachmentRows, useCompletionActionEntrance, type ChatAttachmentContentResolver } from "@agents24/chat-react/ui" import * as React from "react" import { MessageParts } from "./message-parts" import { Bubble, BubbleContent } from "../ui/bubble" import { Message, MessageContent, MessageFooter } from "../ui/message" import type { Agents24ChatTimelineSlotProps } from "../../app" type Props = { animateCompletion: boolean message: ChatMessageModel getHitlActionState: (part: ChatHitlPart) => AgentChatRuntimeHitlActionState | undefined isLoading: boolean onHitlAction: (part: ChatHitlPart, response: HitlResponse, options?: HitlSubmissionOptions) => Promise onRegenerate: () => Promise allowFeedback: boolean onSetFeedback: ( input: { rating: "like" | "dislike" | null; reason?: FeedbackReason | null; comment?: string | null }, ) => Promise Timeline?: React.ComponentType resolveAttachmentContent?: ChatAttachmentContentResolver } export function ChatMessage({ animateCompletion, allowFeedback, getHitlActionState, isLoading, message, onHitlAction, onRegenerate, onSetFeedback, resolveAttachmentContent, Timeline, }: Props) { const isUser = message.role === "user" const showCompletionActions = !isUser && message.isFinal !== false && !isLoading const animateCompletionActions = useCompletionActionEntrance(showCompletionActions, message.runId, animateCompletion) return ( {isUser && message.attachments?.length ? ( ) : null} {isUser && ( { void navigator.clipboard.writeText(content).catch(() => undefined) }, }} message={message} /> )} {showCompletionActions && ( { void navigator.clipboard.writeText(content).catch(() => undefined) }, onRetry: () => onRegenerate(), onSetFeedback: allowFeedback ? (_message, input) => onSetFeedback(input) : undefined, }} message={message} /> )} ) }