This commit is contained in:
Timothy Jaeryang Baek committed 2026-03-06 14:07:34 -06:00
1 parent 04fae8b357
commit 47b007ef19
1 file changed
+7 -3
@@ -59,8 +59,8 @@
tokens = marked.lexer(replaceTokens(processResponseContent(content), model?.name, $user?.name)); tokens = marked.lexer(replaceTokens(processResponseContent(content), model?.name, $user?.name));
}; };
// Throttle parsing to once per animation frame while streaming const updateHandler = (content) => {
$: if (content) { if (content) {
if (done) { if (done) {
cancelAnimationFrame(pendingUpdate); cancelAnimationFrame(pendingUpdate);
pendingUpdate = null; pendingUpdate = null;
@@ -72,8 +72,12 @@
}); });
} }
} }
};
onDestroy(() => { $: updateHandler(content);
// Throttle parsing to once per animation frame while streaming
$: onDestroy(() => {
cancelAnimationFrame(pendingUpdate); cancelAnimationFrame(pendingUpdate);
}); });
</script> </script>