import React, { ForwardedRef, useEffect, useRef } from 'react'; type Message = { role: string content: string } interface ConversationProps { messages: Message[]; onStopClick: () => void; onResendClick: () => void; onEditClick: () => void; onCopyClick: () => void; isClicked: boolean } const ConversationFrontend = React.forwardRef( ({ messages,onStopClick, onResendClick, onEditClick, onCopyClick, isClicked }, ref: ForwardedRef) => { const messagesEndRef = useRef(null) useEffect(() => { if (messagesEndRef.current) { const rect = messagesEndRef.current.getBoundingClientRect(); console.log('Position of the target div:'); console.log('Top:', rect.top); // Distance from the top of the viewport console.log('Left:', rect.left); // Distance from the left of the viewport console.log('Width:', rect.width); // Width of the element console.log('Height:', rect.height); // Height of the element } }, [messages]); useEffect(() => { messagesEndRef.current?.scrollIntoView() }, [messages]) return (
{messages.map((message, index) => { if (index >= 1) { return (

{message.content}

); } })}
Stop
Resend
Edit
{isClicked?"Copied!": "Copy" }
); } ); export default ConversationFrontend;