From 8ef10f9f7560236bdee8fef294874571c8915796 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 24 Oct 2026 21:59:56 +0200 Subject: [PATCH] fix(price-check): keep the badge in step with the line's stored intel The line's ai_item_insights can change under the badge (the assistant fills the line, the operator saves it) and router.refresh() keeps the component mounted, so the badge would keep showing the intel it read at mount. Mirror the prop into local state instead. Co-Authored-By: Claude Opus 5.5 --- src/components/price-check-marker.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/price-check-marker.tsx b/src/components/price-check-marker.tsx index 8ae46bf..f79b573 100644 --- a/src/components/price-check-marker.tsx +++ b/src/components/price-check-marker.tsx @@ -24,7 +24,7 @@ * the line afterwards. */ -import { useCallback, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { Loader2, RefreshCw, Tags } from "lucide-react"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; @@ -117,6 +117,14 @@ export function PriceCheckMarker({ const [refreshing, setRefreshing] = useState(false); const [error, setError] = useState(null); + // The line's stored intel can change under us (the assistant fills + // the line, the operator saves it). Keep the badge in step with it. + useEffect(() => { + const next = asIntel(intel); + // eslint-disable-next-line react-hooks/set-state-in-effect -- mirror the line's stored intel into local state + if (next) setData(next); + }, [intel]); + const check = buildPriceCheck(data, { cost_price, selling_price,