import React, { useState, useEffect } from 'react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/index'; import { Button } from '@/components/ui/index'; import { RefreshCw, Check, AlertCircle, Loader, ExternalLink } from 'lucide-react'; import { checkAppUpdatesCmd, installAppUpdatesCmd, getUpdateChannelCmd, setUpdateChannelCmd, type UpdateCheckResult, } from '@/lib/tauriCommands'; export function Updater() { const [channel, setChannel] = useState('stable'); const [checking, setChecking] = useState(false); const [result, setResult] = useState(null); const [error, setError] = useState(null); const loadChannel = async () => { try { const ch = await getUpdateChannelCmd(); setChannel(ch); } catch { console.error('Failed to load channel'); } }; const checkForUpdates = async () => { setChecking(true); setError(null); try { const data = await checkAppUpdatesCmd(); setResult(data); } catch (err) { setError(String(err)); } finally { setChecking(false); } }; const handleDownloadUpdate = async () => { try { await installAppUpdatesCmd(); } catch (err) { setError('Failed to open releases page: ' + String(err)); } }; const handleChannelChange = async (newChannel: string) => { setChannel(newChannel); try { await setUpdateChannelCmd(newChannel); } catch { setError('Failed to update channel'); } }; useEffect(() => { void loadChannel(); void checkForUpdates(); }, []); return (

Updater

Configure application updates

Update Channel
Check for Updates {error && (
{error}
)} {result && (
Current version: {result.currentVersion}
Latest version: {result.latestVersion || '—'}
)} {result?.updateAvailable ? (
Update Available — v{result.latestVersion}
Click below to open the releases page and download
{result.releaseNotes && (
Release Notes
{result.releaseNotes}
)}
) : result ? (
Up to Date
You are running the latest version
) : null}
); }