From d0ed0ab196d7e650777477390111b7d787eae5a0 Mon Sep 17 00:00:00 2001 From: LeoLTM <44781682+LeoLTM@users.noreply.github.com> Date: Thu, 17 Sep 2026 11:00:57 +0200 Subject: [PATCH 01/18] feat: add manual test trigger functionality with haptic feedback and notification --- .../frontend/src/components/ArmingButton.tsx | 62 +++++++++++++++++++ .../frontend/src/components/ViolationCard.tsx | 25 +++++--- 2 files changed, 80 insertions(+), 7 deletions(-) diff --git a/headless-rust/frontend/src/components/ArmingButton.tsx b/headless-rust/frontend/src/components/ArmingButton.tsx index 8179fe0..f23d98f 100644 --- a/headless-rust/frontend/src/components/ArmingButton.tsx +++ b/headless-rust/frontend/src/components/ArmingButton.tsx @@ -1,12 +1,15 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { HugeiconsIcon } from "@hugeicons/react"; import { + FlashIcon, Shield01Icon, ShieldHalfIcon, ShieldKeyIcon, } from "@hugeicons/core-free-icons"; import { cn } from "@/lib/utils"; import { useAppStore } from "@/stores/useAppStore"; +import { getRpc } from "@/lib/rpc"; +import { toast } from "sonner"; // ponytail: native navigator.vibrate for mobile haptic feedback, zero dependencies const triggerHaptic = (pattern: number | number[]) => { @@ -127,6 +130,31 @@ export function ArmingButton() { // Derive which conditions are missing for the hint text const missingCamera = !cameraConnected; const missingSerial = !connectedPort; + const canTrigger = Boolean(connectedPort && cameraConnected); + + const [isTriggering, setIsTriggering] = useState(false); + + // ponytail: direct RPC test trigger with haptic feedback and toast notification + const handleTestTrigger = useCallback(async () => { + if (!canTrigger || isTriggering) return; + triggerHaptic(20); + setIsTriggering(true); + try { + const res = await getRpc().request.testTrigger({}); + if (res.success) { + triggerHaptic([30, 40]); + toast.success("Manual test trigger fired", { + description: "Test frame captured and recorded", + }); + } + } catch (err: any) { + toast.error("Test trigger failed", { + description: err?.message || "Communication failure", + }); + } finally { + setIsTriggering(false); + } + }, [canTrigger, isTriggering]); return (
- {violation.measuredSpeed} km/h -
-- Limit {violation.maxSpeed} km/h - (+{overSpeed}) -
+ {violation.measuredSpeed < 0 ? ( + <> + + Test Trigger + +Manual verification frame
+ > + ) : ( + <> ++ {violation.measuredSpeed} km/h +
++ Limit {violation.maxSpeed} km/h + (+{overSpeed}) +
+ > + )}