diff --git a/packages/ui/src/stores/session-actions.ts b/packages/ui/src/stores/session-actions.ts index c95359a..24be1fc 100644 --- a/packages/ui/src/stores/session-actions.ts +++ b/packages/ui/src/stores/session-actions.ts @@ -449,7 +449,7 @@ async function readSseStream( if (idleTimer) clearTimeout(idleTimer) idleTimer = setTimeout(() => { timedOut = true - reader.cancel().catch(() => {}) + reader.cancel().catch(() => { }) }, idleTimeoutMs) } resetIdleTimer() @@ -474,6 +474,8 @@ async function readSseStream( } onData(data) } + // Yield to main thread periodically to prevent UI freeze during rapid streaming + await new Promise(resolve => setTimeout(resolve, 0)) } if (timedOut) { throw new Error("Stream timed out")