Skip to content

Conversation

Louis454545
Copy link
Contributor

@Louis454545 Louis454545 commented Aug 16, 2025

Describe Your Changes

  • Fixed scroll position jumping issue when AI completes response while user is reading in the middle of the conversation
  • Added tracking of user's intended scroll position during streaming
  • Implemented logic to restore user's reading position when streaming completes instead of auto-scrolling to bottom
  • Preserved existing auto-scroll behavior when user is genuinely at the bottom

Fixes Issues

Technical Implementation

  • Added userIntendedPositionRef to track where user deliberately scrolls during streaming
  • Added wasStreamingRef to detect streaming completion transitions
  • Modified scroll handlers to record user's position when they scroll away from bottom during streaming
  • Updated auto-scroll effect to restore intended position when streaming ends
  • Used smooth scrolling for position restoration to provide better UX

Testing

The fix addresses the exact reproduction steps from the issue:

  1. Ask AI a question that generates a long response
  2. While AI is generating, scroll to middle of the response to read
  3. When AI completes, scroll position now stays at user's reading position instead of jumping to top

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

🤖 Generated with Claude Code


Important

Fixes scroll position jump by tracking and restoring user's intended scroll position during AI response streaming in ThreadDetail.

  • Behavior:
    • Prevents scroll position jump when AI completes response while user is reading.
    • Tracks user's intended scroll position during streaming and restores it when streaming ends.
    • Maintains auto-scroll behavior when user is at the bottom.
  • Implementation:
    • Adds userIntendedPositionRef and wasStreamingRef in ThreadDetail to track user scroll position and streaming state.
    • Modifies scroll handlers to record user's position when scrolling away from bottom during streaming.
    • Updates auto-scroll effect to restore intended position with smooth scrolling when streaming ends.
  • Testing:
    • Fix verified by reproducing issue steps: asking AI a question, scrolling to read, and ensuring position is maintained when AI completes.

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

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 9462aaf in 1 minute and 35 seconds. Click for details.
  • Reviewed 86 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. web-app/src/routes/threads/$threadId.tsx:157
  • Draft comment:
    The check to clear the intended scroll position (if streaming starts) is unreachable because wasStreamingRef is updated immediately before. Consider storing the previous streaming state (e.g. using a temp variable) before updating wasStreamingRef, then use that in the condition.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. web-app/src/routes/threads/$threadId.tsx:143
  • Draft comment:
    Using a fixed 100ms delay in the setTimeout for DOM updates might be fragile. Consider a more robust approach (e.g. requestAnimationFrame or a MutationObserver) to ensure the DOM is updated before scrolling.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50% None

Workflow ID: wflow_G34SO29VJT4vxTnd

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

…er reading

- Add userIntendedPositionRef to track user's deliberate scroll position during streaming
- Add wasStreamingRef to detect when streaming finishes
- Preserve user's reading position when they scroll away from bottom during AI response
- Restore intended position with smooth scroll when streaming completes
- Reset position tracking on thread changes and component initialization

Fixes menloresearch#5939

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@urmauur urmauur force-pushed the fix/scroll-jump-during-streaming-5939 branch from 9462aaf to ecc9020 Compare August 20, 2025 03:24
@urmauur
Copy link
Member

urmauur commented Aug 20, 2025

LGTM

@louis-menlo louis-menlo merged commit c3b043e into menloresearch:dev Aug 20, 2025
16 checks passed
@github-project-automation github-project-automation bot moved this to QA in Jan Aug 20, 2025
@Louis454545 Louis454545 deleted the fix/scroll-jump-during-streaming-5939 branch August 20, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: QA
Development

Successfully merging this pull request may close these issues.

bug: Scroll position jumps up when the text is completed and the scroll position not on bottom.
3 participants