From d3cff3e9238228c98b6de09c7f6c08ffc5b1e343 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 2 Sep 2026 11:02:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(AgentIO):=20=E8=B7=9F=E6=BB=9A=E8=AF=AF?= =?UTF-8?q?=E5=85=B3=E6=A0=B9=E6=B2=BB=E2=80=94=E2=80=94=5Ftrack=5Ffollow?= =?UTF-8?q?=E6=8C=89scrollTop=E5=87=8F=E5=B0=8F=E5=88=A4=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8A=E7=BF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 旧实现按gap判follow:异步widget挂载使scroll事件滞后,程序滚底后gap瞬时>80 被误判为用户上翻→follow关→第二条消息后输出不再跟滚 --- bricks/agent.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bricks/agent.js b/bricks/agent.js index cdaaef6..cbe4b39 100644 --- a/bricks/agent.js +++ b/bricks/agent.js @@ -357,7 +357,20 @@ bricks.AgentIO = class extends bricks.VBox { _track_follow(){ var e = this.msg_box && this.msg_box.dom_element; if (!e) return; - this._follow = (e.scrollHeight - e.scrollTop - e.clientHeight) < 80; + var st = e.scrollTop; + var near = (e.scrollHeight - st - e.clientHeight) < 80; + if (near) { + // 滚回底部附近 → 恢复跟滚 + this._follow = true; + } else if (this._last_st !== undefined && st < this._last_st - 5) { + // scrollTop 减小 = 用户真上翻 → 暂停跟滚。 + // 程序滚底只会增大 scrollTop;异步 widget 挂载使 scroll 事件滞后时 + // gap 会瞬时 >80,但 st 不减小——不能误判为用户上翻(2026-09-01 根因: + // 旧实现按 gap 判 follow,第二条消息后程序滚底被自己的 scroll 事件 + // 误关 follow,后续输出不再跟滚)。 + this._follow = false; + } + this._last_st = st; } chunk_response(mout, l){ l = l.trim();