import { Modal, Stack, Text, Group, Button, Card, Loader, useMantineColorScheme, Anchor, Progress, } from '@mantine/core'; import { Download, X, ExternalLink } from 'lucide-react'; import { useState } from 'react'; import type { InstalledVersion, DownloadItem } from '@/types/electron'; import { getDisplayNameFromPath } from '@/utils/versionUtils'; import { GITHUB_API } from '@/constants'; interface UpdateAvailableModalProps { opened: boolean; onClose: () => void; currentVersion: InstalledVersion; availableUpdate: DownloadItem; onUpdate: (download: DownloadItem) => Promise; isDownloading?: boolean; downloadProgress?: number; } export const UpdateAvailableModal = ({ opened, onClose, currentVersion, availableUpdate, onUpdate, isDownloading = false, downloadProgress = 0, }: UpdateAvailableModalProps) => { const [isUpdating, setIsUpdating] = useState(false); const { colorScheme } = useMantineColorScheme(); const handleUpdate = async () => { try { setIsUpdating(true); await onUpdate(availableUpdate); onClose(); } catch (error) { window.electronAPI.logs.logError('Failed to update:', error as Error); } finally { setIsUpdating(false); } }; return (
Current Version {currentVersion.version}
Available Version {availableUpdate.version}
Binary: {getDisplayNameFromPath(currentVersion)} View release notes: window.electronAPI.app.openExternal( `https://github.com/${GITHUB_API.KOBOLDCPP_REPO}/releases/tag/v${availableUpdate.version}` ) } > v{availableUpdate.version}
{isDownloading ? `${Math.min(downloadProgress, 100).toFixed(1)}% complete` : 'Preparing update...'}
); };