diff --git a/.changeset/soft-bikes-warn.md b/.changeset/soft-bikes-warn.md new file mode 100644 index 000000000..7b8fff766 --- /dev/null +++ b/.changeset/soft-bikes-warn.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Clear AI chat properly diff --git a/packages/gitbook/src/components/AI/useAIChat.tsx b/packages/gitbook/src/components/AI/useAIChat.tsx index b5a45e84d..2be97db39 100644 --- a/packages/gitbook/src/components/AI/useAIChat.tsx +++ b/packages/gitbook/src/components/AI/useAIChat.tsx @@ -187,6 +187,8 @@ export function useAIChatController(): AIChatController { for await (const data of stream) { if (!data) continue; + if (globalState.getState().state.query !== input.message) break; // Chat was cleared, stop processing the stream + const event = data.event; switch (event.type) {