@@ -68,7 +68,6 @@ export function ChatLog({
68
68
costEstimate,
69
69
} : Props ) {
70
70
const messages = useRedux ( [ "messages" ] , project_id , path ) as ChatMessages ;
71
-
72
71
// see similar code in task list:
73
72
const { selectedHashtags, selectedHashtagsSearch } = useMemo ( ( ) => {
74
73
return getSelectedHashtagsSearch ( selectedHashtags0 ) ;
@@ -507,7 +506,7 @@ export function MessageList({
507
506
const virtuosoHeightsRef = useRef < { [ index : number ] : number } > ( { } ) ;
508
507
const virtuosoScroll = useVirtuosoScrollHook ( {
509
508
cacheId : `${ project_id } ${ path } ` ,
510
- initialState : { index : messages . size - 1 , offset : 0 } , // starts scrolled to the newest message.
509
+ initialState : { index : Math . max ( sortedDates . length - 1 , 0 ) , offset : 0 } , // starts scrolled to the newest message.
511
510
} ) ;
512
511
513
512
return (
@@ -528,8 +527,10 @@ export function MessageList({
528
527
const date = sortedDates [ index ] ;
529
528
const message : ChatMessageTyped | undefined = messages . get ( date ) ;
530
529
if ( message == null ) {
531
- // shouldn't happen. But we should be robust to such a possibility.
532
- return < div style = { { height : "1px" } } /> ;
530
+ // shouldn't happen, but make code robust to such a possibility.
531
+ // if it happens, fix it.
532
+ console . warn ( "empty message" , { date, index, sortedDates } ) ;
533
+ return < div style = { { height : "30px" } } /> ;
533
534
}
534
535
535
536
// only do threading if numChildren is defined. It's not defined,
0 commit comments