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) {
const [expanded, setExpanded] = useState(true);
const [modelLoadError, setModelLoadError] = useState<string | null>(null);
const [localConfidence, setLocalConfidence] = useState<number | null>(null);
const {
visible,
@ -143,14 +144,19 @@ export default function PredictionPanel({
<div>
<div className="flex justify-between items-center mb-1">
<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>
<input
type="range"
min="0"
max="100"
value={confidenceThreshold * 100}
onChange={(e) => onConfidenceChange(Number(e.target.value) / 100)}
value={(localConfidence ?? confidenceThreshold) * 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"
/>
</div>