v2 工作台:上滚看历史后发消息不会拽回最新(旧屏 #925 ③ 的行为丢了)
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 7m
- Merged PRs (30d)
- 969
Description
## 现象
在 v2 工作台里,用户上滚看历史之后**发一条新消息,视图不会回到最新**——新消息发出去了,但屏幕还停在历史那一段,用户看不到自己刚发的内容,也看不到回复。
旧屏不是这样:`#925 ③` 是一条明确的产品决定——**发送 = 显式意图,无条件把视图拽回底部**(覆盖"尊重用户上滚、不打断阅读"那条默认规则)。
## 取证
`apps/web/lib/chat-workbench/use-timeline-scroll.ts`:
- 自动跟随的 effect 第一行就是 `if (!isAtBottom) return;` —— 用户上滚过就不再跟随(这条本身是对的,Slack/Discord 同款纪律)。
- `scrollMessagesToBottom()` 是唯一能把 `isAtBottom` 重新置真的出口,全仓只有两个调用点:
- `copilotkit-v2-panel-body.tsx:1586` —— 「回到最新」悬浮按钮的 `onClick`
- `use-timeline-scroll.ts:150` —— `Ctrl/Cmd+End` 快捷键
- **`send()`(`copilotkit-v2-panel-body.tsx:1162`)从不调用它。**
真栈实测(2026-09-08,`chat-read` 车道):上滚到顶 → 发一条消息 → 轮询 30s,
`scrollHeight - scrollTop - clientHeight` 始终是 **3766px**(判据要求 ≤ 80px)。
## 用户会失去什么
翻历史的时候想起来要补一句,打完发出去——屏幕不动。用户以为没发出去,或者要自己再滚回底部才能看到回复。这在长对话里几乎每次都会撞到。
## 建议修法
在 `send()` 成功入队后调一次 `scrollMessagesToBottom("auto")`(与「回到最新」按钮同一个出口,不新造机制)。这正是旧屏 `#925 ③` 的语义。
## 相关
issue #2997。断言原文(`apps/web/e2e/chat-read.spec.ts` 的
「#925 ③ 发送后强制滚到底:即使之前上滚看历史,发送也拽回最新」)保留为 `test.fixme`,未删、未改宽。
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in apps/web/lib/chat-workbench/use-timeline-scroll.ts and apps/web/.../copilotkit-v2-panel-body.tsx, reading scrollMessagesToBottom and the send() path. Run the assertion in apps/web/e2e/chat-read.spec.ts for #925 ③. Done means sending after scrolling up returns the view to the bottom and the existing test no longer needs test.fixme.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100