@@ -28,6 +28,9 @@ type HandleStepOutputProps = {
2828 displayName : string ;
2929} ;
3030
31+ const MAX_SLICE_LENGTH = 10 ;
32+ const MAX_SLICES_AMOUNT = 10 ;
33+
3134function traverseStepOutputAndReturnMentionTree ( {
3235 stepOutput,
3336 success,
@@ -70,9 +73,8 @@ function handlingArrayStepOutput(
7073 parentDisplayName : string ,
7174 startingIndex = 0 ,
7275) : MentionTreeNode {
73- const maxSliceLength = 100 ;
7476 const isEmptyList = Object . keys ( stepOutput ) . length === 0 ;
75- if ( stepOutput . length <= maxSliceLength ) {
77+ if ( stepOutput . length <= MAX_SLICE_LENGTH ) {
7678 return {
7779 key : parentDisplayName ,
7880 children : stepOutput . map ( ( ouput , idx ) =>
@@ -92,13 +94,15 @@ function handlingArrayStepOutput(
9294 } ;
9395 }
9496
97+ const slicesAmount = Math . ceil ( stepOutput . length / MAX_SLICE_LENGTH ) ;
98+
9599 const numberOfSlices = new Array (
96- Math . ceil ( stepOutput . length / maxSliceLength ) ,
100+ Math . min ( slicesAmount , MAX_SLICES_AMOUNT ) ,
97101 ) . fill ( 0 ) ;
98102 const children : MentionTreeNode [ ] = numberOfSlices . map ( ( _ , idx ) => {
99- const startingIndex = idx * maxSliceLength ;
103+ const startingIndex = idx * MAX_SLICE_LENGTH ;
100104 const endingIndex =
101- Math . min ( ( idx + 1 ) * maxSliceLength , stepOutput . length ) - 1 ;
105+ Math . min ( ( idx + 1 ) * MAX_SLICE_LENGTH , stepOutput . length ) - 1 ;
102106 const displayName = `${ parentDisplayName } ${ startingIndex } -${ endingIndex } ` ;
103107 const sliceOutput = handlingArrayStepOutput (
104108 stepOutput . slice ( startingIndex , endingIndex ) ,
0 commit comments