@@ -103,6 +103,7 @@ export const TopicRefiner: FC<Omit<TopicRefinerProps, 'isLlmProcessing'>> = ({
103103 const [ searchTermRemoved , setSearchTermRemoved ] = useState ( false ) ;
104104 const [ submitProgress , setSubmitProgress ] = useState ( 0 ) ;
105105 const [ submitStatus , setSubmitStatus ] = useState < string > ( '' ) ;
106+ const [ showMemoryLimitModal , setShowMemoryLimitModal ] = useState ( false ) ;
106107
107108 // Function to fetch unique repository count for all finalized topics
108109 const fetchUniqueReposCount = async ( topics : string [ ] ) => {
@@ -507,17 +508,17 @@ export const TopicRefiner: FC<Omit<TopicRefinerProps, 'isLlmProcessing'>> = ({
507508 await new Promise ( resolve => setTimeout ( resolve , 500 ) ) ;
508509 }
509510
510- // Add confirmation for large repository counts
511- if ( uniqueReposCount > 10000 ) {
512- console . log ( 'Showing confirmation modal for large dataset:' , uniqueReposCount ) ;
513- setShowConfirmationModal ( true ) ;
511+ // Show memory limit warning for large repository counts
512+ if ( uniqueReposCount > 2500 ) {
513+ console . log ( 'Showing memory limit modal for large dataset:' , uniqueReposCount ) ;
514+ setShowMemoryLimitModal ( true ) ;
514515 return ;
515516 }
516517
517518 // If we have an error but still have a count, check if it's over threshold
518- if ( uniqueCountError && uniqueReposCount > 10000 ) {
519- console . log ( 'Showing confirmation modal despite error, count:' , uniqueReposCount ) ;
520- setShowConfirmationModal ( true ) ;
519+ if ( uniqueCountError && uniqueReposCount > 2500 ) {
520+ console . log ( 'Showing memory limit modal despite error, count:' , uniqueReposCount ) ;
521+ setShowMemoryLimitModal ( true ) ;
521522 return ;
522523 }
523524
@@ -960,7 +961,12 @@ export const TopicRefiner: FC<Omit<TopicRefinerProps, 'isLlmProcessing'>> = ({
960961 { uniqueReposCount . toLocaleString ( ) } (Fallback)
961962 </ span >
962963 ) : (
963- < span className = "fw-bold" > { uniqueReposCount . toLocaleString ( ) } </ span >
964+ < span className = { `fw-bold ${ uniqueReposCount > 2500 ? 'text-danger' : '' } ` } >
965+ { uniqueReposCount . toLocaleString ( ) }
966+ { uniqueReposCount > 2500 && (
967+ < i className = "fas fa-exclamation-triangle text-warning ms-1" title = "Large dataset - may cause performance issues" > </ i >
968+ ) }
969+ </ span >
964970 ) }
965971 </ div >
966972 { uniqueCountError && (
@@ -1185,8 +1191,8 @@ export const TopicRefiner: FC<Omit<TopicRefinerProps, 'isLlmProcessing'>> = ({
11851191 < div className = "modal-content" >
11861192 < div className = "modal-header" >
11871193 < h5 className = "modal-title d-flex align-items-center" >
1188- < i className = "fas fa-exclamation-circle text-danger me-2" > </ i >
1189- Large Dataset Warning
1194+ < i className = "fas fa-exclamation-triangle text-warning me-2" > </ i >
1195+ Performance Warning - Large Dataset
11901196 </ h5 >
11911197 < button
11921198 type = "button"
@@ -1199,15 +1205,15 @@ export const TopicRefiner: FC<Omit<TopicRefinerProps, 'isLlmProcessing'>> = ({
11991205 > </ button >
12001206 </ div >
12011207 < div className = "modal-body" >
1202- < div className = "alert alert-danger mb-0" >
1208+ < div className = "alert alert-warning mb-0" >
12031209 < p className = "mb-2" >
12041210 You are about to generate a graph with < strong > { uniqueReposCount . toLocaleString ( ) } </ strong > unique repositories.
12051211 </ p >
12061212 < p className = "mb-0" >
1207- This may take a while to process and could impact performance. Are you sure you want to continue?
1213+ < strong > Warning: </ strong > Graphs with more than 2,000 repositories may cause significant performance issues and slow down your browser. Consider reducing the number of topics to improve performance.
12081214 </ p >
12091215 < small className = "d-block mt-2 text-muted" >
1210- Debug: Threshold is 10,000 , current count: { uniqueReposCount }
1216+ Debug: Threshold is 2,500 , current count: { uniqueReposCount }
12111217 </ small >
12121218 </ div >
12131219 </ div >
@@ -1224,14 +1230,68 @@ export const TopicRefiner: FC<Omit<TopicRefinerProps, 'isLlmProcessing'>> = ({
12241230 </ button >
12251231 < button
12261232 type = "button"
1227- className = "btn btn-danger "
1228- onClick = { async ( ) => {
1229- console . log ( 'Confirmation modal confirmed by user, proceeding with submission ' ) ;
1233+ className = "btn btn-warning "
1234+ onClick = { ( ) => {
1235+ console . log ( 'User chose to change dataset ' ) ;
12301236 setShowConfirmationModal ( false ) ;
1231- await submitTopics ( ) ;
1237+ // Focus on the topic selection area or scroll to it
1238+ const topicInput = document . querySelector ( 'input[placeholder="Add a custom topic"]' ) as HTMLInputElement ;
1239+ if ( topicInput ) {
1240+ topicInput . focus ( ) ;
1241+ }
1242+ } }
1243+ >
1244+ Change Dataset
1245+ </ button >
1246+ </ div >
1247+ </ div >
1248+ </ div >
1249+ </ div >
1250+ ) }
1251+
1252+ { /* Memory Limit Modal */ }
1253+ { showMemoryLimitModal && (
1254+ < div className = "modal show d-block" tabIndex = { - 1 } role = "dialog" style = { { backgroundColor : 'rgba(0,0,0,0.5)' } } >
1255+ < div className = "modal-dialog modal-dialog-centered" >
1256+ < div className = "modal-content" >
1257+ < div className = "modal-header" >
1258+ < h5 className = "modal-title d-flex align-items-center" >
1259+ < i className = "fas fa-exclamation-triangle text-warning me-2" > </ i >
1260+ Memory Limit Reached
1261+ </ h5 >
1262+ < button
1263+ type = "button"
1264+ className = "btn-close"
1265+ onClick = { ( ) => {
1266+ console . log ( 'Memory limit modal closed by user' ) ;
1267+ setShowMemoryLimitModal ( false ) ;
1268+ } }
1269+ aria-label = "Close"
1270+ > </ button >
1271+ </ div >
1272+ < div className = "modal-body" >
1273+ < div className = "alert alert-warning mb-0" >
1274+ < p className = "mb-2" >
1275+ Due to the current memory limitation, we only support graphs with 2,500 nodes or below.
1276+ </ p >
1277+ < p className = "mb-0" >
1278+ We are keeping optimize the node scalability.
1279+ </ p >
1280+ < small className = "d-block mt-2 text-muted" >
1281+ Current repository count: { uniqueReposCount . toLocaleString ( ) }
1282+ </ small >
1283+ </ div >
1284+ </ div >
1285+ < div className = "modal-footer" >
1286+ < button
1287+ type = "button"
1288+ className = "btn btn-secondary"
1289+ onClick = { ( ) => {
1290+ console . log ( 'Memory limit modal closed by user' ) ;
1291+ setShowMemoryLimitModal ( false ) ;
12321292 } }
12331293 >
1234- Continue
1294+ OK
12351295 </ button >
12361296 </ div >
12371297 </ div >
0 commit comments