import * as Dialog from '@radix-ui/react-dialog'; import { useEffect, useRef, useState } from 'react'; import { type ChatHistoryItem } from '~/lib/persistence'; interface HistoryItemProps { item: ChatHistoryItem; onDelete?: (event: React.UIEvent) => void; } export function HistoryItem({ item, onDelete }: HistoryItemProps) { const [hovering, setHovering] = useState(false); const hoverRef = useRef(null); useEffect(() => { let timeout: NodeJS.Timeout | undefined; function mouseEnter() { setHovering(true); if (timeout) { clearTimeout(timeout); } } function mouseLeave() { setHovering(false); } hoverRef.current?.addEventListener('mouseenter', mouseEnter); hoverRef.current?.addEventListener('mouseleave', mouseLeave); return () => { hoverRef.current?.removeEventListener('mouseenter', mouseEnter); hoverRef.current?.removeEventListener('mouseleave', mouseLeave); }; }, []); return (
{item.description}
{hovering && (
)}
); }