From b78a912af1e6510e5803bbce4291de65e7a66579 Mon Sep 17 00:00:00 2001 From: MK Fain Date: Wed, 3 Dec 2025 20:56:46 -0600 Subject: [PATCH] Fix GlobalChatPane input delay after AI finishes responding Check for finish_reason in stream chunks to detect when the AI has finished generating content, and release isLoading immediately rather than waiting for the stream connection to fully close. --- src/components/GlobalChatProvider.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/GlobalChatProvider.tsx b/src/components/GlobalChatProvider.tsx index 4fdf8d39..3ced583c 100644 --- a/src/components/GlobalChatProvider.tsx +++ b/src/components/GlobalChatProvider.tsx @@ -141,6 +141,13 @@ export function GlobalChatProvider({ children }: GlobalChatProviderProps) { } return updated; }); + + // Check if the stream is finished (finish_reason is set) + const finishReason = chunk.choices[0]?.finish_reason; + if (finishReason) { + // Response is complete, release the input immediately + setIsLoading(false); + } } // Final trim after response is complete