/** * ExternalUninstallDialog — confirmation modal for uninstalling external MCP servers. * * Shows persona dependency warnings before confirming. Non-destructive: * the server files remain on disk and can be reinstalled at any time. * Tools are disabled (not deleted) and automatically re-enabled on reinstall. * * Fully additive — does not modify any existing component. */ import React, { useEffect, useState } from 'react'; import { AlertTriangle, Loader2, X, Users, Wrench } from 'lucide-react'; export function ExternalUninstallDialog({ server, backendUrl, apiKey, onClose, onConfirmUninstall, preview: externalPreview, }) { const [preview, setPreview] = useState(externalPreview ?? null); const [loadingPreview, setLoadingPreview] = useState(!externalPreview); // Fetch preview on mount if not provided useEffect(() => { if (externalPreview) return; const fetchPreview = async () => { setLoadingPreview(true); try { const headers = {}; if (apiKey) headers['x-api-key'] = apiKey; const res = await fetch(`${backendUrl}/v1/agentic/servers/external/${encodeURIComponent(server.id)}/uninstall-preview`, { headers }); if (res.ok) { setPreview(await res.json()); } } catch { // Preview failed — still allow uninstall } finally { setLoadingPreview(false); } }; void fetchPreview(); }, [server.id, backendUrl, apiKey, externalPreview]); const affectedCount = preview?.affected_personas?.length ?? 0; const toolCount = preview?.tools_to_deactivate?.length ?? server.tools_discovered ?? 0; return (
{/* Backdrop */}
{/* Dialog */}
e.stopPropagation()}> {/* Header */}
0 ? 'bg-amber-500/10 border-amber-500/20' : 'bg-red-500/10 border-red-500/20'}`}> 0 ? 'text-amber-400' : 'text-red-400'}/>

Uninstall {server.label}?

{/* Body */}
{loadingPreview ? (
Checking dependencies...
) : (<> {/* Persona dependency warning */} {affectedCount > 0 && (
{affectedCount} Persona{affectedCount > 1 ? 's' : ''} Affected
{preview.affected_personas.map((p) => (
{p.project_name} {p.tools_affected.length} tool{p.tools_affected.length > 1 ? 's' : ''} will be disabled
))}

These personas will lose access to {server.label} tools until the server is reinstalled.

)} {/* Tools to deactivate */} {toolCount > 0 && (
{toolCount} tool{toolCount > 1 ? 's' : ''} will be deactivated in Context Forge
)} {/* Description */}

This will stop {server.label} and deactivate its tools from your HomePilot instance.

{/* Safety info */}

Non-destructive: Server files remain on disk. No data is deleted.

Reversible: Reinstall anytime — disabled tools will be re-enabled automatically.

{affectedCount > 0 && (

Personas: Affected personas will have this tool disabled. Re-importing or reinstalling restores them.

)}
)}
{/* Actions */}
); }