From ce4902c4771ba0dd9c79206ffed8abc301cf70e2 Mon Sep 17 00:00:00 2001 From: Chandran Date: Mon, 8 Jun 2026 13:14:53 +0200 Subject: [PATCH] fix(calibration): don't open cameras until the user turns them on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Opening or hard-reloading the calibration page used to switch on the webcam (and any other connected camera) unprompted. The "Attached cameras" section mounted on page load and ran getUserMedia immediately: useAvailableCameras fires a `{ video: true }` permission probe to unlock device labels, and that probe grabs whatever the OS treats as the default camera — so a camera could light up even after being removed from the robot's config, with no user action. Gate the section behind an explicit On/Off toggle, off by default. While off, CameraConfiguration is not mounted, so nothing touches a camera; the panel instead explains that turning cameras on will scan connected devices and trigger the browser permission prompt. Cameras are only enumerated and previewed once the user opts in, and toggling off unmounts the section and releases every stream. Also add a Rescan button next to the camera list so a newly plugged-in USB camera can be picked up on demand instead of waiting for the hotplug auto-refresh. --- .../recording/CameraConfiguration.tsx | 25 ++++++-- frontend/src/pages/Calibration.tsx | 58 +++++++++++++++++-- 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/recording/CameraConfiguration.tsx b/frontend/src/components/recording/CameraConfiguration.tsx index 75cf925f..ec1809fc 100644 --- a/frontend/src/components/recording/CameraConfiguration.tsx +++ b/frontend/src/components/recording/CameraConfiguration.tsx @@ -10,7 +10,7 @@ import { } from "@/components/ui/select"; import { Input } from "@/components/ui/input"; import { NumberInput } from "@/components/ui/number-input"; -import { Camera, Plus, X, VideoOff } from "lucide-react"; +import { Camera, Plus, X, VideoOff, RefreshCw } from "lucide-react"; import { useToast } from "@/hooks/use-toast"; import { useAvailableCameras } from "@/hooks/useAvailableCameras"; import { useCameraStream } from "@/hooks/useCameraStream"; @@ -42,6 +42,7 @@ const CameraConfiguration: React.FC = ({ const { cameras: availableCameras, isLoading: isLoadingCameras, + refresh: refreshCameras, } = useAvailableCameras(); const [selectedCameraIndex, setSelectedCameraIndex] = useState(""); const [cameraName, setCameraName] = useState(""); @@ -176,9 +177,25 @@ const CameraConfiguration: React.FC = ({
- +
+ + +