diff --git a/crates/lanspread-peer/src/handlers.rs b/crates/lanspread-peer/src/handlers.rs index 23c2f53..7da859b 100644 --- a/crates/lanspread-peer/src/handlers.rs +++ b/crates/lanspread-peer/src/handlers.rs @@ -251,6 +251,9 @@ pub async fn handle_download_game_files_command( log::error!( "No validated file descriptions available to download game {id}; request metadata first" ); + if let Err(send_err) = tx_notify_ui.send(PeerEvent::DownloadGameFilesFailed { id }) { + log::error!("Failed to send DownloadGameFilesFailed event: {send_err}"); + } return; } @@ -277,6 +280,11 @@ pub async fn handle_download_game_files_command( } } else { log::error!("No trusted peers available after majority validation for game {id}"); + if let Err(send_err) = + tx_notify_ui.send(PeerEvent::DownloadGameFilesFailed { id: id.clone() }) + { + log::error!("Failed to send DownloadGameFilesFailed event: {send_err}"); + } } return; } diff --git a/crates/lanspread-tauri-deno-ts/src/hooks/useGames.ts b/crates/lanspread-tauri-deno-ts/src/hooks/useGames.ts index 92c717e..de6fcbb 100644 --- a/crates/lanspread-tauri-deno-ts/src/hooks/useGames.ts +++ b/crates/lanspread-tauri-deno-ts/src/hooks/useGames.ts @@ -132,11 +132,15 @@ export const useGames = (rescanGameDir: () => void): UseGamesResult => { }); })); + // 'game-download-pre' confirms peer metadata was found. The backend may still + // reject the download during majority validation (which now emits a terminal fail event), + // so keep showing CheckingPeers until 'game-download-begin' reports that transfer started. unlisteners.push(await listen('game-download-pre', (e) => { const id = e.payload as string; - updateById(id, { install_status: InstallStatus.Downloading, clearStatus: true }); + updateById(id, { install_status: InstallStatus.CheckingPeers, clearStatus: true }); })); + // 'game-download-begin' signals consensus size validation has completed and file transfer has started. unlisteners.push(await listen('game-download-begin', (e) => { const id = e.payload as string; updateById(id, { install_status: InstallStatus.Downloading, clearStatus: true });