/** * ConfirmForgetDialog — AWS-style confirmation for destructive memory actions. * * The user must type the persona name exactly to enable the confirm button. * This prevents accidental deletions while keeping the UX lightweight * (no password re-entry needed). * * Used for: * - Forgetting a single memory * - Forgetting ALL memories for a persona * * Safety: memories are deleted, the persona itself is NEVER deleted. */ import React, { useState, useRef, useEffect } from 'react'; import { AlertTriangle, Brain, X } from 'lucide-react'; // --------------------------------------------------------------------------- // Component // --------------------------------------------------------------------------- export default function ConfirmForgetDialog({ mode, personaName, memoryCount = 0, memoryLabel, memoryCategory, onConfirm, onCancel, loading = false, }) { const [typed, setTyped] = useState(''); const inputRef = useRef(null); // Auto-focus the input on mount useEffect(() => { const t = setTimeout(() => inputRef.current?.focus(), 80); return () => clearTimeout(t); }, []); const nameMatches = typed.trim().toLowerCase() === personaName.trim().toLowerCase(); const canConfirm = nameMatches && !loading; const handleKeyDown = (e) => { if (e.key === 'Enter' && canConfirm) onConfirm(); if (e.key === 'Escape') onCancel(); }; return (