code-review-fix task 12.4: add onPointerUp to confidence slider to reduce excessive callbacks

This commit is contained in:
Marko Djordjevic 2026-02-18 20:37:27 +01:00
parent a0a30beb8e
commit 4e0264ca95

View file

@ -38,6 +38,7 @@ export default function PredictionPanel({
}: PredictionPanelProps) { }: PredictionPanelProps) {
const [expanded, setExpanded] = useState(true); const [expanded, setExpanded] = useState(true);
const [modelLoadError, setModelLoadError] = useState<string | null>(null); const [modelLoadError, setModelLoadError] = useState<string | null>(null);
const [localConfidence, setLocalConfidence] = useState<number | null>(null);
const { const {
visible, visible,
@ -143,14 +144,19 @@ export default function PredictionPanel({
<div> <div>
<div className="flex justify-between items-center mb-1"> <div className="flex justify-between items-center mb-1">
<label className="text-[10px] text-muted-foreground">Confidence</label> <label className="text-[10px] text-muted-foreground">Confidence</label>
<span className="text-[10px] font-mono text-foreground">{(confidenceThreshold * 100).toFixed(0)}%</span> <span className="text-[10px] font-mono text-foreground">{((localConfidence ?? confidenceThreshold) * 100).toFixed(0)}%</span>
</div> </div>
<input <input
type="range" type="range"
min="0" min="0"
max="100" max="100"
value={confidenceThreshold * 100} value={(localConfidence ?? confidenceThreshold) * 100}
onChange={(e) => onConfidenceChange(Number(e.target.value) / 100)} onChange={(e) => setLocalConfidence(Number(e.target.value) / 100)}
onPointerUp={(e) => {
const value = Number((e.target as HTMLInputElement).value) / 100;
setLocalConfidence(null);
onConfidenceChange(value);
}}
className="w-full h-1 bg-secondary rounded-lg appearance-none cursor-pointer accent-primary" className="w-full h-1 bg-secondary rounded-lg appearance-none cursor-pointer accent-primary"
/> />
</div> </div>