Yuki Takei 5 месяцев назад
Родитель
Сommit
02eee474e6
1 измененных файлов с 8 добавлено и 10 удалено
  1. 8 10
      apps/app/src/features/openai/client/services/knowledge-assistant.tsx

+ 8 - 10
apps/app/src/features/openai/client/services/knowledge-assistant.tsx

@@ -19,7 +19,7 @@ import type { MessageLog, MessageWithCustomMetaData } from '../../interfaces/mes
 import type { IThreadRelationHasId } from '../../interfaces/thread-relation';
 import { ThreadType } from '../../interfaces/thread-relation';
 import { AiAssistantChatInitialView } from '../components/AiAssistant/AiAssistantSidebar/AiAssistantChatInitialView';
-import { useAiAssistantSidebarStatus } from '../states';
+import { useAiAssistantSidebarActions, useAiAssistantSidebarStatus } from '../states';
 import { useSWRMUTxMessages } from '../stores/message';
 import { useSWRMUTxThreads, useSWRINFxRecentThreads } from '../stores/thread';
 
@@ -73,8 +73,8 @@ type UseKnowledgeAssistant = () => {
 
 export const useKnowledgeAssistant: UseKnowledgeAssistant = () => {
   // Hooks
-  const aiAssistantSidebarData, refreshThreadData = useAiAssistantSidebarStatus();
-  const { aiAssistantData } = aiAssistantSidebarData ?? {};
+  const { aiAssistantData, threadData } = useAiAssistantSidebarStatus();
+  const { refreshThreadData } = useAiAssistantSidebarActions();
   const { mutate: mutateRecentThreads } = useSWRINFxRecentThreads();
   const { trigger: mutateThreadData } = useSWRMUTxThreads(aiAssistantData?._id);
   const { t } = useTranslation();
@@ -151,17 +151,17 @@ export const useKnowledgeAssistant: UseKnowledgeAssistant = () => {
   const placeHolder = useMemo(() => { return 'sidebar_ai_assistant.knowledge_assistant_placeholder' }, []);
 
   const initialView = useMemo(() => {
-    if (aiAssistantSidebarData?.aiAssistantData == null) {
+    if (aiAssistantData == null) {
       return <></>;
     }
 
     return (
       <AiAssistantChatInitialView
-        description={aiAssistantSidebarData.aiAssistantData.description}
-        pagePathPatterns={aiAssistantSidebarData.aiAssistantData.pagePathPatterns}
+        description={aiAssistantData.description}
+        pagePathPatterns={aiAssistantData.pagePathPatterns}
       />
     );
-  }, [aiAssistantSidebarData?.aiAssistantData]);
+  }, [aiAssistantData]);
 
   const [dropdownOpen, setDropdownOpen] = useState(false);
 
@@ -236,8 +236,6 @@ export const useKnowledgeAssistant: UseKnowledgeAssistant = () => {
   }, [dropdownOpen, toggleDropdown, form, t]);
 
   const threadTitleView = useMemo(() => {
-    const { threadData } = aiAssistantSidebarData ?? {};
-
     if (threadData?.title == null) {
       return <></>;
     }
@@ -256,7 +254,7 @@ export const useKnowledgeAssistant: UseKnowledgeAssistant = () => {
         </div>
       </div>
     );
-  }, [aiAssistantSidebarData, handleBackToInitialView]);
+  }, [threadData, handleBackToInitialView]);
 
   return {
     createThread,