Skip to content

Commit a01c4f5

Browse files
Merge pull request #27 from databricks-solutions/vivian_dev
Judge tuning per-question persistence, compact toggles, reset annotation
2 parents 7da50f5 + 886d26c commit a01c4f5

7 files changed

Lines changed: 425 additions & 194 deletions

File tree

client/src/components/AnnotationStartPage.tsx

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -213,35 +213,16 @@ export const AnnotationStartPage: React.FC<AnnotationStartPageProps> = ({ onStar
213213
</RadioGroup>
214214

215215
{/* Randomization Toggle */}
216-
<div className="mt-6 pt-4 border-t border-amber-200">
217-
<div className="flex items-center justify-between">
218-
<div className="flex items-center gap-3">
219-
<Shuffle className="w-5 h-5 text-amber-600" />
220-
<div>
221-
<Label htmlFor="annotation-randomize-toggle" className="font-medium cursor-pointer">
222-
Randomize Trace Order
223-
</Label>
224-
<div className="text-sm text-slate-600">
225-
Each SME sees traces in a different random order
226-
</div>
227-
</div>
228-
</div>
229-
<Switch
230-
id="annotation-randomize-toggle"
231-
checked={randomizeTraces}
232-
onCheckedChange={setRandomizeTraces}
233-
/>
234-
</div>
235-
{!randomizeTraces && (
236-
<div className="text-xs text-slate-500 mt-2 ml-8">
237-
Default: All SMEs will see traces in the same chronological order
238-
</div>
239-
)}
240-
{randomizeTraces && (
241-
<div className="text-xs text-amber-700 mt-2 ml-8">
242-
✓ Randomization enabled: Each SME will see traces in their own unique order
243-
</div>
244-
)}
216+
<div className="mt-4 pt-3 border-t border-amber-200 flex items-center justify-between">
217+
<Label htmlFor="annotation-randomize-toggle" className="text-sm text-slate-600 cursor-pointer flex items-center gap-2">
218+
<Shuffle className="w-4 h-4 text-amber-600" />
219+
Randomize trace order
220+
</Label>
221+
<Switch
222+
id="annotation-randomize-toggle"
223+
checked={randomizeTraces}
224+
onCheckedChange={setRandomizeTraces}
225+
/>
245226
</div>
246227

247228
<div className="mt-4 p-3 bg-purple-100 rounded-lg">

client/src/components/DiscoveryStartPage.tsx

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -210,35 +210,16 @@ export const DiscoveryStartPage: React.FC<DiscoveryStartPageProps> = ({ onStartD
210210
)}
211211

212212
{/* Randomization Toggle */}
213-
<div className="mt-6 pt-4 border-t border-amber-200">
214-
<div className="flex items-center justify-between p-3 rounded-lg bg-white/50">
215-
<div className="flex items-center gap-3">
216-
<Shuffle className="w-5 h-5 text-amber-600" />
217-
<div>
218-
<Label htmlFor="randomize-toggle" className="font-medium cursor-pointer">
219-
Randomize Trace Order
220-
</Label>
221-
<div className="text-sm text-slate-600">
222-
Each participant sees traces in a different random order
223-
</div>
224-
</div>
225-
</div>
226-
<Switch
227-
id="randomize-toggle"
228-
checked={randomizeTraces}
229-
onCheckedChange={setRandomizeTraces}
230-
/>
231-
</div>
232-
{!randomizeTraces && (
233-
<div className="text-xs text-slate-500 mt-2 ml-8">
234-
Default: All participants will see traces in the same chronological order
235-
</div>
236-
)}
237-
{randomizeTraces && (
238-
<div className="text-xs text-amber-700 mt-2 ml-8">
239-
✓ Randomization enabled: Each user will see traces in their own unique order
240-
</div>
241-
)}
213+
<div className="mt-4 pt-3 border-t border-amber-200 flex items-center justify-between">
214+
<Label htmlFor="randomize-toggle" className="text-sm text-slate-600 cursor-pointer flex items-center gap-2">
215+
<Shuffle className="w-4 h-4 text-amber-600" />
216+
Randomize trace order
217+
</Label>
218+
<Switch
219+
id="randomize-toggle"
220+
checked={randomizeTraces}
221+
onCheckedChange={setRandomizeTraces}
222+
/>
242223
</div>
243224

244225
{/* Show current selection info */}

client/src/components/FacilitatorDashboard.tsx

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)