import { ChatbotUIContext } from "@/context/context" import { IconCheck, IconCopy, IconEdit, IconRepeat } from "@tabler/icons-react" import { FC, useContext, useEffect, useState } from "react" import { WithTooltip } from "../ui/with-tooltip" export const MESSAGE_ICON_SIZE = 18 interface MessageActionsProps { isAssistant: boolean isLast: boolean isEditing: boolean isHovering: boolean onCopy: () => void onEdit: () => void onRegenerate: () => void } export const MessageActions: FC = ({ isAssistant, isLast, isEditing, isHovering, onCopy, onEdit, onRegenerate }) => { const { isGenerating } = useContext(ChatbotUIContext) const [showCheckmark, setShowCheckmark] = useState(false) const handleCopy = () => { onCopy() setShowCheckmark(true) } const handleForkChat = async () => {} useEffect(() => { if (showCheckmark) { const timer = setTimeout(() => { setShowCheckmark(false) }, 2000) return () => clearTimeout(timer) } }, [showCheckmark]) return (isLast && isGenerating) || isEditing ? null : (
{/* {((isAssistant && isHovering) || isLast) && ( Fork Chat
} trigger={ } /> )} */} {!isAssistant && isHovering && ( Edit} trigger={ } /> )} {(isHovering || isLast) && ( Copy} trigger={ showCheckmark ? ( ) : ( ) } /> )} {isLast && ( Regenerate} trigger={ } /> )} {/* {1 > 0 && isAssistant && } */} ) }