diff --git a/application/api/answer/routes.py b/application/api/answer/routes.py index a413194b8..bccffb662 100644 --- a/application/api/answer/routes.py +++ b/application/api/answer/routes.py @@ -130,6 +130,18 @@ def save_conversation(conversation_id, question, response, source_log_docs, llm, } } ) + ##remove following queries from the array + conversations_collection.update_one( + {"_id": ObjectId(conversation_id), f"queries.{index}": {"$exists": True}}, + { + "$push":{ + "queries":{ + "$each":[], + "$slice":index+1 + } + } + } + ) elif conversation_id is not None and conversation_id != "None": conversations_collection.update_one( {"_id": ObjectId(conversation_id)}, diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index 15c9fcb97..f6d656751 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -51,21 +51,7 @@ interface NavigationProps { navOpen: boolean; setNavOpen: React.Dispatch>; } -/* const NavImage: React.FC<{ - Light: string | undefined; - Dark: string | undefined; -}> = ({ Light, Dark }) => { - return ( - <> - icon - icon - - ); -}; -NavImage.propTypes = { - Light: PropTypes.string, - Dark: PropTypes.string, -}; */ + export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { const dispatch = useDispatch(); const queries = useSelector(selectQueries); diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 1eee41e78..fc0044044 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -1,6 +1,6 @@ import 'katex/dist/katex.min.css'; -import { forwardRef, useState } from 'react'; +import { forwardRef, useRef, useState } from 'react'; import ReactMarkdown from 'react-markdown'; import { useSelector } from 'react-redux'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; @@ -26,6 +26,7 @@ import { } from '../preferences/preferenceSlice'; import classes from './ConversationBubble.module.css'; import { FEEDBACK, MESSAGE_TYPE } from './conversationModels'; +import { useOutsideAlerter } from '../hooks'; const DisableSourceFE = import.meta.env.VITE_DISABLE_SOURCE_FE || false; @@ -73,7 +74,9 @@ const ConversationBubble = forwardRef< const [isDislikeClicked, setIsDislikeClicked] = useState(false); const [activeTooltip, setActiveTooltip] = useState(null); const [isSidebarOpen, setIsSidebarOpen] = useState(false); + const editableQueryRef = useRef(null); + useOutsideAlerter(editableQueryRef, () => setIsEditClicked(false), [], true); const handleEditClick = () => { setIsEditClicked(false); handleUpdatedQuestionSubmission?.(editInputBox, true, questionNumber); @@ -87,7 +90,7 @@ const ConversationBubble = forwardRef< >
{!isEditClicked && ( @@ -101,42 +104,44 @@ const ConversationBubble = forwardRef<
)} {isEditClicked && ( - setEditInputBox(e.target.value)} - value={editInputBox} - className="w-[85%] ml-2 mr-2 rounded-[28px] py-[12px] dark:border-[0.5px] dark:border-white dark:bg-raisin-black dark:text-white px-[18px] border-[1.5px] border-black" - /> +
+