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 to bottom issue #4289

Merged
merged 1 commit into from
Dec 19, 2024
Merged

fix: scroll to bottom issue #4289

merged 1 commit into from
Dec 19, 2024

Conversation

urmauur
Copy link
Member

@urmauur urmauur commented Dec 18, 2024

Describe Your Changes

  1. TypeScript Type Annotation: The useRef hook for parentRef is updated from useRef(null) to useRef<HTMLDivElement>(null), providing a type annotation to specify that the ref should point to a HTMLDivElement.

  2. New State Addition: A new state currentThread is introduced, which uses the useAtomValue hook to retrieve the value from activeThreadAtom.

  3. Refactoring useEffect Hook:

    • The existing useEffect hook is refactored to:
      • Remove the check for isUserManuallyScrollingUp and !parentRef.current.
      • Add a requestAnimationFrame call to delay scrolling until the DOM updates. This ensures smoother behavior when scrolling to the last index of messages.
      • Update the dependencies of the useEffect to include currentThread?.id and remove unused dependencies like messages, loadModelError, and isUserManuallyScrollingUp.
  4. Removed Logical Checks: The logical checks within the previous useEffect have been refactored to ensure the scroll actions are executed efficiently in the newly structured useEffect.

Fixes Issues

Screen.Recording.2024-12-18.at.13.20.27.mov

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 18, 2024
@urmauur urmauur added this to the v0.5.12 milestone Dec 18, 2024
@urmauur urmauur requested a review from louis-menlo December 18, 2024 06:26
@urmauur urmauur self-assigned this Dec 18, 2024
Copy link
Contributor

@louis-menlo louis-menlo 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.

Copy link
Contributor

Barecheck - Code coverage report

Total: 69.07%

Your code coverage diff: -0.03% ▾

Uncovered files and lines
FileLines
web/screens/Thread/ThreadCenterPanel/ChatBody/index.tsx20-21, 23-24, 26, 30-31, 34-35, 37, 39, 43, 60-63, 65-66, 71, 73-74, 78, 80-84, 90, 92, 97-98, 104-105, 107-108, 110-112, 114-115, 119-121, 123, 158

@urmauur urmauur merged commit 8663a7e into dev Dec 19, 2024
21 checks passed
@urmauur urmauur deleted the fix/scroll-bottom-issue branch December 19, 2024 03:35
@louis-menlo
Copy link
Contributor

Fixed #4292

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.

bug: If I scroll up it keeps autoscrolling so I have to fight with it or wait for it to finish
2 participants