From 7e0b067709c27ef30ef2b31c502ea78a0ea79d21 Mon Sep 17 00:00:00 2001 From: mamadoudicko Date: Thu, 30 Nov 2023 10:27:13 +0100 Subject: [PATCH] fix: update mention suggestion filtering logic --- .../components/Editor/hooks/useMentionConfig.ts | 12 +++++++----- .../QADisplay/components/MessageRow/MessageRow.tsx | 13 +++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/components/ChatEditor/components/Editor/hooks/useMentionConfig.ts b/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/components/ChatEditor/components/Editor/hooks/useMentionConfig.ts index 768649567df3..b86545ec1cd8 100644 --- a/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/components/ChatEditor/components/Editor/hooks/useMentionConfig.ts +++ b/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/components/ChatEditor/components/Editor/hooks/useMentionConfig.ts @@ -79,11 +79,13 @@ export const useMentionConfig = ({ }); }, onUpdate: (props) => { - reactRenderer?.updateProps(props); - - if (!props.clientRect) { - return; - } + reactRenderer?.updateProps({ + ...props, + suggestionData: { + ...suggestionData, + items: props.items, + }, + }); }, onKeyDown: (props) => { if (props.event.key === "Escape") { diff --git a/frontend/app/chat/[chatId]/components/ChatDialogueArea/components/ChatDialogue/components/QADisplay/components/MessageRow/MessageRow.tsx b/frontend/app/chat/[chatId]/components/ChatDialogueArea/components/ChatDialogue/components/QADisplay/components/MessageRow/MessageRow.tsx index f4043833e9b1..3712bb6ea0fc 100644 --- a/frontend/app/chat/[chatId]/components/ChatDialogueArea/components/ChatDialogue/components/QADisplay/components/MessageRow/MessageRow.tsx +++ b/frontend/app/chat/[chatId]/components/ChatDialogueArea/components/ChatDialogue/components/QADisplay/components/MessageRow/MessageRow.tsx @@ -4,10 +4,9 @@ import { CopyButton } from "./components/CopyButton"; import { MessageContent } from "./components/MessageContent"; import { QuestionBrain } from "./components/QuestionBrain"; import { QuestionPrompt } from "./components/QuestionPrompt"; -import { SourcesButton } from './components/SourcesButton'; // Import the new component +import { SourcesButton } from "./components/SourcesButton"; import { useMessageRow } from "./hooks/useMessageRow"; - type MessageRowProps = { speaker: "user" | "assistant"; text?: string; @@ -38,9 +37,11 @@ export const MessageRow = React.forwardRef( const sourcesIndex = messageContent.lastIndexOf("**Sources:**"); const hasSources = sourcesIndex !== -1; - + if (hasSources) { - sourcesContent = messageContent.substring(sourcesIndex + "**Sources:**".length).trim(); + sourcesContent = messageContent + .substring(sourcesIndex + "**Sources:**".length) + .trim(); messageContent = messageContent.substring(0, sourcesIndex).trim(); } @@ -49,7 +50,7 @@ export const MessageRow = React.forwardRef(
{/* Left section for the question and prompt */} -
+
@@ -74,5 +75,5 @@ export const MessageRow = React.forwardRef( ); } ); - + MessageRow.displayName = "MessageRow";