Skip to content

Fix chat auto-scroll during streaming responses#928

Merged
MaheshtheDev merged 4 commits into
mainfrom
fix/chat-autoscroll
May 11, 2026
Merged

Fix chat auto-scroll during streaming responses#928
MaheshtheDev merged 4 commits into
mainfrom
fix/chat-autoscroll

Conversation

@ved015
Copy link
Copy Markdown
Member

@ved015 ved015 commented May 11, 2026

Summary

Fixed the chat interface to automatically scroll down as the AI model streams its response. Previously, the chat only scrolled when the user sent a message, but not when the assistant's response was being generated.

Changes Made

  • Added a useEffect hook to detect when streaming status changes and scroll to bottom
  • Added a MutationObserver to detect DOM content changes during streaming and auto-scroll in real-time
  • auto-scrolling only happens when isScrolledToBottom is true so if user is up and reading his previous message he doesnt go all the way down

Checked on local

Screen.Recording.2026-05-11.at.9.05.41.PM.mov

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 11, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
supermemory-mcp 1c03660 May 11 2026, 04:03 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 11, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
supermemory-app 1c03660 Commit Preview URL

Branch Preview URL
May 11 2026, 04:04 PM

@claude
Copy link
Copy Markdown

claude Bot commented May 11, 2026

Claude finished @ved015's task in 1m 16s —— View job


Review: PR #928 - Fix chat auto-scroll during streaming responses

  • Analyze PR diff and understand the changes
  • Review surrounding code for context
  • Check for bugs, security issues, or logic errors
  • Submit review feedback

Overview: Adds auto-scroll behavior during AI response streaming using a ref to track scroll position and a MutationObserver to detect DOM changes.

Issues found: None — this looks good to ship.

The implementation is solid:

  • Uses isScrolledToBottomRef to avoid stale closure issues — reading state in callbacks would give stale values, but refs provide the current value immediately
  • MutationObserver properly cleans up in the effect's return function
  • Auto-scroll is correctly gated on isScrolledToBottomRef.current so users reading earlier messages won't be interrupted
  • requestAnimationFrame ensures smooth scrolling without layout thrashing
  • Dependency arrays are correct — the MutationObserver effect intentionally omits messages since it watches DOM changes directly

Score: 10/10

@ved015 ved015 requested a review from MaheshtheDev May 11, 2026 15:24
@MaheshtheDev MaheshtheDev merged commit bb50685 into main May 11, 2026
7 of 8 checks passed
@graphite-app graphite-app Bot requested a review from Dhravya May 13, 2026 11:05
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.

2 participants