feat: scroll chat to bottom when user submits a new message#2
Closed
0xenzyme wants to merge 1 commit into
Closed
Conversation
Adds an explicit animated scroll-to-end call inside onSend, right after the optimistic user message is inserted and the transcript anchor state is reset. This ensures the user immediately sees their new message even if they were not already at the bottom of the transcript. Also updates TODO.md to mark this item complete.
jwangkun
requested changes
Jun 9, 2026
jwangkun
left a comment
Collaborator
There was a problem hiding this comment.
PR 审查报告
结论:需修改 ✗ 暂不可合并
审查摘要
| 维度 | 结果 | 说明 |
|---|---|---|
| 问题修复 | 现有 useEffect 在 transcriptMessageCount 变化时已处理滚动,理论上无需此修改 | |
| 代码规范 | ✗ bun.lock 有大问题 | registry URL 全部改为 npmmirror.com,锁文件完整性被破坏 |
| 与项目方向对齐 | 但 bun.lock + 无关格式化噪声污染了 PR |
详细分析
问题 1(阻塞):bun.lock registry URL 全部变更 ✗
- "@anthropic-ai/claude-agent-sdk": ["@anthropic-ai/claude-agent-sdk@0.2.112", "", { ...
+ "@anthropic-ai/claude-agent-sdk": ["@anthropic-ai/claude-agent-sdk@0.2.112", "https://registry.npmmirror.com/...", { ...bun.lock 中所有包的 registry URL 从 "" 被改为了 https://registry.npmmirror.com/...,共 1300+ 行。这是运行 bun install 时使用了非默认 registry 造成的,不属于 PR 的意图。此变更会破坏其他开发者的构建环境。必须还原到 main 分支版本。
问题 2(建议):3 个无关文件的纯格式化变更
ProviderHealth.ts— 纯换行格式变更BrowserPanel.tsx— 纯换行格式变更git.ts— 纯换行格式变更
与 PR 主题无关,属于 bun fmt 的适用范围,应移除或拆分为独立 PR。
问题 3(讨论):核心修改是否真的修复了问题?
当前代码(PR 前的 ChatView.tsx)中:
onSend在line 5567已设置isAtEndRef.current = trueuseEffect监听transcriptMessageCount(line 3955),变化时调用scrollToEnd(false)timelineMessages(line 2188)包含optimisticUserMessages,因此新消息会正确触发 count 变化
所以用户在滚动后发送消息时,流程是:
isAtEndRef.current = true → 状态更新 → useEffect 触发 → scrollToEnd(false)
现有代码理论上已经正确处理了该场景。 PR 添加的 requestAnimationFrame(() => scrollToEnd(true)) 并非 bugfix,而是一个额外行为(动画 & 更早的调度时机)。虽然无害,但建议 PR 描述中明确说明这是增强而非 修复。
合并前必须修复
- 还原
bun.lock到 main 版本(git checkout main -- bun.lock) - 移除
ProviderHealth.ts/BrowserPanel.tsx/git.ts的格式化变更(这些是 pre-existing 的 fmt 漂移)
按 AGENTS.md 要求,验证结果:
bun fmt:check✅bun typecheck✅bun lint✅bun run test✅(ChatMarkdown test 为 pre-existing 问题)
Collaborator
PR Closed — Stale\n\nHi @0xenzyme, thank you for your contribution.\n\nThis PR has been closed because PR is unvouched and oversized (XXL) per project guidelines.\n\n### Next steps\n- If you'd like to continue working on this, please address the review feedback and re-open the PR or open a new one.\n- For new features, please start a Discussion first to align with the project direction.\n- Keep PRs small, focused, and well-described per our template.\n\nFeel free to reach out if you have questions! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an explicit animated scroll-to-end call inside "onSend" so the chat transcript scrolls to the bottom immediately when a user submits a new message.
Why
Previously, scrolling to the bottom after sending a message relied on the "transcriptMessageCount" useEffect firing only when the user was already at the end of the transcript. If the user scrolled up and then sent a message, the transcript would stay out of view. This change makes the scroll explicit and immediate.
How
Verification