@@ -193,15 +193,19 @@ function SessionWorkbench(props: {
193193 return el . scrollHeight - el . scrollTop - el . clientHeight < 100 ;
194194 } ;
195195
196- const virtualizer = createVirtualizer ( {
197- get count ( ) {
198- const v = view ( ) ;
199- if ( ! v ) return 0 ;
200- return v . timeline . length + ( busy ( ) ? 1 : 0 ) ;
201- } ,
202- getScrollElement : ( ) => scrollContainer ( ) ,
203- estimateSize : ( ) => 100 , // Reasonable default for a timeline item
204- overscan : 10 ,
196+ const virtualizer = createMemo ( ( ) => {
197+ const el = scrollContainer ( ) ;
198+ if ( ! el ) return null ;
199+ return createVirtualizer ( {
200+ get count ( ) {
201+ const v = view ( ) ;
202+ if ( ! v ) return 0 ;
203+ return v . timeline . length + ( busy ( ) ? 1 : 0 ) ;
204+ } ,
205+ getScrollElement : ( ) => el ,
206+ estimateSize : ( ) => 100 , // Reasonable default for a timeline item
207+ overscan : 10 ,
208+ } ) ;
205209 } ) ;
206210
207211 const sendInput = async ( ) => {
@@ -260,7 +264,7 @@ function SessionWorkbench(props: {
260264 { ( sessionView ) => {
261265 return (
262266 < div class = { css ( { maxW : '760px' , w : 'full' , mx : 'auto' , display : 'flex' , flexDir : 'column' , gap : '32px' , pb : '64px' } ) } >
263- < Show when = { scrollContainer ( ) } fallback = {
267+ < Show when = { virtualizer ( ) } fallback = {
264268 // Fallback before virtualizer initializes/mounts
265269 < >
266270 < For each = { sessionView ( ) . timeline } >
@@ -271,9 +275,9 @@ function SessionWorkbench(props: {
271275 </ Show >
272276 </ >
273277 } >
274- { ( _ ) => (
275- < div style = { { height : `${ virtualizer . getTotalSize ( ) } px` , width : '100%' , position : 'relative' } } >
276- < For each = { virtualizer . getVirtualItems ( ) } >
278+ { ( virt ) => (
279+ < div style = { { height : `${ virt ( ) . getTotalSize ( ) } px` , width : '100%' , position : 'relative' } } >
280+ < For each = { virt ( ) . getVirtualItems ( ) } >
277281 { ( virtualItem ) => {
278282 const isBusyRow = virtualItem . index === sessionView ( ) . timeline . length ;
279283 return (
@@ -285,7 +289,7 @@ function SessionWorkbench(props: {
285289 width : '100%' ,
286290 transform : `translateY(${ virtualItem . start } px)` ,
287291 } }
288- ref = { ( el ) => virtualizer . measureElement ( el ) }
292+ ref = { ( el ) => virt ( ) . measureElement ( el ) }
289293 data-index = { virtualItem . index }
290294 >
291295 < div class = { css ( { pb : '32px' } ) } >
0 commit comments