diff --git a/frontend/src/components/ai-builder/GeneratingAnimation.tsx b/frontend/src/components/ai-builder/GeneratingAnimation.tsx index f372487e..834e9ffe 100644 --- a/frontend/src/components/ai-builder/GeneratingAnimation.tsx +++ b/frontend/src/components/ai-builder/GeneratingAnimation.tsx @@ -1,31 +1,60 @@ import { useEffect, useState } from 'react' -import { Sparkles } from 'lucide-react' +import { cn } from '@/lib/utils' const MESSAGES = [ - 'Analyzing your flow requirements...', - 'Building decision paths...', - 'Generating troubleshooting logic...', - 'Crafting resolution steps...', - 'Structuring the flow...', -] + 'Setting up your flow...', + 'Building diagnostic paths...', + 'Putting the pieces in place...', + 'Almost there...', +] as const -export function GeneratingAnimation() { +const MESSAGE_DURATIONS = [4000, 8000, 8000, Infinity] // ms each message shows + +interface GeneratingAnimationProps { + branchContext?: { current: number; total: number } +} + +export function GeneratingAnimation({ branchContext }: GeneratingAnimationProps) { const [messageIndex, setMessageIndex] = useState(0) + // Reset and advance message on mount/remount useEffect(() => { - const interval = setInterval(() => { - setMessageIndex((prev) => (prev + 1) % MESSAGES.length) - }, 3000) - return () => clearInterval(interval) + setMessageIndex(0) + let current = 0 + + const advance = () => { + current += 1 + if (current < MESSAGES.length - 1) { + setMessageIndex(current) + timer = setTimeout(advance, MESSAGE_DURATIONS[current]) + } else { + setMessageIndex(MESSAGES.length - 1) + } + } + + let timer = setTimeout(advance, MESSAGE_DURATIONS[0]) + return () => clearTimeout(timer) }, []) return ( -
-
-
- -
-

+

+ {/* Spinner */} +
+ + {/* Branch context (Generate All mode) */} + {branchContext && ( +

+ Branch {branchContext.current} of {branchContext.total} +

+ )} + + {/* Rotating message */} +

{MESSAGES[messageIndex]}