diff --git a/src/components/GlobalChatProvider.tsx b/src/components/GlobalChatProvider.tsx index e86db2ac..0058f039 100644 --- a/src/components/GlobalChatProvider.tsx +++ b/src/components/GlobalChatProvider.tsx @@ -143,15 +143,12 @@ export function GlobalChatProvider({ children }: GlobalChatProviderProps) { return updated; }); - // Check if the stream is finished (finish_reason is set) - // Only release once to avoid multiple state updates + // Release loading as soon as finish_reason is received + // Don't break - let the stream drain naturally to avoid async iterator cleanup delays const finishReason = chunk.choices[0]?.finish_reason; if (finishReason && !loadingReleased) { loadingReleased = true; - // Response is complete, release the input immediately setIsLoading(false); - // Break out of the loop - we don't need any more chunks - break; } }