allow models to share shareable detection hardware

The hardware picker treated every device another model listed as taken, so a second model couldn't pick an Intel GPU or the CPU that the first one already used. The backend only rejects reuse of devices that can't be shared (Coral, MemryX), so the picker now matches that and only marks exclusive units as claimed.
This commit is contained in:
Josh Hawkins
2026-09-28 09:28:09 -05:00
parent 225e014979
commit 3adf2cf48e
@@ -21,7 +21,8 @@ type HardwarePickerProps = {
// scopes the unit checkbox ids, since several models can list the same unit // scopes the unit checkbox ids, since several models can list the same unit
idPrefix: string; idPrefix: string;
devices: string[]; devices: string[];
// device strings already taken by another model, mapped to that model's scene // device strings already taken by another model, mapped to that model's
// scene. Only binding for hardware that can't be shared.
claimedElsewhere: Record<string, string>; claimedElsewhere: Record<string, string>;
cameraCount: number; cameraCount: number;
disabled?: boolean; disabled?: boolean;
@@ -84,8 +85,11 @@ export function HardwarePicker({
return; return;
} }
// start with the first unit no other model has taken // start with the first unit no other model has taken, falling back to
const free = entry.units.find((unit) => !claimedElsewhere[unit.device]); // a taken one when the hardware can be shared
const free =
entry.units.find((unit) => !claimedElsewhere[unit.device]) ??
(entry.unlimited ? entry.units[0] : undefined);
if (!free) { if (!free) {
onChange([]); onChange([]);
@@ -184,7 +188,9 @@ export function HardwarePicker({
{t("detectionModels.hardware.unitsDescription")} {t("detectionModels.hardware.unitsDescription")}
</p> </p>
{selected.units.map((unit) => { {selected.units.map((unit) => {
const claimedBy = claimedElsewhere[unit.device]; const claimedBy = selected.unlimited
? undefined
: claimedElsewhere[unit.device];
return ( return (
<div <div