mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-08 03:08:02 +00:00
perf: batch scrollToBottom during streaming via rAF (#21946)
This commit is contained in:
parent
ff8cf80fb5
commit
fc5f399573
1 changed files with 12 additions and 2 deletions
|
|
@ -1281,6 +1281,16 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
let scrollRAF = null;
|
||||
const scheduleScrollToBottom = () => {
|
||||
if (!scrollRAF) {
|
||||
scrollRAF = requestAnimationFrame(async () => {
|
||||
scrollRAF = null;
|
||||
await scrollToBottom();
|
||||
});
|
||||
}
|
||||
};
|
||||
const chatCompletedHandler = async (_chatId, modelId, responseMessageId, messages) => {
|
||||
const res = await chatCompleted(localStorage.token, {
|
||||
model: modelId,
|
||||
|
|
@ -1698,7 +1708,7 @@
|
|||
await tick();
|
||||
|
||||
if (autoScroll) {
|
||||
scrollToBottom();
|
||||
scheduleScrollToBottom();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -2482,7 +2492,7 @@
|
|||
}
|
||||
|
||||
if (autoScroll) {
|
||||
scrollToBottom();
|
||||
scheduleScrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue