(null);
+
const onCloseRef = useRef(onClose);
onCloseRef.current = onClose;
@@ -44,8 +55,20 @@ export function UpdateCheckModal({ theme, onClose }: UpdateCheckModalProps) {
checkForUpdates();
}, []);
+ // Subscribe to update status changes
+ useEffect(() => {
+ const unsubscribe = window.maestro.updates.onStatus((status) => {
+ setDownloadStatus(status);
+ if (status.status === 'error' && status.error) {
+ setDownloadError(status.error);
+ }
+ });
+ return () => unsubscribe();
+ }, []);
+
const checkForUpdates = async () => {
setLoading(true);
+ setDownloadError(null);
try {
const updateResult = await window.maestro.updates.check();
setResult(updateResult);
@@ -90,6 +113,29 @@ export function UpdateCheckModal({ theme, onClose }: UpdateCheckModalProps) {
});
};
+ const formatBytes = (bytes: number) => {
+ if (bytes === 0) return '0 B';
+ const k = 1024;
+ const sizes = ['B', 'KB', 'MB', 'GB'];
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
+ };
+
+ const handleDownloadUpdate = async () => {
+ setDownloadError(null);
+ setDownloadStatus({ status: 'downloading', progress: { percent: 0, bytesPerSecond: 0, total: 0, transferred: 0 } });
+
+ const downloadResult = await window.maestro.updates.download();
+ if (!downloadResult.success && downloadResult.error) {
+ setDownloadError(downloadResult.error);
+ setDownloadStatus({ status: 'error', error: downloadResult.error });
+ }
+ };
+
+ const handleInstallUpdate = () => {
+ window.maestro.updates.install();
+ };
+
// Register layer on mount
useEffect(() => {
const id = registerLayer({
@@ -112,6 +158,9 @@ export function UpdateCheckModal({ theme, onClose }: UpdateCheckModalProps) {
};
}, [registerLayer, unregisterLayer]);
+ const isDownloading = downloadStatus.status === 'downloading';
+ const isDownloaded = downloadStatus.status === 'downloaded';
+
return (
- {/* Upgrade Instructions */}
-
-
- How to Upgrade
-
-
-
Upgrading is simple - just download and replace the app binary:
-
- - Download the latest release for your platform
- - Replace the existing Maestro app
- - Restart Maestro
-
-
- All your data (sessions, settings, history) will persist automatically.
-
-
-
-
{/* Release Notes */}
@@ -313,16 +341,100 @@ export function UpdateCheckModal({ theme, onClose }: UpdateCheckModalProps) {
- {/* Download Button */}
-
+ {/* Download Error */}
+ {downloadError && (
+
+
+
{downloadError}
+
+
+ )}
+
+ {/* Download Progress */}
+ {isDownloading && downloadStatus.progress && (
+
+
+ Downloading update...
+ {Math.round(downloadStatus.progress.percent)}%
+
+
+
+ {formatBytes(downloadStatus.progress.transferred)} / {formatBytes(downloadStatus.progress.total)}
+ {formatBytes(downloadStatus.progress.bytesPerSecond)}/s
+
+
+ )}
+
+ {/* Action Buttons */}
+
+ {isDownloaded ? (
+
+ ) : (
+
+ )}
+
+ {/* Fallback link */}
+
+
>
) : (