@@ -285,6 +285,7 @@ export const FacilitatorDashboard: React.FC<FacilitatorDashboardProps> = ({ onNa
285285 const [ isAddingTraces , setIsAddingTraces ] = React . useState ( false ) ;
286286 const [ isReorderingTraces , setIsReorderingTraces ] = React . useState ( false ) ;
287287 const [ isResettingDiscovery , setIsResettingDiscovery ] = React . useState ( false ) ;
288+ const [ isResettingAnnotation , setIsResettingAnnotation ] = React . useState ( false ) ;
288289
289290 // Judge name state - used for MLflow feedback entries
290291 const [ judgeName , setJudgeName ] = React . useState < string > ( workshop ?. judge_name || 'workshop_judge' ) ;
@@ -466,6 +467,39 @@ export const FacilitatorDashboard: React.FC<FacilitatorDashboardProps> = ({ onNa
466467 }
467468 } ;
468469
470+ const handleResetAnnotation = async ( ) => {
471+ if ( ! workshopId ) return ;
472+
473+ setIsResettingAnnotation ( true ) ;
474+ try {
475+ const response = await fetch ( `/workshops/${ workshopId } /reset-annotation` , {
476+ method : 'POST' ,
477+ headers : {
478+ 'Content-Type' : 'application/json' ,
479+ } ,
480+ } ) ;
481+
482+ if ( ! response . ok ) {
483+ const error = await response . json ( ) ;
484+ throw new Error ( error . detail || 'Failed to reset annotation' ) ;
485+ }
486+
487+ // Invalidate annotation-related caches
488+ queryClient . invalidateQueries ( { queryKey : [ 'workshop' , workshopId ] } ) ;
489+ queryClient . invalidateQueries ( { queryKey : [ 'annotations' , workshopId ] } ) ;
490+ queryClient . invalidateQueries ( { queryKey : [ 'all-traces' , workshopId ] } ) ;
491+
492+ toast . success ( 'Annotation reset! All SME progress cleared. Select your trace configuration.' ) ;
493+
494+ // Force page reload to reflect phase change
495+ window . location . reload ( ) ;
496+ } catch ( error : any ) {
497+ toast . error ( `Failed to reset annotation: ${ error . message } ` ) ;
498+ } finally {
499+ setIsResettingAnnotation ( false ) ;
500+ }
501+ } ;
502+
469503 return (
470504 < div className = "p-6" >
471505 < div className = "max-w-6xl mx-auto space-y-6" >
@@ -1070,6 +1104,58 @@ export const FacilitatorDashboard: React.FC<FacilitatorDashboardProps> = ({ onNa
10701104 < PhaseControlButton phase = "annotation" />
10711105 </ div >
10721106 </ div >
1107+
1108+ { /* Reset Annotation */ }
1109+ < div className = "border border-purple-200 rounded-lg p-4 bg-purple-50" >
1110+ < div className = "flex items-center gap-2 mb-3" >
1111+ < RotateCcw className = "w-5 h-5 text-purple-600" />
1112+ < div className = "text-left" >
1113+ < div className = "font-medium text-purple-800" > Reset Annotation</ div >
1114+ < div className = "text-xs text-purple-600" > Go back to reconfigure trace selection</ div >
1115+ </ div >
1116+ </ div >
1117+ < AlertDialog >
1118+ < AlertDialogTrigger asChild >
1119+ < Button
1120+ variant = "outline"
1121+ size = "sm"
1122+ disabled = { isResettingAnnotation }
1123+ className = "w-full border-purple-300 text-purple-700 hover:bg-purple-100"
1124+ >
1125+ { isResettingAnnotation ? (
1126+ < >
1127+ < div className = "w-3 h-3 border border-purple-300 border-t-purple-600 rounded-full animate-spin mr-2" />
1128+ Resetting...
1129+ </ >
1130+ ) : (
1131+ < >
1132+ < RotateCcw className = "w-3 h-3 mr-2" />
1133+ Reset & Reconfigure
1134+ </ >
1135+ ) }
1136+ </ Button >
1137+ </ AlertDialogTrigger >
1138+ < AlertDialogContent >
1139+ < AlertDialogHeader >
1140+ < AlertDialogTitle > Reset Annotation Phase?</ AlertDialogTitle >
1141+ < AlertDialogDescription >
1142+ This will reset the annotation phase so you can reconfigure the trace selection and settings.
1143+ < br /> < br />
1144+ < strong > All SME annotations will be cleared.</ strong > SMEs will need to start their annotations from the beginning.
1145+ </ AlertDialogDescription >
1146+ </ AlertDialogHeader >
1147+ < AlertDialogFooter >
1148+ < AlertDialogCancel > Cancel</ AlertDialogCancel >
1149+ < AlertDialogAction
1150+ onClick = { handleResetAnnotation }
1151+ className = "bg-purple-600 hover:bg-purple-700"
1152+ >
1153+ Reset Annotation
1154+ </ AlertDialogAction >
1155+ </ AlertDialogFooter >
1156+ </ AlertDialogContent >
1157+ </ AlertDialog >
1158+ </ div >
10731159 </ >
10741160 ) }
10751161 </ div >
0 commit comments