@@ -485,6 +485,41 @@ export const TopicRefiner: FC<Omit<TopicRefinerProps, 'isLlmProcessing'>> = ({
485485 prevStep ( ) ;
486486 } ;
487487
488+ // Add this function after the other helper functions
489+ const getTopicsWithBothModels = ( ) => {
490+ const topicsByModel = suggestionsByModel . reduce ( ( acc , suggestion ) => {
491+ if ( ! acc [ suggestion . topic ] ) {
492+ acc [ suggestion . topic ] = new Set ( ) ;
493+ }
494+ acc [ suggestion . topic ] . add ( suggestion . model ) ;
495+ return acc ;
496+ } , { } as Record < string , Set < ModelType > > ) ;
497+
498+ return Object . entries ( topicsByModel )
499+ . filter ( ( [ , models ] ) => models . size === 2 )
500+ . map ( ( [ topic ] ) => topic ) ;
501+ } ;
502+
503+ const handleAddAllRecommendedTopics = ( ) => {
504+ const topicsWithBothModels = getTopicsWithBothModels ( ) ;
505+ const newTopics = topicsWithBothModels . filter ( topic => ! finalizedTopics . includes ( topic ) ) ;
506+ if ( newTopics . length > 0 ) {
507+ setFinalizedTopics ( [ ...finalizedTopics , ...newTopics ] ) ;
508+ // Update topic counts for new topics
509+ newTopics . forEach ( topic => {
510+ const suggestion = suggestions . find ( s => s . name === topic ) ;
511+ if ( suggestion ) {
512+ setTopicCounts ( prev => ( {
513+ ...prev ,
514+ [ topic ] : suggestion . count
515+ } ) ) ;
516+ } else {
517+ fetchTopicCount ( topic ) ;
518+ }
519+ } ) ;
520+ }
521+ } ;
522+
488523 return (
489524 < main className = "container-fluid py-4" style = { { height : '100vh' , overflowY : 'auto' } } >
490525 { /* Navigation/Header Row */ }
@@ -560,6 +595,15 @@ export const TopicRefiner: FC<Omit<TopicRefinerProps, 'isLlmProcessing'>> = ({
560595 </ span >
561596 </ h3 >
562597 < div className = "d-flex gap-2" >
598+ < button
599+ className = "btn btn-outline-primary"
600+ onClick = { handleAddAllRecommendedTopics }
601+ disabled = { getTopicsWithBothModels ( ) . length === 0 }
602+ title = "Add all topics recommended by both AI models"
603+ >
604+ < Plus size = { 16 } className = "me-2" />
605+ Both AI Recommended
606+ </ button >
563607 < button
564608 className = "btn btn-outline-secondary"
565609 onClick = { ( ) => setShowPromptModal ( true ) }
0 commit comments