diff --git a/inventory/src/components/ai/AiDescriptionCompare.tsx b/inventory/src/components/ai/AiDescriptionCompare.tsx
index 0553219..e49fc57 100644
--- a/inventory/src/components/ai/AiDescriptionCompare.tsx
+++ b/inventory/src/components/ai/AiDescriptionCompare.tsx
@@ -18,7 +18,7 @@
import { useState, useEffect, useRef, useCallback } from "react";
import { Textarea } from "@/components/ui/textarea";
import { Button } from "@/components/ui/button";
-import { Sparkles, AlertCircle, Check } from "lucide-react";
+import { Sparkles, AlertCircle, Check, RefreshCw } from "lucide-react";
import { cn } from "@/lib/utils";
export interface AiDescriptionCompareProps {
@@ -28,6 +28,10 @@ export interface AiDescriptionCompareProps {
issues: string[];
onAccept: (editedSuggestion: string) => void;
onDismiss: () => void;
+ /** Called to re-roll (re-run) the AI validation */
+ onRevalidate?: () => void;
+ /** Whether re-validation is in progress */
+ isRevalidating?: boolean;
productName?: string;
className?: string;
}
@@ -39,6 +43,8 @@ export function AiDescriptionCompare({
issues,
onAccept,
onDismiss,
+ onRevalidate,
+ isRevalidating = false,
productName,
className,
}: AiDescriptionCompareProps) {
@@ -226,6 +232,18 @@ export function AiDescriptionCompare({
>
Ignore
+ {onRevalidate && (
+
+ )}
diff --git a/inventory/src/components/product-editor/ProductEditForm.tsx b/inventory/src/components/product-editor/ProductEditForm.tsx
index f94333b..e844639 100644
--- a/inventory/src/components/product-editor/ProductEditForm.tsx
+++ b/inventory/src/components/product-editor/ProductEditForm.tsx
@@ -218,6 +218,7 @@ export function ProductEditForm({
const watchCompany = watch("company");
const watchLine = watch("line");
+ const watchDescription = watch("description");
// Populate form on mount
useEffect(() => {
@@ -452,7 +453,7 @@ export function ProductEditForm({
const handleValidateDescription = useCallback(async () => {
const values = getValues();
- if (!values.description?.trim()) return;
+ if (!values.description?.trim() || values.description.trim().length < 10) return;
clearDescriptionResult();
setValidatingField("description");
const companyLabel = fieldOptions.companies.find((c) => c.value === values.company)?.label;
@@ -550,7 +551,7 @@ export function ProductEditForm({
{fc.label}
- {isDescription && (
+ {isDescription && (watchDescription?.trim().length ?? 0) >= 10 && (
descriptionResult?.suggestion ? (