/** * @license * Copyright 2025 Vybestack LLC * SPDX-License-Identifier: Apache-2.0 */ import type React from 'react'; import { useState, useCallback } from 'react'; import { Box, Text } from 'ink'; import { Colors } from '../../colors.js'; import { useKeypress } from '../../hooks/useKeypress.js'; import type { SubagentInfo } from './types.js'; function formatDate(isoString: string): string { try { return new Date(isoString).toLocaleString(); } catch { return isoString; } } interface SubagentDeleteContentProps { subagent: SubagentInfo; error: string | null; isDeleting: boolean; } function SubagentDeleteContent({ subagent, error, isDeleting, }: SubagentDeleteContentProps) { return ( WARNING: This action cannot be undone ─────────────────────────────────────────────────────── {error && ( {error} )} Subagent: {subagent.name} Profile: {subagent.profile} Created: {formatDate(subagent.createdAt)} This will permanently delete the subagent and all configuration data. The profile will NOT be affected. WARNING: All subagent settings and prompts will be lost! {/* Controls */} [Enter] Confirm Delete [ESC] Cancel {isDeleting && ( Deleting... )} ); } interface SubagentDeleteDialogProps { subagent: SubagentInfo; onConfirm: () => Promise; onCancel: () => void; isFocused?: boolean; } export const SubagentDeleteDialog: React.FC = ({ subagent, onConfirm, onCancel, isFocused = true, }) => { const [isDeleting, setIsDeleting] = useState(false); const [error, setError] = useState(null); const handleConfirm = useCallback(async () => { setIsDeleting(true); setError(null); try { await onConfirm(); } catch (err) { setError(err instanceof Error ? err.message : 'Failed to delete'); setIsDeleting(false); } }, [onConfirm]); useKeypress( (key) => { if (isDeleting) return; if (key.name === 'escape') { onCancel(); return; } if (key.name === 'return') { void handleConfirm(); } }, { isActive: isFocused && !isDeleting }, ); return ( ); };