From 7d10eed7c29f5c9bab5a6315a48fba1b5f716211 Mon Sep 17 00:00:00 2001 From: Jackson Chen <541898146chen@gmail.com> Date: Thu, 9 Jan 2025 22:10:36 -0800 Subject: [PATCH] refactor(chat): remove PopoverMentionList component and its associated styles --- .../components/chat/popover-mention-list.tsx | 130 ------------------ 1 file changed, 130 deletions(-) delete mode 100644 ee/tabby-ui/components/chat/popover-mention-list.tsx diff --git a/ee/tabby-ui/components/chat/popover-mention-list.tsx b/ee/tabby-ui/components/chat/popover-mention-list.tsx deleted file mode 100644 index efe5a702160d..000000000000 --- a/ee/tabby-ui/components/chat/popover-mention-list.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import React, { useEffect, useRef } from 'react' - -import { MentionNodeAttrs, SourceItem } from './prompt-form-editor/types' - -interface PopoverMentionListProps { - items: SourceItem[] - selectedIndex: number - onUpdateSelectedIndex: (index: number) => void - handleItemSelection: ( - item: SourceItem, - command?: (props: MentionNodeAttrs) => void - ) => void -} - -// Maximum number of items visible in the list -const MAX_VISIBLE_ITEMS = 4 -// Height of each item in pixels -const ITEM_HEIGHT = 42 - -export const PopoverMentionList: React.FC = ({ - items, - selectedIndex, - onUpdateSelectedIndex, - handleItemSelection -}) => { - const selectedItemRef = useRef(null) - const containerRef = useRef(null) - - // Dynamically calculate container height based on number of items - const containerHeight = - Math.min(items.length, MAX_VISIBLE_ITEMS) * ITEM_HEIGHT - - // Scroll into view for the currently selected item - useEffect(() => { - const container = containerRef.current - const selectedItem = selectedItemRef.current - if (container && selectedItem) { - const containerTop = container.scrollTop - const containerBottom = containerTop + container.clientHeight - const itemTop = selectedItem.offsetTop - const itemBottom = itemTop + selectedItem.offsetHeight - - if (itemTop < containerTop) { - container.scrollTop = itemTop - } else if (itemBottom > containerBottom) { - container.scrollTop = itemBottom - container.clientHeight - } - } - }, [selectedIndex]) - - // Render list content - const renderContent = () => { - if (!items.length) { - return ( -
- No files found -
- ) - } - - return ( -
- {items.map((item, index) => { - const filepath = item.filepath - const isSelected = index === selectedIndex - - return ( - - ) - })} -
- ) - } - - return <>{renderContent()} -}