fix: defer padding recalculation to avoid race condition with DOM updates

This commit is contained in:
Andrew Beal 2025-10-12 00:55:22 +01:00
parent 84ea96c394
commit 68dda10852

View file

@ -16,11 +16,15 @@
export let chatContainer: HTMLDivElement;
export function onFinishedSubmitting() {
if (lastAssistantMessageElement && lastAssistantMessageElement.offsetHeight <
chatContainer.offsetHeight - parseFloat(getComputedStyle(chatContainer).padding) * 2) {
// Recalculate padding when streaming ends to fix race condition with streaming indicator removal
assistantMessageAction(lastAssistantMessageElement);
}
tick().then(() => {
requestAnimationFrame(() => {
if (lastAssistantMessageElement && lastAssistantMessageElement.offsetHeight <
chatContainer.offsetHeight - parseFloat(getComputedStyle(chatContainer).padding) * 2) {
// Recalculate padding when streaming ends to fix race condition with streaming indicator removal
assistantMessageAction(lastAssistantMessageElement);
}
});
});
}
let thoughtElement: HTMLElement | undefined;