Skip to content

Commit 388b20d

Browse files
authored
Clear AI chat stream properly (#3544)
1 parent ea7e94f commit 388b20d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

.changeset/soft-bikes-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Clear AI chat properly

packages/gitbook/src/components/AI/useAIChat.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ export function useAIChatController(): AIChatController {
187187
for await (const data of stream) {
188188
if (!data) continue;
189189

190+
if (globalState.getState().state.query !== input.message) break; // Chat was cleared, stop processing the stream
191+
190192
const event = data.event;
191193

192194
switch (event.type) {

0 commit comments

Comments
 (0)