Skip to content

PRD-2153: Allow user to scroll up while response is generating#44

Merged
veliseev93 merged 3 commits intodevelopmentfrom
PRD-2153-modify-auto-scroll-behavior
Feb 19, 2026
Merged

PRD-2153: Allow user to scroll up while response is generating#44
veliseev93 merged 3 commits intodevelopmentfrom
PRD-2153-modify-auto-scroll-behavior

Conversation

@Tomass673
Copy link
Copy Markdown
Collaborator

@Tomass673 Tomass673 assigned Tomass673 and veliseev93 and unassigned Tomass673 Feb 6, 2026
renderItem={renderItem}
// TODO: Add autoscrollToBottom logic when it implemented in lib
maintainVisibleContentPosition={{
startRenderingFromBottom: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Without this condition, the chat starts rendering from top to bottom, could you please fix it?

Image

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@veliseev93 veliseev93 assigned Tomass673 and unassigned veliseev93 Feb 11, 2026
@Tomass673 Tomass673 assigned veliseev93 and unassigned Tomass673 Feb 11, 2026
Copy link
Copy Markdown
Contributor

@veliseev93 veliseev93 left a comment

Choose a reason for hiding this comment

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

@Tomass673 I left a few suggestions on how to improve gesture interception during auto-scrolling at the bottom - could you please check them out?

const isScrollToBottomVisible = useSharedValue(0);
const previousScrollY = useRef(0);
const [autoscrollToBottomThreshold, setAutoscrollToBottomThreshold] = useState<number | undefined>(1);
const isNearBottomRef = useRef(true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
const isNearBottomRef = useRef(true);
const shouldAutoscrollToBottomRef = useRef(true);
const touchStartY = useRef(0);

isScrollToBottomAvailable.current = true;
}, 500);

if (isNearBottomRef.current && listRef.current && messages?.length > 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (isNearBottomRef.current && listRef.current && messages?.length > 0) {
if (shouldAutoscrollToBottomRef.current) {
requestAnimationFrame(() => {
listRef.current?.scrollToEnd({ animated: true });
});
}

return (
<View className='relative flex-1'>
<AppFlashList<Message>
ref={listRef}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
ref={listRef}
onTouchStart={(e) => {
touchStartY.current = e.nativeEvent.pageY;
shouldAutoscrollToBottomRef.current = false;
}}
onTouchEnd={(e) => {
const deltaY = e.nativeEvent.pageY - touchStartY.current;
if (deltaY < 20) {
shouldAutoscrollToBottomRef.current = true;
}
}}

@Tomass673
Copy link
Copy Markdown
Collaborator Author

@Tomass673 I left a few suggestions on how to improve gesture interception during auto-scrolling at the bottom - could you please check them out?

It works mostly fine on iOS (though still a bit flaky), but it doesn’t work on Android at all.

When the user scrolls up during response generation and then scrolls back down to the bottom, shouldAutoscrollToBottomRef never switches back to true.

Your suggested approach relies on onTouchStart and onTouchEnd events, but they are not triggered reliably on Android

@veliseev93
Copy link
Copy Markdown
Contributor

@Tomass673 I left a few suggestions on how to improve gesture interception during auto-scrolling at the bottom - could you please check them out?

It works mostly fine on iOS (though still a bit flaky), but it doesn’t work on Android at all.

When the user scrolls up during response generation and then scrolls back down to the bottom, shouldAutoscrollToBottomRef never switches back to true.

Your suggested approach relies on onTouchStart and onTouchEnd events, but they are not triggered reliably on Android

We can use similar callbacks like this:

        onTouchStart={(e) => {
          if (isResponseGenerating) {
            shouldAutoscrollToBottomRef.current = false;
            previousTouchY.current = e.nativeEvent.pageY;
          }
        }}
        onTouchMove={(e) => {
          const currentY = e.nativeEvent.pageY;
          const deltaY = currentY - previousTouchY.current;

          previousTouchY.current = currentY;
          shouldAutoscrollToBottomRef.current = deltaY < 0;
        }}

It works on both platforms:

Test.mov

@veliseev93 veliseev93 assigned Tomass673 and unassigned veliseev93 Feb 19, 2026
@Tomass673
Copy link
Copy Markdown
Collaborator Author

@Tomass673 I left a few suggestions on how to improve gesture interception during auto-scrolling at the bottom - could you please check them out?

It works mostly fine on iOS (though still a bit flaky), but it doesn’t work on Android at all.
When the user scrolls up during response generation and then scrolls back down to the bottom, shouldAutoscrollToBottomRef never switches back to true.
Your suggested approach relies on onTouchStart and onTouchEnd events, but they are not triggered reliably on Android

We can use similar callbacks like this:

        onTouchStart={(e) => {
          if (isResponseGenerating) {
            shouldAutoscrollToBottomRef.current = false;
            previousTouchY.current = e.nativeEvent.pageY;
          }
        }}
        onTouchMove={(e) => {
          const currentY = e.nativeEvent.pageY;
          const deltaY = currentY - previousTouchY.current;

          previousTouchY.current = currentY;
          shouldAutoscrollToBottomRef.current = deltaY < 0;
        }}

It works on both platforms:

Test.mov

@Tomass673 I left a few suggestions on how to improve gesture interception during auto-scrolling at the bottom - could you please check them out?

It works mostly fine on iOS (though still a bit flaky), but it doesn’t work on Android at all.
When the user scrolls up during response generation and then scrolls back down to the bottom, shouldAutoscrollToBottomRef never switches back to true.
Your suggested approach relies on onTouchStart and onTouchEnd events, but they are not triggered reliably on Android

We can use similar callbacks like this:

        onTouchStart={(e) => {
          if (isResponseGenerating) {
            shouldAutoscrollToBottomRef.current = false;
            previousTouchY.current = e.nativeEvent.pageY;
          }
        }}
        onTouchMove={(e) => {
          const currentY = e.nativeEvent.pageY;
          const deltaY = currentY - previousTouchY.current;

          previousTouchY.current = currentY;
          shouldAutoscrollToBottomRef.current = deltaY < 0;
        }}

It works on both platforms:

Test.mov

Now it works fine on both platforms indeed. Thank you!

@Tomass673 Tomass673 assigned veliseev93 and unassigned Tomass673 and veliseev93 Feb 19, 2026
@veliseev93 veliseev93 merged commit cdde996 into development Feb 19, 2026
1 check passed
@veliseev93 veliseev93 deleted the PRD-2153-modify-auto-scroll-behavior branch February 19, 2026 10:21
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