Skip to content

Commit 657df48

Browse files
authored
fix: correct incorrect assistant display when quick ai access (#779)
* fix: correct incorrect assistant display when quick ai access * docs: update changelog
1 parent f4f7732 commit 657df48

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

docs/content.en/docs/release-notes/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Information about release notes of Coco Server is provided here.
2626
- fix: unregister ext hotkey when it gets deleted #770
2727
- fix: indexing apps does not respect search scope config #773
2828
- fix: restore missing category titles on subpages #772
29-
29+
- fix: correct incorrect assistant display when quick ai access #779
3030

3131
### ✈️ Improvements
3232

src/components/Search/AssistantManager.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useRef, useMemo, useState } from "react";
1+
import { useCallback, useRef, useMemo, useState, useEffect } from "react";
22
import { cloneDeep, isEmpty } from "lodash-es";
33

44
import { useSearchStore } from "@/stores/searchStore";
@@ -43,12 +43,17 @@ export function useAssistantManager({
4343
const askAIRef = useRef<Assistant | null>(null);
4444

4545
const askAI = useMemo(() => {
46-
const newAssistant = selectedAssistant ?? quickAiAccessAssistant;
47-
return newAssistant;
46+
return selectedAssistant ?? quickAiAccessAssistant;
4847
}, [quickAiAccessAssistant, selectedAssistant]);
4948

5049
const [assistantDetail, setAssistantDetail] = useState<any>({});
5150

51+
useEffect(() => {
52+
if (goAskAi) return;
53+
54+
askAIRef.current = null;
55+
}, [goAskAi]);
56+
5257
const assistant_get = useCallback(async () => {
5358
if (!askAI?.id) return;
5459
if (disabledExtensions.includes("QuickAIAccess")) return;
@@ -75,7 +80,8 @@ export function useAssistantManager({
7580

7681
if (disabledExtensions.includes("QuickAIAccess")) return;
7782

78-
askAIRef.current = cloneDeep(askAI);
83+
askAIRef.current ??= cloneDeep(askAI);
84+
7985
if (!askAIRef.current) return;
8086

8187
let value = inputValue.trim();

0 commit comments

Comments
 (0)