perf: fix double-RAF streaming display lag (#23016)
This commit is contained in:
@@ -555,13 +555,7 @@
|
|||||||
console.log('Unknown message type', data);
|
console.log('Unknown message type', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'chat:message:delta' || type === 'message' || type === 'status') {
|
history.messages[event.message_id] = message;
|
||||||
scheduleHistoryFlush();
|
|
||||||
} else {
|
|
||||||
cancelAnimationFrame(historyRAF);
|
|
||||||
historyRAF = null;
|
|
||||||
history.messages[event.message_id] = message;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Non-active chat completion: queue stays in the global store.
|
// Non-active chat completion: queue stays in the global store.
|
||||||
@@ -1313,15 +1307,6 @@
|
|||||||
|
|
||||||
let scrollRAF = null;
|
let scrollRAF = null;
|
||||||
let contentsRAF = null;
|
let contentsRAF = null;
|
||||||
let historyRAF = null;
|
|
||||||
const scheduleHistoryFlush = () => {
|
|
||||||
if (!historyRAF) {
|
|
||||||
historyRAF = requestAnimationFrame(() => {
|
|
||||||
historyRAF = null;
|
|
||||||
history = history;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const scheduleScrollToBottom = () => {
|
const scheduleScrollToBottom = () => {
|
||||||
if (!scrollRAF) {
|
if (!scrollRAF) {
|
||||||
scrollRAF = requestAnimationFrame(async () => {
|
scrollRAF = requestAnimationFrame(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user