carrito semi saneado

This commit is contained in:
Lucas Tettamanti
2026-01-17 15:20:32 -03:00
parent 204403560e
commit 8cc4744c49
4 changed files with 48 additions and 40 deletions

View File

@@ -197,10 +197,14 @@ class RunTimeline extends HTMLElement {
addedOptimistic = true;
}
// auto-scroll solo si agregamos burbujas optimistas nuevas
if (addedOptimistic) {
// auto-scroll al final cuando hay mensajes nuevos
// Solo si el usuario estaba cerca del final (dentro de 150px) o si había optimistas
const wasNearBottom = this._lastScrollPosition === undefined ||
(log.scrollHeight - this._lastScrollPosition - log.clientHeight) < 150;
if (addedOptimistic || wasNearBottom) {
log.scrollTop = log.scrollHeight;
}
this._lastScrollPosition = log.scrollTop;
requestAnimationFrame(() => this.emitLayout());
this.bindScroll(log);
@@ -211,6 +215,7 @@ class RunTimeline extends HTMLElement {
if (this._scrollBound) return;
this._scrollBound = true;
log.addEventListener("scroll", () => {
this._lastScrollPosition = log.scrollTop;
emit("ui:chatScroll", { chat_id: this.chatId, scrollTop: log.scrollTop });
});
}