diff --git a/src/components/Chat/ChatInput.tsx b/src/components/Chat/ChatInput.tsx index d6836cea..5769ed24 100644 --- a/src/components/Chat/ChatInput.tsx +++ b/src/components/Chat/ChatInput.tsx @@ -33,50 +33,17 @@ const ChatInput: React.FC = ({ const [searchTerm, setSearchTerm] = useState('') const textareaRef = useRef(null) - const getCaretCoordinates = (element: HTMLTextAreaElement) => { - const { selectionStart, value } = element - const textBeforeCaret = value.substring(0, selectionStart) - - // Create a hidden div with the same styling as textarea - const mirror = document.createElement('div') - mirror.style.cssText = window.getComputedStyle(element).cssText - mirror.style.height = 'auto' - mirror.style.position = 'absolute' - mirror.style.visibility = 'hidden' - mirror.style.whiteSpace = 'pre-wrap' - document.body.appendChild(mirror) - - // Create a span for the text before caret - const textNode = document.createTextNode(textBeforeCaret) - const span = document.createElement('span') - span.appendChild(textNode) - mirror.appendChild(span) - - // Get coordinates - const coordinates = { - top: span.offsetTop + parseInt(window.getComputedStyle(element).lineHeight, 10) / 2, - left: span.offsetLeft, - } - - // Clean up - document.body.removeChild(mirror) - - return coordinates - } - const handleKeyDown = (e: React.KeyboardEvent) => { if (userTextFieldInput && !e.shiftKey && e.key === 'Enter') { e.preventDefault() handleSubmitNewMessage() } else if (e.key === '@') { const rect = e.currentTarget.getBoundingClientRect() - const position = getCaretCoordinates(e.currentTarget) setAutocompletePosition({ - top: rect.top + position.top, - left: rect.left + position.left, + top: rect.top, + left: rect.left, }) setShowFileAutocomplete(true) - // console.log('showFileAutocomplete', showFileAutocomplete) } else if (showFileAutocomplete && e.key === 'Escape') { setShowFileAutocomplete(false) } diff --git a/src/components/Chat/MessageComponents/ChatSources.tsx b/src/components/Chat/MessageComponents/ChatSources.tsx index 72ce8891..3c360481 100644 --- a/src/components/Chat/MessageComponents/ChatSources.tsx +++ b/src/components/Chat/MessageComponents/ChatSources.tsx @@ -50,8 +50,8 @@ const ChatSources: React.FC = ({ contextItems }) => { return (
Sources:
- -
+ {/* eslint-disable-next-line tailwindcss/no-custom-classname */} +
{contextItems.map((contextItem) => ( diff --git a/src/components/Chat/index.tsx b/src/components/Chat/index.tsx index b5f8057a..288ed665 100644 --- a/src/components/Chat/index.tsx +++ b/src/components/Chat/index.tsx @@ -54,9 +54,7 @@ const ChatComponent: React.FC = () => { return } - // Extract file references from the message const fileRefs = await extractFileReferences(userTextFieldInput || '') - // console.log('fileRefs', fileRefs) // Create or update chat with file context outputChat = userTextFieldInput?.trim() @@ -68,14 +66,10 @@ const ChatComponent: React.FC = () => { files: fileRefs, }) : chat - // outputChat = userTextFieldInput?.trim() - // ? await appendToOrCreateChat(chat, userTextFieldInput, agentConfig) - // : chat if (!outputChat) { return } - // console.log('outputChat', outputChat) setCurrentChat(outputChat) await saveChat(outputChat)