Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat: add auto-update UI with download progress and install button
Claude5ca859de065f
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsxindex 5cd7d9857..69fb81456 100644--- a/src/components/ControlPanel.tsx+++ b/src/components/ControlPanel.tsx@@ -1,7 +1,7 @@import { useState, useEffect } from "react";import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";import { Button } from "./ui/button";-import { Trash2, Settings, FileText, Mic } from "lucide-react";+import { Trash2, Settings, FileText, Mic, Download, RefreshCw, Loader2 } from "lucide-react";import SettingsModal from "./SettingsModal";import TitleBar from "./TitleBar";import SupportDropdown from "./ui/SupportDropdown";@@ -28,6 +28,9 @@ export default function ControlPanel() {updateDownloaded: false,isDevelopment: false,});+ const [isDownloading, setIsDownloading] = useState(false);+ const [isInstalling, setIsInstalling] = useState(false);+ const [downloadProgress, setDownloadProgress] = useState(0);const {confirmDialog,@@ -59,17 +62,37 @@ export default function ControlPanel() {};const handleUpdateDownloaded = (_event: any, _info: any) => {+ setIsDownloading(false);+ setDownloadProgress(100);setUpdateStatus((prev) => ({ ...prev, updateDownloaded: true }));+ toast({+ title: "Update Ready",+ description: "Click 'Install Update' to restart and apply the update.",+ variant: "success",+ });};const handleUpdateError = (_event: any, _error: any) => {- // Update errors are handled by the update service+ setIsDownloading(false);+ setIsInstalling(false);+ toast({+ title: "Update Error",+ description: "Failed to update. Please try again later.",+ variant: "destructive",+ });+ };++ const handleDownloadProgress = (_event: any, progressObj: any) => {+ if (progressObj?.percent) {+ setDownloadProgress(Math.round(progressObj.percent));+ }};const disposers = [window.electronAPI.onUpdateAvailable(handleUpdateAvailable),window.electronAPI.onUpdateDownloaded(handleUpdateDownloaded),window.electronAPI.onUpdateError(handleUpdateError),+ window.electronAPI.onUpdateDownloadProgress(handleDownloadProgress),];// Cleanup listeners on unmount@@ -162,6 +185,91 @@ export default function ControlPanel() {});};+ const handleUpdateClick = async () => {+ if (updateStatus.updateDownloaded) {+ // Show confirmation dialog before installing+ showConfirmDialog({+ title: "Install Update",+ description:+ "The update will be installed and the app will restart. Make sure you've saved any work.",+ onConfirm: async () => {+ setIsInstalling(true);+ try {+ await window.electronAPI.installUpdate();+ // Set a timeout to show an alert if the app doesn't restart+ setTimeout(() => {+ if (isInstalling) {+ setIsInstalling(false);+ showAlertDialog({+ title: "Update Installation",+ description:+ "The app may not have restarted automatically. Please quit and reopen the app to complete the update.",+ });+ }+ }, 10000);+ } catch (error) {+ setIsInstalling(false);+ toast({+ title: "Install Failed",+ description: "Failed to install update. Please try again.",+ variant: "destructive",+ });+ }+ },+ });+ } else if (updateStatus.updateAvailable && !isDownloading) {+ // Start download+ setIsDownloading(true);+ setDownloadProgress(0);+ try {+ await window.electronAPI.downloadUpdate();+ } catch (error) {+ setIsDownloading(false);+ toast({+ title: "Download Failed",+ description: "Failed to download update. Please try again.",+ variant: "destructive",+ });+ }+ }+ };++ const getUpdateButtonContent = () => {+ if (isInstalling) {+ return (+ <>+ <Loader2 size={14} className="animate-spin" />+ <span>Installing...</span>+ </>+ );+ }+ if (isDownloading) {+ return (+ <>+ <Loader2 size={14} className="animate-spin" />+ <span>{downloadProgress}%</span>+ </>+ );+ }+ if (updateStatus.updateDownloaded) {+ return (+ <>+ <RefreshCw size={14} />+ <span>Install Update</span>+ </>+ );+ }+ if (updateStatus.updateAvailable) {+ return (+ <>+ <Download size={14} />+ <span>Update Available</span>+ </>+ );+ }+ return null;+ };+return (<div className="min-h-screen bg-white"><ConfirmDialog@@ -184,13 +292,27 @@ export default function ControlPanel() {<TitleBaractions={<>- {/* Update notification badge */}+ {/* Update button */}{!updateStatus.isDevelopment &&(updateStatus.updateAvailable ||- updateStatus.updateDownloaded) && (- <div className="relative">- <div className="absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full"></div>- </div>+ updateStatus.updateDownloaded ||+ isDownloading ||+ isInstalling) && (+ <Button+ variant={updateStatus.updateDownloaded ? "default" : "outline"}+ size="sm"+ onClick={handleUpdateClick}+ disabled={isInstalling}+ className={`gap-1.5 text-xs ${+ updateStatus.updateDownloaded+ ? "bg-blue-600 hover:bg-blue-700 text-white"+ : isDownloading+ ? "border-blue-300 text-blue-600"+ : "border-blue-300 text-blue-600 hover:bg-blue-50"+ }`}+ >+ {getUpdateButtonContent()}+ </Button>)}<SupportDropdown /><Button