From 625aed151de6a3024f02cd5ad198ab5193f5f8df Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Thu, 28 Nov 2024 04:02:05 +0530 Subject: [PATCH 1/4] (fix:edit-query)delete following queries --- application/api/answer/routes.py | 12 ++++++++++++ frontend/src/conversation/ConversationBubble.tsx | 4 +--- frontend/src/conversation/conversationSlice.ts | 5 ++++- frontend/src/settings/Documents.tsx | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) 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/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 1eee41e78..324c722b8 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -337,9 +337,7 @@ const ConversationBubble = forwardRef< ) : ( - - {children} - + {children} ); }, ul({ children }) { diff --git a/frontend/src/conversation/conversationSlice.ts b/frontend/src/conversation/conversationSlice.ts index 9298e7a52..69f81e212 100644 --- a/frontend/src/conversation/conversationSlice.ts +++ b/frontend/src/conversation/conversationSlice.ts @@ -173,7 +173,10 @@ export const conversationSlice = createSlice({ state, action: PayloadAction<{ index: number; prompt: string; query?: Query }>, ) { - state.queries[action.payload.index] = action.payload; + state.queries = [ + ...state.queries.splice(0, action.payload.index), + action.payload, + ]; }, updateStreamingQuery( state, diff --git a/frontend/src/settings/Documents.tsx b/frontend/src/settings/Documents.tsx index cea14f0a7..bbad47635 100644 --- a/frontend/src/settings/Documents.tsx +++ b/frontend/src/settings/Documents.tsx @@ -85,7 +85,7 @@ const Documents: React.FC = ({ setSortField(newSortField); setSortOrder(newSortOrder); } - + setLoading(true); getDocsWithPagination( newSortField, newSortOrder, From 55ecda902dd9b080a773d698057f5443b1f097be Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 29 Nov 2024 03:28:35 +0530 Subject: [PATCH 2/4] (fix:edit-feat): exacting the UI/UX --- frontend/src/Navigation.tsx | 16 +---- .../src/conversation/ConversationBubble.tsx | 71 ++++++++++--------- 2 files changed, 37 insertions(+), 50 deletions(-) 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 324c722b8..e642f5fcc 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,40 @@ 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" - /> +
+ setEditInputBox(e.target.value)} + value={editInputBox} + className="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" + /> +
+ + +
+
)} -
{ + setIsEditClicked(true); + setEditInputBox(message); + }} + className={`p-2 cursor-pointer rounded-full hover:bg-[#35363B] flex items-center ${isQuestionHovered || isEditClicked ? 'visible' : 'invisible'}`} > - Edit { - setIsEditClicked(true); - setEditInputBox(message); - }} - /> -
+ Edit + - {isEditClicked && ( -
- - -
- )} ); } else { From 6953c3dbe4c260a0f0767b7a28f292eaf2cd84a2 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 29 Nov 2024 03:32:36 +0530 Subject: [PATCH 3/4] (fix:markdown) no overflowing words --- frontend/src/conversation/ConversationBubble.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index e642f5fcc..39d2b5766 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -310,7 +310,7 @@ const ConversationBubble = forwardRef< }`} > Date: Sat, 30 Nov 2024 02:44:24 +0530 Subject: [PATCH 4/4] (fix:edit-query) replace input with textarea --- frontend/src/conversation/ConversationBubble.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 39d2b5766..fc0044044 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -105,10 +105,14 @@ const ConversationBubble = forwardRef< )} {isEditClicked && (
- setEditInputBox(e.target.value)} +