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