Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 12, 2025

Summary

This PR fixes the scrollbar auto-scroll issue where the conversation window would jump up during API activities and not stay at the bottom, especially in longer conversations.

Problem

  • Scrollbar was jumping up to earlier parts of the conversation during API activities
  • Auto-scroll was being disabled inappropriately during streaming
  • Users couldn't see the latest messages without manually scrolling down repeatedly

Solution

  • Keep auto-scroll enabled during streaming unless user explicitly scrolls up
  • Prevent disabling auto-scroll when expanding rows during streaming
  • Improve scroll-to-bottom logic to better handle API activities
  • Don't disable auto-scroll during streaming even if near bottom

Changes Made

  1. Modified the auto-scroll effect to always scroll during streaming unless explicitly disabled
  2. Updated the row expansion effect to not disable auto-scroll during streaming
  3. Enhanced the wheel event handler to be more intelligent about when to disable auto-scroll
  4. Improved the atBottomStateChange handler to keep auto-scroll enabled during streaming

Testing

  • Tested with long conversations to ensure scrollbar stays at bottom
  • Verified that manual scrolling up still works and disables auto-scroll appropriately
  • Confirmed that auto-scroll resumes when user scrolls back to bottom
  • Tested during API activities and streaming to ensure smooth behavior

Fixes #6987


Important

Fixes auto-scroll behavior in ChatView.tsx to remain at the bottom during streaming and API activities unless user scrolls up.

  • Behavior:
    • Keeps auto-scroll enabled during streaming unless user scrolls up in ChatView.tsx.
    • Prevents disabling auto-scroll when expanding rows during streaming.
    • Enhances scroll-to-bottom logic to handle API activities better.
    • Ensures auto-scroll is not disabled during streaming even if near bottom.
  • Functions:
    • Modifies useEffect to prevent disabling auto-scroll during streaming when rows are expanded.
    • Updates handleWheel to avoid disabling auto-scroll during streaming if near bottom.
    • Adjusts atBottomStateChange to maintain auto-scroll during streaming.
  • Testing:
    • Tested with long conversations to ensure scrollbar stays at bottom.
    • Verified manual scrolling up disables auto-scroll appropriately.
    • Confirmed auto-scroll resumes when user scrolls back to bottom.
    • Tested during API activities and streaming for smooth behavior.

This description was created by Ellipsis for 0c3a8ba. You can customize this summary. It will automatically update as commits are pushed.

- Keep auto-scroll enabled during streaming unless user explicitly scrolls up
- Prevent disabling auto-scroll when expanding rows during streaming
- Improve scroll-to-bottom logic to handle API activities better
- Fix issue where scrollbar jumps up during long conversations

Fixes #6987
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 12, 2025 13:26
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Aug 12, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like debugging in production - technically possible but morally questionable.

if (wheelEvent.deltaY && wheelEvent.deltaY < 0) {
if (scrollContainerRef.current?.contains(wheelEvent.target as Node)) {
// User scrolled up - but don't disable during streaming if we're near bottom
if (!isStreaming || !isAtBottom) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? The isAtBottom state might not be immediately updated when checking in the wheel handler, potentially causing a race condition. Consider using a ref or checking the scroll position directly to avoid stale state issues.

disableAutoScrollRef.current = false
}
// During streaming, always keep auto-scroll enabled unless user explicitly scrolled
if (isStreaming && isAtBottom) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This second condition checking isStreaming && isAtBottom appears redundant since if isAtBottom is true, we just set disableAutoScrollRef.current = false on line 1886. Could we simplify this logic?

disableAutoScrollRef.current = false
}
// During streaming, always keep auto-scroll enabled unless user explicitly scrolled
if (isStreaming && isAtBottom) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment here explaining why auto-scroll behaves differently during streaming. Something like:

let timer: ReturnType<typeof setTimeout> | undefined
if (!disableAutoScrollRef.current) {
// Always scroll to bottom during streaming unless user explicitly scrolled up
if (!disableAutoScrollRef.current || isStreaming) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to auto-scroll logic during streaming are significant. Have we considered adding test coverage for this new behavior? It would help ensure the fix works correctly across different scenarios.

}

// Don't disable auto-scroll during streaming even if rows are expanded
if (wasAnyRowExpandedByUser && !isStreaming) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future maintainability, consider extracting the auto-scroll logic into a custom hook like useAutoScroll. This would centralize the complex conditions and make the behavior easier to test and understand.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 12, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Aug 13, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 13, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Draft / In Progress] in Roo Code Roadmap Aug 13, 2025
@daniel-lxs daniel-lxs marked this pull request as draft August 13, 2025 20:06
@daniel-lxs
Copy link
Member

Closing this PR as the issue has been resolved in PR #7064 which removed the 500-message limit that was causing the scrollbar jumping. The fix has been merged to main. Let me know if you notice this issue again!

@daniel-lxs daniel-lxs closed this Aug 14, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft / In Progress] to Done in Roo Code Roadmap Aug 14, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Draft / In Progress size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Scrollbar does not stay scrolled to the bottom of the RooCode window

4 participants