Skip to content

Commit 060c09e

Browse files
authored
fix: resolved minor issues with voice playback (#780)
* fix: resolved minor issues with voice playback * docs: update changelog * update
1 parent 657df48 commit 060c09e

File tree

6 files changed

+37
-16
lines changed

6 files changed

+37
-16
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Information about release notes of Coco Server is provided here.
2727
- fix: indexing apps does not respect search scope config #773
2828
- fix: restore missing category titles on subpages #772
2929
- fix: correct incorrect assistant display when quick ai access #779
30+
- fix: resolved minor issues with voice playback #780
3031

3132
### ✈️ Improvements
3233

src/components/Assistant/Chat.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { useAppStore } from "@/stores/appStore";
2424
import { useSearchStore } from "@/stores/searchStore";
2525
import { useAuthStore } from "@/stores/authStore";
2626
import Splash from "./Splash";
27-
import Synthesize from "./Synthesize";
2827

2928
interface ChatAIProps {
3029
isSearchActive?: boolean;
@@ -86,7 +85,6 @@ const ChatAI = memo(
8685
});
8786

8887
const { currentService, visibleStartPage } = useConnectStore();
89-
const { synthesizeItem } = useChatStore();
9088

9189
const addError = useAppStore.getState().addError;
9290

@@ -404,8 +402,6 @@ const ChatAI = memo(
404402
{!activeChat?._id && !visibleStartPage && (
405403
<PrevSuggestion sendMessage={init} />
406404
)}
407-
408-
{synthesizeItem && <Synthesize />}
409405
</div>
410406
</>
411407
);

src/components/Search/AiOverview.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const AiOverview: FC<AiSummaryProps> = (props) => {
2121

2222
const [visible, setVisible] = useState(false);
2323

24-
const { isTyping, chunkData, loadingStep } = useStreamChat({
24+
const { isTyping, chunkData, loadingStep, messageId } = useStreamChat({
2525
message,
2626
clientId: "ai-overview-client-id",
2727
server: aiOverviewServer,
@@ -56,10 +56,10 @@ const AiOverview: FC<AiSummaryProps> = (props) => {
5656
<div className="flex-1 overflow-auto text-sm hide-scrollbar">
5757
<div className="-ml-11 -mr-4 user-select-text">
5858
<ChatMessage
59-
key="current"
59+
key={messageId}
6060
hide_assistant
6161
message={{
62-
_id: "current",
62+
_id: messageId,
6363
_source: {
6464
type: "assistant",
6565
message: "",

src/components/Search/AskAi.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,20 @@ import { useShortcutsStore } from "@/stores/shortcutsStore";
2020
interface State {
2121
serverId?: string;
2222
assistantId?: string;
23-
copyButtonId?: string;
23+
messageId: string;
24+
copyButtonId: string;
2425
}
2526

2627
const AskAi = () => {
27-
const { askAiMessage, setGoAskAi, setSelectedAssistant, setAskAiSessionId, selectedAssistant, setAskAiServerId, setAskAiAssistantId } = useSearchStore();
28+
const {
29+
askAiMessage,
30+
setGoAskAi,
31+
setSelectedAssistant,
32+
setAskAiSessionId,
33+
selectedAssistant,
34+
setAskAiServerId,
35+
setAskAiAssistantId,
36+
} = useSearchStore();
2837

2938
const addError = useAppStore((state) => state.addError);
3039

@@ -62,7 +71,10 @@ const AskAi = () => {
6271

6372
const { quickAiAccessServer, quickAiAccessAssistant } = useExtensionsStore();
6473

65-
const state = useReactive<State>({});
74+
const state = useReactive<State>({
75+
messageId: nanoid(),
76+
copyButtonId: nanoid(),
77+
});
6678

6779
const modifierKey = useShortcutsStore((state) => state.modifierKey);
6880

@@ -154,7 +166,10 @@ const AskAi = () => {
154166

155167
const { serverId, assistantId } = state;
156168

157-
state.copyButtonId = nanoid();
169+
Object.assign(state, {
170+
messageId: nanoid(),
171+
copyButtonId: nanoid(),
172+
});
158173

159174
try {
160175
await platformAdapter.invokeBackend("ask_ai", {
@@ -210,10 +225,10 @@ const AskAi = () => {
210225

211226
<div className="-my-8 -ml-11 user-select-text">
212227
<ChatMessage
213-
key={"current"}
228+
key={state.messageId}
214229
hide_assistant
215230
message={{
216-
_id: "current",
231+
_id: state.messageId,
217232
_source: {
218233
type: "assistant",
219234
message: "",

src/hooks/useStreamChat.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useAppStore } from "@/stores/appStore";
66
import { EventPayloads } from "@/types/platform";
77
import platformAdapter from "@/utils/platformAdapter";
88
import useMessageChunkData from "./useMessageChunkData";
9+
import { nanoid } from "nanoid";
910

1011
interface Options {
1112
message: string;
@@ -18,15 +19,17 @@ interface Options {
1819
interface State {
1920
sessionId?: string;
2021
isTyping?: boolean;
22+
messageId: string;
2123
}
2224

2325
export const useStreamChat = (options: Options) => {
2426
const { message, clientId, server, assistant, setVisible } = options;
2527

2628
const unlistenRef = useRef<() => void>(noop);
27-
const addError = useAppStore((state) => state.addError);
29+
const { addError } = useAppStore();
2830
const state = useReactive<State>({
2931
isTyping: true,
32+
messageId: nanoid(),
3033
});
3134
const [loadingStep, setLoadingStep] = useState<Record<string, boolean>>({
3235
query_intent: false,
@@ -112,6 +115,8 @@ export const useStreamChat = (options: Options) => {
112115

113116
clearAllChunkData();
114117

118+
state.messageId = nanoid();
119+
115120
try {
116121
await platformAdapter.invokeBackend("ask_ai", {
117122
message,

src/pages/main/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@ import SearchChat from "@/components/SearchChat";
44
import { useAppStore } from "@/stores/appStore";
55
import { useSyncStore } from "@/hooks/useSyncStore";
66
import UpdateApp from "@/components/UpdateApp";
7+
import Synthesize from "@/components/Assistant/Synthesize";
8+
import { useChatStore } from "@/stores/chatStore";
79

810
function MainApp() {
9-
10-
const setIsTauri = useAppStore((state) => state.setIsTauri);
11+
const { setIsTauri } = useAppStore();
1112
useEffect(() => {
1213
setIsTauri(true);
1314
}, []);
15+
const { synthesizeItem } = useChatStore();
1416

1517
useSyncStore();
1618

1719
return (
1820
<>
1921
<SearchChat isTauri={true} hasModules={["search", "chat"]} />
2022
<UpdateApp />
23+
24+
{synthesizeItem && <Synthesize />}
2125
</>
2226
);
2327
}

0 commit comments

Comments
 (0)