@@ -362,39 +362,6 @@ export function ChatPage({
362
362
}
363
363
} , [ setMessage , setCurrentMessageFiles ] ) ;
364
364
365
- const clientScrollToBottom = useCallback ( ( fast ?: boolean ) => {
366
- waitForScrollRef . current = true ;
367
-
368
- setTimeout ( ( ) => {
369
- if ( ! endDivRef . current || ! scrollableDivRef . current ) {
370
- console . error ( "endDivRef or scrollableDivRef not found" ) ;
371
- return ;
372
- }
373
-
374
- const rect = endDivRef . current . getBoundingClientRect ( ) ;
375
- const isVisible = rect . top >= 0 && rect . bottom <= window . innerHeight ;
376
-
377
- if ( isVisible ) return ;
378
-
379
- // Check if all messages are currently rendered
380
- // If all messages are already rendered, scroll immediately
381
- endDivRef . current . scrollIntoView ( {
382
- behavior : fast ? "auto" : "smooth" ,
383
- } ) ;
384
-
385
- if ( chatSessionIdRef . current ) {
386
- useChatSessionStore
387
- . getState ( )
388
- . updateHasPerformedInitialScroll ( chatSessionIdRef . current , true ) ;
389
- }
390
- } , 50 ) ;
391
-
392
- // Reset waitForScrollRef after 1.5 seconds
393
- setTimeout ( ( ) => {
394
- waitForScrollRef . current = false ;
395
- } , 1500 ) ;
396
- } , [ ] ) ;
397
-
398
365
const debounceNumber = 100 ; // time for debouncing
399
366
400
367
// handle re-sizing of the text area
@@ -490,6 +457,40 @@ export function ChatPage({
490
457
( state ) => state . updateCurrentChatSessionSharedStatus
491
458
) ;
492
459
460
+ const clientScrollToBottom = useCallback (
461
+ ( fast ?: boolean ) => {
462
+ waitForScrollRef . current = true ;
463
+
464
+ setTimeout ( ( ) => {
465
+ if ( ! endDivRef . current || ! scrollableDivRef . current ) {
466
+ console . error ( "endDivRef or scrollableDivRef not found" ) ;
467
+ return ;
468
+ }
469
+
470
+ const rect = endDivRef . current . getBoundingClientRect ( ) ;
471
+ const isVisible = rect . top >= 0 && rect . bottom <= window . innerHeight ;
472
+
473
+ if ( isVisible ) return ;
474
+
475
+ // Check if all messages are currently rendered
476
+ // If all messages are already rendered, scroll immediately
477
+ endDivRef . current . scrollIntoView ( {
478
+ behavior : fast ? "auto" : "smooth" ,
479
+ } ) ;
480
+
481
+ if ( chatSessionIdRef . current ) {
482
+ updateHasPerformedInitialScroll ( chatSessionIdRef . current , true ) ;
483
+ }
484
+ } , 50 ) ;
485
+
486
+ // Reset waitForScrollRef after 1.5 seconds
487
+ setTimeout ( ( ) => {
488
+ waitForScrollRef . current = false ;
489
+ } , 1500 ) ;
490
+ } ,
491
+ [ updateHasPerformedInitialScroll ]
492
+ ) ;
493
+
493
494
const { onSubmit, stopGenerating, handleMessageSpecificFileUpload } =
494
495
useChatController ( {
495
496
filterManager,
0 commit comments