Skip to content

fix: 修复聊天发送后向上滚动的 Bug#124

Open
ErlichLiu wants to merge 1 commit intomainfrom
ErlichLiu/fix-scroll-on-send
Open

fix: 修复聊天发送后向上滚动的 Bug#124
ErlichLiu wants to merge 1 commit intomainfrom
ErlichLiu/fix-scroll-on-send

Conversation

@ErlichLiu
Copy link
Owner

Summary

修复了 Chat 和 Agent 模式中,发送消息后会向上滚动的 UI Bug。

问题分析

cv-ready CSS 类控制 content-visibility: auto 优化的启用。当流式生成停止时,该类被重新应用,导致浏览器重新计算消息尺寸。即使使用 contain-intrinsic-size: auto 缓存尺寸,class 的反复切换也会触发布局抖动,scroll 位置微移 1px 足以让 StickToBottom 误认为用户主动滚动而解除粘性,后续新消息不再自动滚动到底部。

解决方案

移除对 streaming 状态的依赖,始终应用 cv-ready 类。由于流式消息元素没有 data-message-id,不受 content-visibility: auto 影响,而历史消息的尺寸缓存保持稳定,避免重复的布局重算。

修改文件

  • apps/electron/src/renderer/components/chat/ChatMessages.tsx(L294)
  • apps/electron/src/renderer/components/agent/AgentMessages.tsx(L624)

`cv-ready` CSS 类触发 `content-visibility: auto` 的切换,当流式结束时重新应用该类会导致布局重算和滚动位置微移(1px),使得 StickToBottom 错误地认为用户主动滚动而解除粘性,导致新消息到达时不自动滚动到底部。现在始终应用 cv-ready 以保持稳定的尺寸缓存,避免重复的布局抖动。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant