From abe42eaf0985de826b416e6952b494294a1b9add Mon Sep 17 00:00:00 2001 From: Algorithm5838 <108630393+Algorithm5838@users.noreply.github.com> Date: Thu, 26 Mar 2026 00:13:31 +0300 Subject: [PATCH] perf: fix double-RAF streaming display lag (#23016) --- src/lib/components/chat/Chat.svelte | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 5407f307b..c4955882b 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -555,13 +555,7 @@ console.log('Unknown message type', data); } - if (type === 'chat:message:delta' || type === 'message' || type === 'status') { - scheduleHistoryFlush(); - } else { - cancelAnimationFrame(historyRAF); - historyRAF = null; - history.messages[event.message_id] = message; - } + history.messages[event.message_id] = message; } } else { // Non-active chat completion: queue stays in the global store. @@ -1313,15 +1307,6 @@ let scrollRAF = null; let contentsRAF = null; - let historyRAF = null; - const scheduleHistoryFlush = () => { - if (!historyRAF) { - historyRAF = requestAnimationFrame(() => { - historyRAF = null; - history = history; - }); - } - }; const scheduleScrollToBottom = () => { if (!scrollRAF) { scrollRAF = requestAnimationFrame(async () => {