import { useParams } from '@remix-run/react'; import { classNames } from '~/utils/classNames'; import * as Dialog from '@radix-ui/react-dialog'; import { type ChatHistoryItem } from '~/lib/persistence'; import WithTooltip from '~/components/ui/Tooltip'; import { useEditChatDescription } from '~/lib/hooks'; interface HistoryItemProps { item: ChatHistoryItem; onDelete?: (event: React.UIEvent) => void; onDuplicate?: (id: string) => void; exportChat: (id?: string) => void; } export function HistoryItem({ item, onDelete, onDuplicate, exportChat }: HistoryItemProps) { const { id: urlId } = useParams(); const isActiveChat = urlId === item.urlId; const { editing, handleChange, handleBlur, handleSubmit, handleKeyDown, currentDescription, toggleEditMode } = useEditChatDescription({ initialDescription: item.description, customChatId: item.id, syncWithGlobalStore: isActiveChat, }); const renderDescriptionForm = (