FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.
C++ ai-agentsalgorithmic-tradingbloomberg-terminalcppfinancefinancial-marketsfintechgood-first-issueinvestmentinvestment-researchmachine-learningopensourcepythonqtquantitative-financestock-markettrading
fix: auto-updater and Python bundling configuration
tilakpatel2274043a318d79
diff --git a/fincept-terminal-desktop/.github/workflows/build-with-updater.yml b/fincept-terminal-desktop/.github/workflows/build-with-updater.ymlindex 81f9b42ff..89f589b03 100644--- a/fincept-terminal-desktop/.github/workflows/build-with-updater.yml+++ b/fincept-terminal-desktop/.github/workflows/build-with-updater.yml@@ -96,3 +96,4 @@ jobs:prerelease: falseargs: ${{ matrix.args }}includeUpdaterJson: true+ updaterJsonKeepUniversal: truediff --git a/fincept-terminal-desktop/.gitignore b/fincept-terminal-desktop/.gitignoreindex d1b9a0158..4e1c7b9db 100644--- a/fincept-terminal-desktop/.gitignore+++ b/fincept-terminal-desktop/.gitignore@@ -26,8 +26,25 @@ dist-ssrsrc/services/node_modulessrc-tauri/target-# Python embeddable package (download separately)-src-tauri/resources/python/+# Python embeddable package - include the executables and core files+# But ignore large library directories to keep repo size manageable+src-tauri/resources/python/Lib/*+!src-tauri/resources/python/Lib/site-packages/+src-tauri/resources/python/Scripts/*+!src-tauri/resources/python/Scripts/*.exe+# Always include these critical files:+!src-tauri/resources/python/python.exe+!src-tauri/resources/python/python312.dll+!src-tauri/resources/python/*.pyd+!src-tauri/resources/python/*.zip+!src-tauri/resources/python/*.txt+!src-tauri/resources/python/*.py+!src-tauri/resources/python/_pth++# Bun executable - always include+!src-tauri/resources/bun/bun.exe++# Scripts should always be included!src-tauri/resources/scripts/fincept-terminal-desktop/nul"**/.claude/"diff --git a/fincept-terminal-desktop/package.json b/fincept-terminal-desktop/package.jsonindex 9f7434393..ec8358477 100644--- a/fincept-terminal-desktop/package.json+++ b/fincept-terminal-desktop/package.json@@ -1,13 +1,14 @@{"name": "fincept-terminal-desktop","private": true,- "version": "3.0.0",+ "version": "3.0.10","type": "module","scripts": {"dev": "vite","build": "tsc && vite build","preview": "vite preview",- "tauri": "tauri"+ "tauri": "tauri",+ "bump-version": "node scripts/bump-version.js"},"dependencies": {"@langchain/community": "^0.3.56",diff --git a/fincept-terminal-desktop/scripts/bump-version.js b/fincept-terminal-desktop/scripts/bump-version.jsnew file mode 100644index 000000000..bf52824de--- /dev/null+++ b/fincept-terminal-desktop/scripts/bump-version.js@@ -0,0 +1,117 @@+#!/usr/bin/env node++/**+ * Version Bump Script for Fincept Terminal+ *+ * Usage:+ * node scripts/bump-version.js <new-version>+ * npm run bump-version <new-version>+ *+ * Example:+ * node scripts/bump-version.js 3.0.11+ *+ * This script updates version numbers across all configuration files:+ * - package.json+ * - src-tauri/tauri.conf.json+ * - src-tauri/Cargo.toml+ */++const fs = require('fs');+const path = require('path');++// Get the new version from command line arguments+const newVersion = process.argv[2];++if (!newVersion) {+ console.error('❌ Error: No version specified');+ console.log('Usage: node scripts/bump-version.js <version>');+ console.log('Example: node scripts/bump-version.js 3.0.11');+ process.exit(1);+}++// Validate version format (semantic versioning: x.y.z)+const versionRegex = /^\d+\.\d+\.\d+$/;+if (!versionRegex.test(newVersion)) {+ console.error('❌ Error: Invalid version format');+ console.log('Version must follow semantic versioning format: x.y.z');+ console.log('Example: 3.0.11');+ process.exit(1);+}++console.log(`\n🚀 Bumping version to ${newVersion}...\n`);++// File paths+const rootDir = path.join(__dirname, '..');+const packageJsonPath = path.join(rootDir, 'package.json');+const tauriConfPath = path.join(rootDir, 'src-tauri', 'tauri.conf.json');+const cargoTomlPath = path.join(rootDir, 'src-tauri', 'Cargo.toml');++let successCount = 0;+let failCount = 0;++// Update package.json+try {+ console.log('📦 Updating package.json...');+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));+ const oldVersion = packageJson.version;+ packageJson.version = newVersion;+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');+ console.log(` ✅ Updated from ${oldVersion} to ${newVersion}`);+ successCount++;+} catch (error) {+ console.error(` ❌ Failed to update package.json: ${error.message}`);+ failCount++;+}++// Update tauri.conf.json+try {+ console.log('⚙️ Updating src-tauri/tauri.conf.json...');+ const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8'));+ const oldVersion = tauriConf.version;+ tauriConf.version = newVersion;+ fs.writeFileSync(tauriConfPath, JSON.stringify(tauriConf, null, 2) + '\n');+ console.log(` ✅ Updated from ${oldVersion} to ${newVersion}`);+ successCount++;+} catch (error) {+ console.error(` ❌ Failed to update tauri.conf.json: ${error.message}`);+ failCount++;+}++// Update Cargo.toml+try {+ console.log('🦀 Updating src-tauri/Cargo.toml...');+ let cargoToml = fs.readFileSync(cargoTomlPath, 'utf8');+ const versionMatch = cargoToml.match(/^version = "([^"]+)"/m);++ if (versionMatch) {+ const oldVersion = versionMatch[1];+ cargoToml = cargoToml.replace(+ /^version = "[^"]+"/m,+ `version = "${newVersion}"`+ );+ fs.writeFileSync(cargoTomlPath, cargoToml);+ console.log(` ✅ Updated from ${oldVersion} to ${newVersion}`);+ successCount++;+ } else {+ throw new Error('Version line not found in Cargo.toml');+ }+} catch (error) {+ console.error(` ❌ Failed to update Cargo.toml: ${error.message}`);+ failCount++;+}++// Summary+console.log('\n' + '='.repeat(50));+if (failCount === 0) {+ console.log(`✨ Version bump complete! ${successCount}/3 files updated successfully.`);+ console.log(`\n📋 Next steps:`);+ console.log(` 1. Review the changes: git diff`);+ console.log(` 2. Commit the changes: git add . && git commit -m "chore: bump version to ${newVersion}"`);+ console.log(` 3. Create a tag: git tag v${newVersion}`);+ console.log(` 4. Push: git push && git push --tags`);+ console.log(` 5. GitHub Actions will automatically build and create a release`);+} else {+ console.error(`⚠️ Version bump completed with errors: ${successCount} succeeded, ${failCount} failed`);+ console.error('Please fix the errors and try again.');+ process.exit(1);+}diff --git a/fincept-terminal-desktop/src-tauri/Cargo.toml b/fincept-terminal-desktop/src-tauri/Cargo.tomlindex 8ec0e158f..81c3668f4 100644--- a/fincept-terminal-desktop/src-tauri/Cargo.toml+++ b/fincept-terminal-desktop/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "fincept-terminal-desktop"-version = "3.0.0"+version = "3.0.10"description = "Professional-grade financial analysis platform with AI-powered insights and real-time market data"authors = ["Fincept Corporation <[email protected]>"]edition = "2021"diff --git a/fincept-terminal-desktop/src-tauri/tauri.conf.json b/fincept-terminal-desktop/src-tauri/tauri.conf.jsonindex 89facd9ca..081993d95 100644--- a/fincept-terminal-desktop/src-tauri/tauri.conf.json+++ b/fincept-terminal-desktop/src-tauri/tauri.conf.json@@ -1,7 +1,7 @@{"$schema": "https://schema.tauri.app/config/2","productName": "FinceptTerminal",- "version": "3.0.0",+ "version": "3.0.10","identifier": "com.fincept.terminal","build": {"beforeDevCommand": "npm run dev",diff --git a/fincept-terminal-desktop/src/components/common/AutoUpdater.tsx b/fincept-terminal-desktop/src/components/common/AutoUpdater.tsxnew file mode 100644index 000000000..43987f520--- /dev/null+++ b/fincept-terminal-desktop/src/components/common/AutoUpdater.tsx@@ -0,0 +1,274 @@+import { useEffect, useState } from 'react';+import { check, Update } from '@tauri-apps/plugin-updater';+import { relaunch } from '@tauri-apps/plugin-process';+import { Button } from '@/components/ui/button';+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@/components/ui/dialog';+import { Progress } from '@/components/ui/progress';+import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';+import { Download, RefreshCw, CheckCircle2, XCircle, Info } from 'lucide-react';++interface AutoUpdaterProps {+ checkOnMount?: boolean;+ checkIntervalMinutes?: number;+}++export function AutoUpdater({ checkOnMount = true, checkIntervalMinutes = 30 }: AutoUpdaterProps) {+ const [updateAvailable, setUpdateAvailable] = useState(false);+ const [updateInfo, setUpdateInfo] = useState<Update | null>(null);+ const [downloading, setDownloading] = useState(false);+ const [downloadProgress, setDownloadProgress] = useState(0);+ const [error, setError] = useState<string | null>(null);+ const [checking, setChecking] = useState(false);+ const [showDialog, setShowDialog] = useState(false);+ const [updateReady, setUpdateReady] = useState(false);++ const checkForUpdates = async (silent = false) => {+ try {+ setChecking(true);+ setError(null);++ console.log('[AutoUpdater] Checking for updates...');+ const update = await check();++ if (update?.available) {+ console.log(`[AutoUpdater] Update available: v${update.version}`);+ console.log(`[AutoUpdater] Current version: v${update.currentVersion}`);+ console.log(`[AutoUpdater] Release date: ${update.date}`);++ setUpdateInfo(update);+ setUpdateAvailable(true);++ if (!silent) {+ setShowDialog(true);+ }+ } else {+ console.log('[AutoUpdater] No updates available');++ if (!silent) {+ // Show a brief notification that app is up to date+ setError('You are running the latest version!');+ setTimeout(() => setError(null), 3000);+ }+ }+ } catch (err) {+ const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred';+ console.error('[AutoUpdater] Error checking for updates:', errorMessage);++ // Only show error if it's not a silent check and not a network error+ if (!silent && !errorMessage.includes('network')) {+ setError(`Failed to check for updates: ${errorMessage}`);+ }+ } finally {+ setChecking(false);+ }+ };++ const downloadAndInstall = async () => {+ if (!updateInfo) return;++ try {+ setDownloading(true);+ setError(null);+ setDownloadProgress(0);++ console.log('[AutoUpdater] Starting download and installation...');++ // Download and install with progress tracking+ await updateInfo.downloadAndInstall((event) => {+ switch (event.event) {+ case 'Started':+ console.log(`[AutoUpdater] Download started - Total size: ${event.data.contentLength} bytes`);+ setDownloadProgress(0);+ break;+ case 'Progress':+ const progress = (event.data.chunkLength / (event.data.contentLength || 1)) * 100;+ console.log(`[AutoUpdater] Download progress: ${progress.toFixed(2)}%`);+ setDownloadProgress(progress);+ break;+ case 'Finished':+ console.log('[AutoUpdater] Download finished, installing...');+ setDownloadProgress(100);+ break;+ }+ });++ console.log('[AutoUpdater] Update installed successfully! Preparing to relaunch...');+ setUpdateReady(true);++ // Auto-relaunch after 2 seconds+ setTimeout(async () => {+ console.log('[AutoUpdater] Relaunching application...');+ await relaunch();+ }, 2000);++ } catch (err) {+ const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred';+ console.error('[AutoUpdater] Error during download/install:', errorMessage);+ setError(`Failed to install update: ${errorMessage}`);+ setDownloading(false);+ }+ };++ const handleLater = () => {+ setShowDialog(false);+ console.log('[AutoUpdater] Update postponed by user');+ };++ // Check for updates on mount+ useEffect(() => {+ if (checkOnMount) {+ // Delay initial check by 3 seconds to not interfere with app startup+ const timer = setTimeout(() => {+ checkForUpdates(true);+ }, 3000);++ return () => clearTimeout(timer);+ }+ }, [checkOnMount]);++ // Set up periodic update checks+ useEffect(() => {+ if (checkIntervalMinutes > 0) {+ const interval = setInterval(() => {+ checkForUpdates(true);+ }, checkIntervalMinutes * 60 * 1000);++ return () => clearInterval(interval);+ }+ }, [checkIntervalMinutes]);++ return (+ <>+ {/* Update Dialog */}+ <Dialog open={showDialog} onOpenChange={setShowDialog}>+ <DialogContent className="sm:max-w-[500px]">+ <DialogHeader>+ <DialogTitle className="flex items-center gap-2">+ <Download className="h-5 w-5" />+ Update Available+ </DialogTitle>+ <DialogDescription>+ A new version of FinceptTerminal is available.+ </DialogDescription>+ </DialogHeader>++ <div className="space-y-4 py-4">+ {updateInfo && (+ <div className="space-y-2">+ <div className="flex justify-between text-sm">+ <span className="text-muted-foreground">Current Version:</span>+ <span className="font-mono">{updateInfo.currentVersion}</span>+ </div>+ <div className="flex justify-between text-sm">+ <span className="text-muted-foreground">New Version:</span>+ <span className="font-mono font-bold text-green-600">{updateInfo.version}</span>+ </div>+ <div className="flex justify-between text-sm">+ <span className="text-muted-foreground">Release Date:</span>+ <span>{updateInfo.date ? new Date(updateInfo.date).toLocaleDateString() : 'N/A'}</span>+ </div>+ </div>+ )}++ {updateInfo?.body && (+ <div className="rounded-md bg-muted p-3 text-sm">+ <p className="font-semibold mb-2">Release Notes:</p>+ <p className="text-muted-foreground whitespace-pre-wrap">{updateInfo.body}</p>+ </div>+ )}++ {downloading && (+ <div className="space-y-2">+ <div className="flex items-center justify-between text-sm">+ <span>Downloading update...</span>+ <span>{downloadProgress.toFixed(0)}%</span>+ </div>+ <Progress value={downloadProgress} />+ </div>+ )}++ {updateReady && (+ <Alert className="border-green-500 bg-green-50 dark:bg-green-950">+ <CheckCircle2 className="h-4 w-4 text-green-600" />+ <AlertTitle>Update Ready!</AlertTitle>+ <AlertDescription>+ The application will restart in a moment...+ </AlertDescription>+ </Alert>+ )}++ {error && (+ <Alert variant="destructive">+ <XCircle className="h-4 w-4" />+ <AlertTitle>Error</AlertTitle>+ <AlertDescription>{error}</AlertDescription>+ </Alert>+ )}+ </div>++ <DialogFooter>+ {!downloading && !updateReady && (+ <>+ <Button variant="outline" onClick={handleLater}>+ Later+ </Button>+ <Button onClick={downloadAndInstall} disabled={downloading}>+ <Download className="mr-2 h-4 w-4" />+ Download & Install+ </Button>+ </>+ )}+ {downloading && (+ <Button disabled>+ <RefreshCw className="mr-2 h-4 w-4 animate-spin" />+ Installing...+ </Button>+ )}+ </DialogFooter>+ </DialogContent>+ </Dialog>++ {/* Manual Check Button (can be placed in settings/menu) */}+ <Button+ variant="ghost"+ size="sm"+ onClick={() => checkForUpdates(false)}+ disabled={checking || downloading}+ className="gap-2"+ >+ {checking ? (+ <>+ <RefreshCw className="h-4 w-4 animate-spin" />+ Checking...+ </>+ ) : (+ <>+ <Info className="h-4 w-4" />+ Check for Updates+ </>+ )}+ </Button>++ {/* Success/Error Toast */}+ {error && !showDialog && (+ <div className="fixed bottom-4 right-4 z-50 max-w-md">+ <Alert className={error.includes('latest version') ? 'border-green-500' : 'border-red-500'}>+ {error.includes('latest version') ? (+ <CheckCircle2 className="h-4 w-4 text-green-600" />+ ) : (+ <XCircle className="h-4 w-4" />+ )}+ <AlertDescription>{error}</AlertDescription>+ </Alert>+ </div>+ )}+ </>+ );+}diff --git a/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx b/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsxindex 418f2dddd..320ae970b 100644--- a/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx+++ b/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx@@ -1,12 +1,14 @@import React, { useState, useRef, useEffect } from 'react';import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';-import { Maximize, Minimize, Download, Settings, RefreshCw, User, Database, Eye, HelpCircle, LogOut } from 'lucide-react';+import { Maximize, Minimize, Download, Settings, RefreshCw, User, Database, Eye, HelpCircle, LogOut, CheckCircle2, XCircle } from 'lucide-react';import { useAuth } from '@/contexts/AuthContext';import { useNavigation } from '@/contexts/NavigationContext';import { APP_VERSION } from '@/constants/version';import { useAutoUpdater } from '@/hooks/useAutoUpdater';import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';import { Button } from '@/components/ui/button';+import { Progress } from '@/components/ui/progress';+import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';import ForumTab from '@/components/tabs/ForumTab';import DashboardTab from '@/components/tabs/DashboardTab';import MarketsTab from '@/components/tabs/MarketsTab';@@ -123,7 +125,7 @@ export default function FinxeptTerminal() {const [activeTab, setActiveTab] = useState("dashboard");const [isFullscreen, setIsFullscreen] = useState(false);const [statusMessage, setStatusMessage] = useState("");- const { updateAvailable, updateInfo, installUpdate, dismissUpdate } = useAutoUpdater();+ const { updateAvailable, updateInfo, isInstalling, installProgress, error, installUpdate, dismissUpdate } = useAutoUpdater();React.useEffect(() => {document.body.style.margin = '0';@@ -858,36 +860,99 @@ export default function FinxeptTerminal() {{/* Update Available Dialog */}<Dialog open={updateAvailable} onOpenChange={(open) => !open && dismissUpdate()}>- <DialogContent className="sm:max-w-[425px]">+ <DialogContent className="sm:max-w-[500px]"><DialogHeader>- <DialogTitle>Update Available</DialogTitle>+ <DialogTitle className="flex items-center gap-2">+ <Download className="h-5 w-5" />+ Update Available+ </DialogTitle><DialogDescription>A new version of FinceptTerminal is available.</DialogDescription></DialogHeader>- <div className="py-4">- <div className="mb-4">- <p className="text-sm font-semibold mb-2">Version: {updateInfo?.version}</p>- {updateInfo?.body && (- <div className="text-sm text-muted-foreground">- <p className="font-semibold mb-1">Release Notes:</p>- <div className="max-h-48 overflow-y-auto bg-muted p-3 rounded-md">- <pre className="whitespace-pre-wrap text-xs">{updateInfo.body}</pre>++ <div className="space-y-4 py-4">+ {updateInfo && (+ <div className="space-y-2">+ <div className="flex justify-between text-sm">+ <span className="text-muted-foreground">Current Version:</span>+ <span className="font-mono">{updateInfo.currentVersion}</span>+ </div>+ <div className="flex justify-between text-sm">+ <span className="text-muted-foreground">New Version:</span>+ <span className="font-mono font-bold text-green-600">{updateInfo.version}</span>+ </div>+ {updateInfo.date && (+ <div className="flex justify-between text-sm">+ <span className="text-muted-foreground">Release Date:</span>+ <span>{new Date(updateInfo.date).toLocaleDateString()}</span></div>+ )}+ </div>+ )}++ {updateInfo?.body && (+ <div className="rounded-md bg-muted p-3 text-sm">+ <p className="font-semibold mb-2">Release Notes:</p>+ <div className="max-h-48 overflow-y-auto">+ <p className="text-muted-foreground whitespace-pre-wrap text-xs">{updateInfo.body}</p></div>- )}- </div>- <p className="text-xs text-muted-foreground">- The update will download and install automatically. Your app will restart after installation.- </p>+ </div>+ )}++ {isInstalling && (+ <div className="space-y-2">+ <div className="flex items-center justify-between text-sm">+ <span>{installProgress === 100 ? 'Installing...' : 'Downloading...'}</span>+ <span>{installProgress.toFixed(0)}%</span>+ </div>+ <Progress value={installProgress} />+ </div>+ )}++ {installProgress === 100 && isInstalling && (+ <Alert className="border-green-500 bg-green-50 dark:bg-green-950">+ <CheckCircle2 className="h-4 w-4 text-green-600" />+ <AlertTitle>Update Ready!</AlertTitle>+ <AlertDescription>+ The application will restart in a moment...+ </AlertDescription>+ </Alert>+ )}++ {error && (+ <Alert variant="destructive">+ <XCircle className="h-4 w-4" />+ <AlertTitle>Error</AlertTitle>+ <AlertDescription>{error}</AlertDescription>+ </Alert>+ )}++ {!isInstalling && (+ <p className="text-xs text-muted-foreground">+ The update will download and install automatically. Your app will restart after installation.+ </p>+ )}</div>+<DialogFooter>- <Button variant="outline" onClick={dismissUpdate}>- Later- </Button>- <Button onClick={installUpdate}>- Update Now- </Button>+ {!isInstalling && !error && (+ <>+ <Button variant="outline" onClick={dismissUpdate}>+ Later+ </Button>+ <Button onClick={installUpdate}>+ <Download className="mr-2 h-4 w-4" />+ Update Now+ </Button>+ </>+ )}+ {isInstalling && (+ <Button disabled>+ <RefreshCw className="mr-2 h-4 w-4 animate-spin" />+ {installProgress === 100 ? 'Installing...' : 'Downloading...'}+ </Button>+ )}</DialogFooter></DialogContent></Dialog>diff --git a/fincept-terminal-desktop/src/hooks/useAutoUpdater.ts b/fincept-terminal-desktop/src/hooks/useAutoUpdater.tsindex adad69c2a..3fc99bc7e 100644--- a/fincept-terminal-desktop/src/hooks/useAutoUpdater.ts+++ b/fincept-terminal-desktop/src/hooks/useAutoUpdater.ts@@ -2,13 +2,17 @@ import { useEffect, useState } from 'react';import { check, type Update } from '@tauri-apps/plugin-updater';import { relaunch } from '@tauri-apps/plugin-process';-const SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds+const CHECK_INTERVAL_MS = 30 * 60 * 1000; // Check every 30 minutesconst LAST_CHECK_KEY = 'updater_last_check';+const DISMISSED_VERSION_KEY = 'updater_dismissed_version';interface UseAutoUpdaterReturn {updateAvailable: boolean;updateInfo: Update | null;isChecking: boolean;+ isInstalling: boolean;+ installProgress: number;+ error: string | null;checkForUpdate: () => Promise<void>;installUpdate: () => Promise<void>;dismissUpdate: () => void;@@ -18,16 +22,33 @@ export function useAutoUpdater(): UseAutoUpdaterReturn {const [updateAvailable, setUpdateAvailable] = useState(false);const [updateInfo, setUpdateInfo] = useState<Update | null>(null);const [isChecking, setIsChecking] = useState(false);+ const [isInstalling, setIsInstalling] = useState(false);+ const [installProgress, setInstallProgress] = useState(0);+ const [error, setError] = useState<string | null>(null);const checkForUpdate = async (silent = false) => {try {setIsChecking(true);+ setError(null);+ console.log('[AutoUpdater] Checking for updates...');const update = await check();if (update?.available) {- console.log(`[Updater] Update available: v${update.version}`);- console.log(`[Updater] Release notes: ${update.body}`);+ console.log(`[AutoUpdater] Update available: v${update.version}`);+ console.log(`[AutoUpdater] Current version: v${update.currentVersion}`);+ console.log(`[AutoUpdater] Release date: ${update.date}`);+ console.log(`[AutoUpdater] Release notes: ${update.body}`);++ // Check if this version was previously dismissed+ const dismissedVersion = localStorage.getItem(DISMISSED_VERSION_KEY);+ if (dismissedVersion === update.version) {+ console.log('[AutoUpdater] Update was previously dismissed by user');+ if (!silent) {+ setError('This update was previously dismissed. A new update will be shown when available.');+ }+ return;+ }setUpdateInfo(update);setUpdateAvailable(true);@@ -35,12 +56,20 @@ export function useAutoUpdater(): UseAutoUpdaterReturn {// Update last check timestamplocalStorage.setItem(LAST_CHECK_KEY, Date.now().toString());} else {+ console.log('[AutoUpdater] No updates available - you are on the latest version');if (!silent) {- console.log('[Updater] No updates available');+ setError('You are running the latest version!');+ setTimeout(() => setError(null), 3000);}}- } catch (error) {- console.error('[Updater] Error checking for updates:', error);+ } catch (err) {+ const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred';+ console.error('[AutoUpdater] Error checking for updates:', errorMessage);++ // Only show error if it's not a network-related error or if not silent+ if (!silent && !errorMessage.toLowerCase().includes('network') && !errorMessage.toLowerCase().includes('fetch')) {+ setError(`Failed to check for updates: ${errorMessage}`);+ }} finally {setIsChecking(false);}@@ -48,62 +77,97 @@ export function useAutoUpdater(): UseAutoUpdaterReturn {const installUpdate = async () => {if (!updateInfo) {- console.error('[Updater] No update info available');+ console.error('[AutoUpdater] No update info available');+ setError('No update information available');return;}try {- console.log('[Updater] Downloading and installing update...');- await updateInfo.downloadAndInstall();-- console.log('[Updater] Update installed, relaunching app...');- await relaunch();- } catch (error) {- console.error('[Updater] Error installing update:', error);+ setIsInstalling(true);+ setInstallProgress(0);+ setError(null);++ console.log('[AutoUpdater] Starting download and installation...');++ // Download and install with progress tracking+ await updateInfo.downloadAndInstall((event) => {+ switch (event.event) {+ case 'Started':+ console.log(`[AutoUpdater] Download started - Size: ${event.data.contentLength} bytes`);+ setInstallProgress(0);+ break;+ case 'Progress':+ const progress = (event.data.chunkLength / (event.data.contentLength || 1)) * 100;+ console.log(`[AutoUpdater] Download progress: ${progress.toFixed(2)}%`);+ setInstallProgress(Math.min(progress, 100));+ break;+ case 'Finished':+ console.log('[AutoUpdater] Download complete, installing...');+ setInstallProgress(100);+ break;+ }+ });++ console.log('[AutoUpdater] Update installed successfully!');+ console.log('[AutoUpdater] Relaunching application in 2 seconds...');++ // Give user a moment to see the success message+ setTimeout(async () => {+ try {+ await relaunch();+ } catch (relaunchError) {+ console.error('[AutoUpdater] Failed to relaunch:', relaunchError);+ setError('Update installed but failed to relaunch. Please restart manually.');+ setIsInstalling(false);+ }+ }, 2000);++ } catch (err) {+ const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred';+ console.error('[AutoUpdater] Error installing update:', errorMessage);+ setError(`Failed to install update: ${errorMessage}`);+ setIsInstalling(false);+ setInstallProgress(0);}};const dismissUpdate = () => {+ if (updateInfo?.version) {+ // Store the dismissed version so we don't show it again+ localStorage.setItem(DISMISSED_VERSION_KEY, updateInfo.version);+ console.log(`[AutoUpdater] Update v${updateInfo.version} dismissed by user`);+ }setUpdateAvailable(false);setUpdateInfo(null);+ setError(null);};useEffect(() => {- // Check if we should run an update check- const shouldCheckForUpdate = () => {- const lastCheck = localStorage.getItem(LAST_CHECK_KEY);-- if (!lastCheck) {- return true; // First time, check immediately- }-- const lastCheckTime = parseInt(lastCheck, 10);- const timeSinceLastCheck = Date.now() - lastCheckTime;-- return timeSinceLastCheck >= SEVEN_DAYS_MS;- };-- // Perform initial check on mount if needed- if (shouldCheckForUpdate()) {- console.log('[Updater] Performing background update check...');+ // Perform initial check on mount (delayed by 5 seconds to not interfere with app startup)+ const initialCheckTimer = setTimeout(() => {+ console.log('[AutoUpdater] Performing initial background update check...');checkForUpdate(true);- }+ }, 5000);- // Set up periodic checks every 7 days+ // Set up periodic checks every 30 minutesconst interval = setInterval(() => {- if (shouldCheckForUpdate()) {- console.log('[Updater] Performing scheduled update check...');- checkForUpdate(true);- }- }, SEVEN_DAYS_MS);+ console.log('[AutoUpdater] Performing periodic update check...');+ checkForUpdate(true);+ }, CHECK_INTERVAL_MS);- return () => clearInterval(interval);+ return () => {+ clearTimeout(initialCheckTimer);+ clearInterval(interval);+ };}, []);return {updateAvailable,updateInfo,isChecking,+ isInstalling,+ installProgress,+ error,checkForUpdate: () => checkForUpdate(false),installUpdate,dismissUpdate,