match index-less device strings to hardware units in the detection models picker

A config with `edgetpu:usb` was reported as hardware that wasn't found, because the picker compared device strings exactly and the probe reports the unit as `edgetpu:usb:0`. A device without an index now resolves to the first unit of that kind, so the hardware dropdown, the unit checkboxes, and the model summary all recognize it.
This commit is contained in:
Josh Hawkins
2026-10-07 08:39:28 -05:00
parent 53b0dff949
commit d4a7504d67
2 changed files with 32 additions and 6 deletions
@@ -15,6 +15,7 @@ import {
hardwareForDevices,
MAX_DETECTORS,
recommendedDetectorCount,
resolveUnitDevice,
} from "@/utils/detectionHardware";
type HardwarePickerProps = {
@@ -60,9 +61,13 @@ export function HardwarePicker({
return [];
}
const assigned = devices.map((device) =>
resolveUnitDevice(selected, device),
);
return selected.units
.map((unit) => unit.device)
.filter((device) => devices.includes(device));
.filter((device) => assigned.includes(device));
}, [selected, devices]);
/** Spread `count` detectors round robin over the selected units. */
@@ -200,7 +205,7 @@ export function HardwarePicker({
<Checkbox
id={`${idPrefix}-${unit.device}`}
className="size-5 text-white accent-white data-[state=checked]:bg-selected data-[state=checked]:text-white"
checked={devices.includes(unit.device)}
checked={selectedUnits.includes(unit.device)}
disabled={disabled || Boolean(claimedBy)}
onCheckedChange={(checked) =>
handleUnitToggle(unit.device, checked === true)