mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-07 02:58:21 +00:00
refac
This commit is contained in:
parent
b338850cc1
commit
c701ebe07b
1 changed files with 12 additions and 7 deletions
|
|
@ -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 () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue