diff --git a/src/interface/web/app/chat/chat.module.css b/src/interface/web/app/chat/chat.module.css index 98786272..b9bd68c7 100644 --- a/src/interface/web/app/chat/chat.module.css +++ b/src/interface/web/app/chat/chat.module.css @@ -21,11 +21,6 @@ div.inputBox { align-content: center; } -div.actualInputArea { - display: grid; - grid-template-columns: auto 1fr auto auto; -} - input.inputBox { border: none; } diff --git a/src/interface/web/app/chat/page.tsx b/src/interface/web/app/chat/page.tsx index 1cf53e12..ac641d6a 100644 --- a/src/interface/web/app/chat/page.tsx +++ b/src/interface/web/app/chat/page.tsx @@ -1,7 +1,7 @@ 'use client' import styles from './chat.module.css'; -import React, { Suspense, useEffect, useRef, useState } from 'react'; +import React, { Suspense, useEffect, useState } from 'react'; import SuggestionCard from '../components/suggestions/suggestionCard'; import SidePanel from '../components/sidePanel/chatHistorySidePanel'; @@ -10,289 +10,16 @@ import NavMenu from '../components/navMenu/navMenu'; import { useSearchParams } from 'next/navigation' import Loading from '../components/loading/loading'; -import { handleCompiledReferences, handleImageResponse, setupWebSocket, uploadDataForIndexing } from '../common/chatFunctions'; -import { Progress } from "@/components/ui/progress" +import { handleCompiledReferences, handleImageResponse, setupWebSocket } from '../common/chatFunctions'; import 'katex/dist/katex.min.css'; -import { - ArrowCircleUp, - ArrowRight, - Browser, - ChatsTeardrop, - FileArrowUp, - GlobeSimple, - Gps, - Image, - Microphone, - Notebook, - Question, - Robot, - Shapes -} from '@phosphor-icons/react'; -import { - Command, - CommandDialog, - CommandEmpty, - CommandGroup, - CommandInput, - CommandItem, - CommandList, - CommandSeparator, - CommandShortcut, -} from "@/components/ui/command" - -import { Textarea } from "@/components/ui/textarea" -import { Button } from '@/components/ui/button'; import { StreamMessage } from '../components/chatMessage/chatMessage'; -import { AlertDialog, AlertDialogAction, AlertDialogContent, AlertDialogDescription, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog'; -import { Popover, PopoverContent } from '@/components/ui/popover'; -import { PopoverTrigger } from '@radix-ui/react-popover'; import { welcomeConsole } from '../common/utils'; +import ChatInputArea, { ChatOptions } from '../components/chatInputArea/chatInputArea'; +import { useAuthenticatedData } from '../common/auth'; -interface ChatInputProps { - sendMessage: (message: string) => void; - sendDisabled: boolean; - setUploadedFiles?: (files: string[]) => void; - conversationId?: string | null; - chatOptionsData?: ChatOptions | null; - isMobileWidth?: boolean; -} -function ChatInputArea(props: ChatInputProps) { - const [message, setMessage] = useState(''); - const fileInputRef = useRef(null); - - const [warning, setWarning] = useState(null); - const [error, setError] = useState(null); - const [uploading, setUploading] = useState(false); - - const [progressValue, setProgressValue] = useState(0); - - useEffect(() => { - if (!uploading) { - setProgressValue(0); - } - - if (uploading) { - const interval = setInterval(() => { - setProgressValue((prev) => { - const increment = Math.floor(Math.random() * 5) + 1; // Generates a random number between 1 and 5 - const nextValue = prev + increment; - return nextValue < 100 ? nextValue : 100; // Ensures progress does not exceed 100 - }); - }, 800); - return () => clearInterval(interval); - } - }, [uploading]); - - function onSendMessage() { - props.sendMessage(message); - setMessage(''); - } - - function handleSlashCommandClick(command: string) { - setMessage(`/${command} `); - } - - function handleFileButtonClick() { - if (!fileInputRef.current) return; - fileInputRef.current.click(); - } - - function handleFileChange(event: React.ChangeEvent) { - if (!event.target.files) return; - - uploadDataForIndexing( - event.target.files, - setWarning, - setUploading, - setError, - props.setUploadedFiles, - props.conversationId); - } - - function getIconForSlashCommand(command: string) { - if (command.includes('summarize')) { - return - } - - if (command.includes('help')) { - return - } - - if (command.includes('automation')) { - return - } - - if (command.includes('webpage')) { - return - } - - if (command.includes('notes')) { - return - } - - if (command.includes('image')) { - return - } - - if (command.includes('default')) { - return - } - - if (command.includes('general')) { - return - } - - if (command.includes('online')) { - return - } - return - } - - return ( - <> - { - uploading && ( - - - - Uploading data. Please wait. - - - - - setUploading(false)}>Dismiss - - - )} - { - warning && ( - - - - Data Upload Warning - - {warning} - setWarning(null)}>Close - - - ) - } - { - error && ( - - - - Oh no! - Something went wrong while uploading your data - - {error} - setError(null)}>Close - - - ) - } - { - (message.startsWith('/') && message.split(' ').length === 1) && -
- - - - - e.preventDefault()} - className={`${props.isMobileWidth ? 'w-[100vw]' : 'w-full'} rounded-md`}> - - - - No matching commands. - - {props.chatOptionsData && Object.entries(props.chatOptionsData).map(([key, value]) => ( - handleSlashCommandClick(key)}> -
-
- {getIconForSlashCommand(key)} - /{key} -
-
- {value} -
-
-
- ))} -
- -
-
-
-
-
- } -
- - - -
-