From 26aad5712a9c87f7e6f1d92c94a2a027dcc93b96 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 1 Sep 2026 18:11:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(AgentIO):=20=E6=BB=9A=E5=BA=95=E6=94=B9?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E2=80=94=E2=80=94=E5=90=8E=E5=8F=B0tab?= =?UTF-8?q?=E4=B8=8D=E8=A7=A6=E5=8F=91rAF=E5=AF=BC=E8=87=B4=E6=B5=81?= =?UTF-8?q?=E5=BC=8F=E6=9B=B4=E6=96=B0=E6=97=B6=E4=B8=8D=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bricks/agent.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/bricks/agent.js b/bricks/agent.js index 1a3b1a7..55ea074 100644 --- a/bricks/agent.js +++ b/bricks/agent.js @@ -332,21 +332,17 @@ bricks.AgentIO = class extends bricks.VBox { } // 会话区保持最后输出可见(2026-09-01):内容超出显示范围时自动滚到底。 // 仅当用户本就停在底部附近才跟滚——用户主动上翻看历史时不强行拉回; - // 滚回底部或发送新消息后恢复跟滚。rAF 延迟到本帧布局完成后滚, - // 保证 scrollHeight 已是新内容的尺寸(同步滚会拿到旧高度)。 + // 滚回底部或发送新消息后恢复跟滚。 + // 同步滚:读 scrollHeight 本身强制布局,拿到的是新内容尺寸; + // 不用 rAF(后台 tab 不触发 rAF,流式更新时不滚)。 scroll_to_bottom(){ - if (this._scroll_pending) return; - this._scroll_pending = true; - requestAnimationFrame(function(){ - this._scroll_pending = false; - var e = this.msg_box && this.msg_box.dom_element; - if (!e) return; - if (this._follow === false) { - var near_bottom = (e.scrollHeight - e.scrollTop - e.clientHeight) < 80; - if (!near_bottom) return; - } - e.scrollTop = e.scrollHeight; - }.bind(this)); + var e = this.msg_box && this.msg_box.dom_element; + if (!e) return; + if (this._follow === false) { + var near_bottom = (e.scrollHeight - e.scrollTop - e.clientHeight) < 80; + if (!near_bottom) return; + } + e.scrollTop = e.scrollHeight; } _track_follow(){ var e = this.msg_box && this.msg_box.dom_element;