@@ -863,44 +863,31 @@ const DesktopLayout: React.FC<{
863863 </ div >
864864 < div className = "flex flex-col gap-2 px-3 pb-3" >
865865 { ( ( ) => {
866- // Get critical moves directly from game tree (like MovesContainer)
867- const mainLineNodes = gameTree . getMainLine ( ) . slice ( 1 ) // Skip root
868- const criticalMoves = mainLineNodes
869- . filter ( ( node , index ) => {
870- // Determine if this is a player move
871- const chess = new Chess ( node . fen )
872- const isPlayerMove =
873- drill . selection . playerColor === 'white'
874- ? chess . turn ( ) === 'b' // If black to move, white just played
875- : chess . turn ( ) === 'w' // If white to move, black just played
866+ // Get critical moves from moveAnalyses instead of relying on GameNode properties
867+ const criticalMoves = performanceData . moveAnalyses
868+ . filter ( ( move ) => {
869+ // Determine if this is a player move using the same logic as elsewhere
870+ const isWhiteMove = isMoveByWhite ( move . fen )
871+ const isPlayerMove = drill . selection . playerColor === 'white'
872+ ? isWhiteMove
873+ : ! isWhiteMove
876874 return isPlayerMove
877875 } )
878- . filter ( ( node ) => {
879- // Filter for critical moves (same logic as MovesContainer)
880- return node . blunder || node . inaccuracy || node . excellentMove
881- } )
882- . map ( ( node ) => {
883- // Convert to MoveAnalysis format for display
884- let classification : 'blunder' | 'inaccuracy' | 'excellent' =
885- 'excellent'
886- if ( node . blunder ) {
887- classification = 'blunder'
888- } else if ( node . inaccuracy ) {
889- classification = 'inaccuracy'
890- }
891-
876+ . map ( ( move ) => {
877+ // Get classification from our helper function
878+ const classification = getChartClassification ( move , gameNodesMap )
879+ // Get the correct move number from the FEN
880+ const actualMoveNumber = getMoveNumberFromFen ( move . fen )
892881 return {
893- move : node . move || '' ,
894- san : node . san || '' ,
895- fen : node . fen ,
896- fenBeforeMove : node . parent ?. fen ,
897- moveNumber : node . moveNumber ,
898- isPlayerMove : true ,
899- evaluation : 0 , // Will be filled if needed
882+ ...move ,
900883 classification,
901- evaluationLoss : 0 ,
884+ moveNumber : actualMoveNumber ,
902885 }
903886 } )
887+ . filter ( ( move ) => {
888+ // Filter for critical moves (not just 'good')
889+ return [ 'excellent' , 'inaccuracy' , 'blunder' ] . includes ( move . classification )
890+ } )
904891 . sort ( ( a , b ) => {
905892 // Sort by move number (chronological order)
906893 return a . moveNumber - b . moveNumber
0 commit comments