From 6863ca482c8bda5e4dd89212a2969ec2daecb3d3 Mon Sep 17 00:00:00 2001 From: Algorithm5838 <108630393+Algorithm5838@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:42:16 +0300 Subject: [PATCH] perf: use rAF to debounce getContents() during streaming --- src/lib/components/chat/Chat.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index a44756febd..14a7de457f 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -964,7 +964,11 @@ }; $: if (history) { - getContents(); + cancelAnimationFrame(contentsRAF); + contentsRAF = requestAnimationFrame(() => { + getContents(); + contentsRAF = null; + }); } else { artifactContents.set([]); } @@ -1294,6 +1298,7 @@ }; let scrollRAF = null; + let contentsRAF = null; const scheduleScrollToBottom = () => { if (!scrollRAF) { scrollRAF = requestAnimationFrame(async () => {