@@ -75,6 +75,7 @@ export function SessionTurn(
7575
7676 let scrollRef : HTMLDivElement | undefined
7777 const [ state , setState ] = createStore ( {
78+ contentRef : undefined as HTMLDivElement | undefined ,
7879 stickyTitleRef : undefined as HTMLDivElement | undefined ,
7980 stickyTriggerRef : undefined as HTMLDivElement | undefined ,
8081 userScrolled : false ,
@@ -101,10 +102,18 @@ export function SessionTurn(
101102 function scrollToBottom ( ) {
102103 if ( ! scrollRef || state . userScrolled || ! working ( ) ) return
103104 requestAnimationFrame ( ( ) => {
104- scrollRef ?. scrollTo ( { top : scrollRef . scrollHeight , behavior : "instant " } )
105+ scrollRef ?. scrollTo ( { top : scrollRef . scrollHeight , behavior : "smooth " } )
105106 } )
106107 }
107108
109+ createResizeObserver (
110+ ( ) => state . contentRef ,
111+ ( { height } ) => {
112+ console . log ( height )
113+ scrollToBottom ( )
114+ } ,
115+ )
116+
108117 createEffect ( ( ) => {
109118 if ( ! working ( ) ) {
110119 setState ( "userScrolled" , false )
@@ -232,11 +241,6 @@ export function SessionTurn(
232241 } )
233242 }
234243
235- createEffect ( ( ) => {
236- lastPart ( )
237- scrollToBottom ( )
238- } )
239-
240244 const [ store , setStore ] = createStore ( {
241245 status : rawStatus ( ) ,
242246 stepsExpanded : props . stepsExpanded ?? working ( ) ,
@@ -296,6 +300,7 @@ export function SessionTurn(
296300
297301 return (
298302 < div
303+ ref = { ( el ) => setState ( "contentRef" , el ) }
299304 data-message = { message ( ) . id }
300305 data-slot = "session-turn-message-container"
301306 class = { props . classes ?. container }
0 commit comments