Skip to content

Commit 860a0b4

Browse files
authored
Merge pull request open-webui#22111 from Algorithm5838/perf/debounce-get-contents
perf: use rAF to debounce getContents() during streaming
2 parents 67893b9 + 6863ca4 commit 860a0b4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/lib/components/chat/Chat.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,11 @@
964964
};
965965
966966
$: if (history) {
967-
getContents();
967+
cancelAnimationFrame(contentsRAF);
968+
contentsRAF = requestAnimationFrame(() => {
969+
getContents();
970+
contentsRAF = null;
971+
});
968972
} else {
969973
artifactContents.set([]);
970974
}
@@ -1294,6 +1298,7 @@
12941298
};
12951299
12961300
let scrollRAF = null;
1301+
let contentsRAF = null;
12971302
const scheduleScrollToBottom = () => {
12981303
if (!scrollRAF) {
12991304
scrollRAF = requestAnimationFrame(async () => {

0 commit comments

Comments
 (0)