Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scroll bottom when generation text #4323

Merged
merged 5 commits into from
Dec 23, 2024
Merged

Conversation

urmauur
Copy link
Member

@urmauur urmauur commented Dec 23, 2024

Describe Your Changes

The changes in this Git diff can be summarized as follows:

  1. Use of requestAnimationFrame:

    • Removed the requestAnimationFrame calls from two places where scrolling is performed. This was used to schedule the scroll operation to occur optimally in the browser's next repaint cycle.
  2. Direct Scrolling:

    • The code now directly calls scrollTo on parentRef.current without wrapping it in a requestAnimationFrame. This may have been done to simplify the logic or because the timing provided by requestAnimationFrame wasn't necessary.
  3. Dependency Array Modifications in useEffect:

    • Added currentThread?.id to the dependency array of both useEffect hooks. This ensures that the effects are re-executed whenever currentThread?.id changes, which might be to ensure that the scrolling logic considers a change in the thread being viewed.
  4. Code Simplification:

    • The changes result in simpler effect logic by removing the additional requestAnimationFrame wrapping, under the assumption that immediate execution provides the desired behavior without visual issues like jank.

Overall, these changes simplify the scrolling logic in the ChatBody component by removing unnecessary scheduling of the scroll operation and making the effects more responsive to changes in the currentThread.

Fixes Issues

Self Checklist

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

@urmauur urmauur added the type: bug Something isn't working label Dec 23, 2024
@urmauur urmauur added this to the v0.5.12 milestone Dec 23, 2024
@urmauur urmauur requested a review from louis-jan December 23, 2024 09:05
@urmauur urmauur self-assigned this Dec 23, 2024
Copy link
Contributor

github-actions bot commented Dec 23, 2024

Barecheck - Code coverage report

Total: 68.66%

Your code coverage diff: -0.08% ▾

Uncovered files and lines
FileLines
web/screens/Thread/ThreadCenterPanel/ChatBody/index.tsx24-25, 27-28, 30, 34-35, 38-39, 41, 43, 47, 64-69, 71-72, 75-76, 81, 83-84, 88-91, 95-98, 102-105, 109-113, 117, 119, 124-126, 132, 134, 136-137, 139-141, 143-144, 148-150, 152, 189

Copy link
Contributor

@louis-jan louis-jan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

This is the build for this pull request. You can download it from the Artifacts section here: Build URL.

@louis-jan louis-jan merged commit 56d1ffa into main Dec 23, 2024
19 checks passed
@louis-jan louis-jan deleted the fix/scroll-bottom-regenerate branch December 23, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants