import { useState, useEffect, useRef } from 'react' import { X } from 'lucide-react' const SHOW_DELAY_MS = 2500 // Module-level flag — resets on each app launch (page reload) let dismissedThisSession = false export function FreeApiKeyBubble({ forceApiGenerations, hasLtxApiKey, isGenerating, }: { forceApiGenerations: boolean hasLtxApiKey: boolean isGenerating: boolean }) { const [dismissed, setDismissed] = useState(() => dismissedThisSession) const [visible, setVisible] = useState(false) const timerRef = useRef | null>(null) useEffect(() => { if (isGenerating && !dismissed && !forceApiGenerations && !hasLtxApiKey) { timerRef.current = setTimeout(() => setVisible(true), SHOW_DELAY_MS) } else { if (timerRef.current) clearTimeout(timerRef.current) timerRef.current = null setVisible(false) } return () => { if (timerRef.current) clearTimeout(timerRef.current) } }, [isGenerating, dismissed, forceApiGenerations, hasLtxApiKey]) if (!visible) return null const handleDismiss = () => { dismissedThisSession = true setDismissed(true) } const handleGoToSettings = () => { window.dispatchEvent( new CustomEvent('open-settings', { detail: { tab: 'apiKeys' } }), ) } return (

Speed up inference and save memory with free cloud text encoding and prompt enhancement.{' '} {' '} to enable it.

The free API key covers text encoding and prompt enhancement only. Video generation via API requires a paid plan.

) }