import { useEffect, useRef } from 'react' import { Bot, FileText } from 'lucide-react' export interface MentionItem { type: 'file' | 'agent' value: string label: string description?: string } interface MentionSuggestionsProps { isOpen: boolean items: MentionItem[] onSelect: (item: MentionItem) => void onClose: () => void selectedIndex?: number } export function MentionSuggestions({ isOpen, items, onSelect, onClose, selectedIndex = 0 }: MentionSuggestionsProps) { const listRef = useRef(null) useEffect(() => { if (!isOpen) return const handleClickOutside = (e: MouseEvent) => { if (listRef.current && !listRef.current.contains(e.target as Node)) { onClose() } } document.addEventListener('mousedown', handleClickOutside) return () => document.removeEventListener('mousedown', handleClickOutside) }, [isOpen, onClose]) useEffect(() => { if (!isOpen || !listRef.current) return const selectedItem = listRef.current.children[selectedIndex] as HTMLElement if (selectedItem) { selectedItem.scrollIntoView({ block: 'nearest' }) } }, [selectedIndex, isOpen]) if (!isOpen || items.length === 0) return null const getFilename = (path: string) => path.split('/').pop() || path const getDirectory = (path: string) => { const parts = path.split('/') return parts.slice(0, -1).join('/') || '.' } return (
{items.map((item, idx) => ( ))}
) }