Skip to content

fix: scroll to bottom when sending a message while scrolled up#314

Open
mschead wants to merge 1 commit intomainfrom
worktree-unnecessary-scroll
Open

fix: scroll to bottom when sending a message while scrolled up#314
mschead wants to merge 1 commit intomainfrom
worktree-unnecessary-scroll

Conversation

@mschead
Copy link
Contributor

@mschead mschead commented Mar 23, 2026

Call scrollToBottom({ force: true }) before handleSubmit when the user is scrolled up. This synchronously sets isAtBottom = true and starts a smooth animation, so the library's own ResizeObserver picks up the new content height naturally — no custom observer or ref signal needed.

Summary by CodeRabbit

  • Bug Fixes
    • Improved chat auto-scrolling behavior to ensure the message list scrolls to the bottom when submitting new messages, enhancing visibility across desktop and mobile interfaces.

Call scrollToBottom({ force: true }) before handleSubmit when the user
is scrolled up. This synchronously sets isAtBottom = true and starts a
smooth animation, so the library's own ResizeObserver picks up the new
content height naturally — no custom observer or ref signal needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hackerai Ready Ready Preview, Comment Mar 23, 2026 10:19pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b09627f6-c840-49d9-b27e-cb611ccb0b3c

📥 Commits

Reviewing files that changed from the base of the PR and between c07da20 and e78b93c.

📒 Files selected for processing (1)
  • app/components/chat.tsx

📝 Walkthrough

Walkthrough

A memoized submit handler handleSubmitWithScroll was introduced in the chat component that automatically scrolls to the bottom of the message list when a user submits a message, then delegates to the existing submit handler. Both ChatInput components now utilize this new handler.

Changes

Cohort / File(s) Summary
Chat Submit Handler Enhancement
app/components/chat.tsx
Added handleSubmitWithScroll memoized callback that forces scroll-to-bottom on form submission before delegating to existing handleSubmit. Updated both ChatInput usages to reference the new handler.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A little hop, a scroll divine,
Messages stack in perfect line,
Submit the thought, down we glide,
No need to chase what's far and wide!
Smooth as lettuce, swift as breeze, 🌬️
Chat flows easy, sure to please!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding automatic scroll-to-bottom functionality when sending messages while scrolled up, which is the core modification in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-unnecessary-scroll

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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