diff --git a/desktop/main.js b/desktop/main.js index 1ec6960..b1ce812 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -465,6 +465,24 @@ function configureSession() { let target = path.join(dir, name), n = 1; while (fs.existsSync(target)) target = path.join(dir, `${base} (${n++})${ext}`); item.setSavePath(target); + // Since we suppressed the save dialog, the download would otherwise be completely silent. Give feedback + // when it finishes: a notification (click → reveal the file in Explorer) so the user knows it saved and + // where. Also tell the web UI so it can show its own toast. On failure, say so. + item.once('done', (_ev, state) => { + try { + const ok = state === 'completed'; + const savedName = ok ? path.basename(target) : (item.getFilename() || 'file'); + // Always tell the web UI (it shows a branded toast when the window is up). + try { if (win && !win.isDestroyed()) win.webContents.send('download-done', { name: savedName, path: ok ? target : '', ok }); } catch (_) {} + // If the window is focused, that toast is enough — skip the native notification to avoid a double + // notice. If the app is minimized/in the tray, show a native notification instead (click → reveal). + const focused = win && !win.isDestroyed() && win.isVisible() && win.isFocused(); + if (!focused && Notification.isSupported()) { + if (ok) { const note = new Notification({ title: 'Download complete', body: savedName + ' — saved to your Downloads folder. Click to show it.' }); note.on('click', () => { try { shell.showItemInFolder(target); } catch (_) {} }); note.show(); } + else new Notification({ title: 'Download failed', body: savedName + ' could not be saved.' }).show(); + } + } catch (_) {} + }); } catch (_) {} }); } diff --git a/desktop/package.json b/desktop/package.json index ff38dff..ad0192f 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -1,6 +1,6 @@ { "name": "biz-connect-desktop", - "version": "0.1.19", + "version": "0.1.20", "description": "Biz Connect technician desktop client — loads the Connect web UI with native screen capture", "author": { "name": "BizGaze", diff --git a/desktop/preload.js b/desktop/preload.js index 7a0c486..9b9d15a 100644 --- a/desktop/preload.js +++ b/desktop/preload.js @@ -43,5 +43,6 @@ contextBridge.exposeInMainWorld('bizConnectNative', Object.freeze({ // #3: subscribe to auto-update lifecycle events so the UI can show download progress + "ready". // cb receives {phase:'checking'|'available'|'downloading'|'ready'|'current'|'error', percent?, version?}. onUpdateEvent: (cb) => { try { ipcRenderer.on('update-event', (_e, data) => { try { cb(data); } catch (_) {} }); } catch (_) {} }, + onDownloadDone: (cb) => { try { ipcRenderer.on('download-done', (_e, data) => { try { cb(data); } catch (_) {} }); } catch (_) {} }, // desktop: a file finished downloading to the Downloads folder → show a toast restartToUpdate: () => ipcRenderer.invoke('restart-to-update'), })); diff --git a/server/public/home.html b/server/public/home.html index ffcaf4a..5eaa8cf 100644 --- a/server/public/home.html +++ b/server/public/home.html @@ -1158,7 +1158,7 @@ -