Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(updates): forward progress/error/check events + ready notification

enes308fd2c35bf4
diff --git a/src/main/updater.ts b/src/main/updater.ts
index 56e1e2cda..5994e2312 100644
--- a/src/main/updater.ts
+++ b/src/main/updater.ts
@@ -1,9 +1,10 @@
-// Auto-update client (electron-updater). Only runs in a packaged app; in dev it is a no-op.
-// Flow: check on launch (and periodically) → on `update-available` notify the renderer →
-// when the download finishes, notify again so the banner can offer "Restart to update".
-// On macOS, silent self-install requires a signed + notarized build; unsigned builds still
-// surface the banner so the user can download/install manually.
-import { app, BrowserWindow, ipcMain } from 'electron'
+// Auto-update client (electron-updater). The packaged app downloads updates automatically
+// and forwards the full lifecycle (available → progress → downloaded → error/not-available)
+// to the renderer's UpdateCard. Version lookup, manual check, and restart work in dev too;
+// the automatic feed checks and event wiring are packaged-only. On macOS, silent self-install
+// requires a signed + notarized build; unsigned builds still surface the card for a manual
+// download.
+import { app, BrowserWindow, ipcMain, Notification } from 'electron'
import electronUpdater from 'electron-updater'
import { IPC } from '../shared/ipc'
@@ -12,32 +13,73 @@ const { autoUpdater } = electronUpdater
const SIX_HOURS = 6 * 60 * 60 * 1000
export function initUpdater(win: BrowserWindow): void {
- if (!app.isPackaged) return // dev: no update server, skip entirely
-
- autoUpdater.autoDownload = true
- autoUpdater.autoInstallOnAppQuit = true
-
const send = (channel: string, payload?: unknown) => {
if (!win.isDestroyed()) win.webContents.send(channel, payload)
}
+ // Always available, even in dev: current version, manual check, restart.
+ ipcMain.handle(IPC.appGetVersion, () => app.getVersion())
+ ipcMain.on(IPC.appRestartToUpdate, () => autoUpdater.quitAndInstall())
+
+ if (!app.isPackaged) {
+ // Dev: there is no update server. A manual check reports "up to date" so the Settings
+ // button still gives feedback; automatic checks are skipped entirely.
+ ipcMain.on(IPC.appCheckForUpdates, () => send(IPC.appUpdateNotAvailable))
+ return
+ }
+
+ autoUpdater.autoDownload = true
+ autoUpdater.autoInstallOnAppQuit = true
+
autoUpdater.on('update-available', (info) => {
send(IPC.appUpdateAvailable, { version: info.version, notes: info.releaseNotes ?? '' })
})
+ autoUpdater.on('download-progress', (p) => {
+ send(IPC.appUpdateProgress, {
+ percent: p.percent,
+ transferred: p.transferred,
+ total: p.total,
+ bytesPerSecond: p.bytesPerSecond
+ })
+ })
+
autoUpdater.on('update-downloaded', (info) => {
send(IPC.appUpdateDownloaded, { version: info.version })
+ // OS notification only when the window is in the background; the card covers the foreground.
+ if (!win.isFocused() && Notification.isSupported()) {
+ const n = new Notification({
+ title: 'Update ready',
+ body: `nodeterm ${info.version} is ready to install.`
+ })
+ n.on('click', () => {
+ if (win.isDestroyed()) return
+ if (win.isMinimized()) win.restore()
+ win.show()
+ win.focus()
+ })
+ n.show()
+ }
})
+ autoUpdater.on('update-not-available', () => send(IPC.appUpdateNotAvailable))
+
autoUpdater.on('error', (err) => {
- console.error('[updater]', err?.message ?? err)
+ const message = err?.message ?? String(err)
+ console.error('[updater]', message)
+ send(IPC.appUpdateError, message)
})
- // User accepted the banner → quit and install the staged update.
- ipcMain.on(IPC.appRestartToUpdate, () => {
- autoUpdater.quitAndInstall()
+ // Manual check from Settings; surfaces failures to the card.
+ ipcMain.on(IPC.appCheckForUpdates, () => {
+ autoUpdater.checkForUpdates().catch((err) => {
+ const message = err?.message ?? String(err)
+ console.error('[updater]', message)
+ send(IPC.appUpdateError, message)
+ })
})
+ // Automatic checks: on launch and every six hours.
const check = () => {
autoUpdater.checkForUpdates().catch((err) => console.error('[updater]', err?.message ?? err))
}