mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix GlobalChatPane input delay after AI response completes
Release the loading state immediately when finish_reason is received, but don't break from the for-await loop. Breaking triggers async iterator cleanup which can cause a multi-second delay before the input becomes available again. Instead, let the stream drain naturally while the UI is already unlocked for user input.
This commit is contained in:
1 parent
6457fbda76
commit
ad217937a3
1 file changed
+2
-5
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user