Mask/zone editor fixes (#22732)

* add guards to reject missing sub commands

* mask/zone bugfixes

- fix websocket crash when creating a new mask or zone before a name is assigned
- fix deleted masks and zones not disappearing from the list until navigating away
- fix deleting profile override not reverting to the base mask in the list
- fix inertia defaulting to nan

* disable save button on invalid form state

* fix validation for speed estimation

* ensure polygon is closed before allowing save

* require all masks and zones to be on the base config

* clarify dialog message and tooltip when removing an override

* clarify docs
This commit is contained in:
Josh Hawkins
2026-04-02 08:15:51 -06:00
committed by GitHub
parent adc8c2a6e8
commit 5059311c9d
9 changed files with 235 additions and 86 deletions
@@ -80,9 +80,10 @@ export default function ObjectMaskEditPane({
}
}, [polygons, activePolygonIndex]);
const maskName = polygon?.name || "";
const { send: sendObjectMaskState } = useObjectMaskState(
polygon?.camera || "",
polygon?.name || "",
maskName,
);
const cameraConfig = useMemo(() => {
@@ -143,7 +144,7 @@ export default function ObjectMaskEditPane({
}),
enabled: z.boolean(),
objects: z.string(),
isFinished: z.boolean().refine(() => polygon?.isFinished === true, {
isFinished: z.boolean().refine((val) => val === true, {
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
}),
});
@@ -160,6 +161,12 @@ export default function ObjectMaskEditPane({
},
});
useEffect(() => {
if (polygon?.isFinished !== undefined) {
form.setValue("isFinished", polygon.isFinished, { shouldValidate: true });
}
}, [polygon?.isFinished, form]);
const saveToConfig = useCallback(
async ({
name: maskId,
@@ -256,8 +263,8 @@ export default function ObjectMaskEditPane({
},
);
updateConfig();
// Only publish WS state for base config
if (!editingProfile) {
// Only publish WS state for base config when mask has a name
if (!editingProfile && maskName) {
sendObjectMaskState(enabled ? "ON" : "OFF");
}
} else {
@@ -300,6 +307,7 @@ export default function ObjectMaskEditPane({
cameraConfig,
t,
sendObjectMaskState,
maskName,
editingProfile,
],
);
@@ -454,7 +462,7 @@ export default function ObjectMaskEditPane({
</Button>
<Button
variant="select"
disabled={isLoading}
disabled={isLoading || !form.formState.isValid}
className="flex flex-1"
aria-label={t("button.save", { ns: "common" })}
type="submit"