mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-27 16:04:50 -06:00
refac
This commit is contained in:
@@ -99,16 +99,21 @@
|
||||
|
||||
// Throttle message list rebuilds to once per animation frame during streaming.
|
||||
// Structural changes (currentId change) always rebuild immediately.
|
||||
$: if (history.currentId) {
|
||||
const currentIdChanged = history.currentId !== lastCurrentId;
|
||||
lastCurrentId = history.currentId;
|
||||
const handleHistoryChange = (currentId, _messages) => {
|
||||
if (!currentId) {
|
||||
messages = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const currentIdChanged = currentId !== lastCurrentId;
|
||||
lastCurrentId = currentId;
|
||||
|
||||
if (currentIdChanged) {
|
||||
// Structural change: new chat, navigation, new message — rebuild immediately
|
||||
cancelAnimationFrame(pendingRebuild);
|
||||
pendingRebuild = null;
|
||||
buildMessages();
|
||||
} else if (history.messages) {
|
||||
} else if (_messages) {
|
||||
// Content update (streaming) — throttle to once per frame
|
||||
if (!pendingRebuild) {
|
||||
pendingRebuild = requestAnimationFrame(() => {
|
||||
@@ -117,9 +122,9 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messages = [];
|
||||
}
|
||||
};
|
||||
|
||||
$: handleHistoryChange(history.currentId, history.messages);
|
||||
|
||||
$: if (autoScroll && bottomPadding) {
|
||||
(async () => {
|
||||
|
||||
Reference in New Issue
Block a user