UpdateManager
Auto-update polling and installation lifecycle
packages/desktop/src/main/update-manager.ts manages the full desktop app update lifecycle — checking for new releases, downloading, and installing them.
Architecture
Updates are served from the Cosmo backend rather than direct distribution CDNs. The desktop polls the server, which applies rollout bucketing and channel routing before returning a download URL.
Auto-updates use electron-updater for the actual download and install mechanism. The UpdateManager acts as a controller that decides when to invoke electron-updater.
Update Status
type UpdateStatus =
| 'idle'
| 'checking'
| 'available'
| 'not-available'
| 'downloading'
| 'downloaded'
| 'error';Status changes are pushed to the renderer via the updates:status IPC event and the UpdateCard component in the sidebar renders current state.
Client ID
A stable client ID is generated once on first launch and stored in userData/.cosmo-client-id. It is sent with every update check so the server can deterministically include or exclude this client in a partial rollout (e.g. rolloutPercentage: 20).
Methods
start(intervalMs?)
Starts a polling loop. Default interval: 30 minutes. On first call it immediately checks for updates, then repeats on the interval.
checkForUpdates()
Calls GET /api/v1/updates/check with query params:
| Param | Value |
|---|---|
version | Current app version (from app.getVersion()) |
platform | darwin / win32 / linux |
arch | x64 / arm64 |
channel | stable (default) / beta / canary |
clientId | Stable per-device ID |
If an update is available, status transitions to 'available' and the renderer is notified.
downloadUpdate()
Calls electron-updater's downloadUpdate(). Status transitions 'downloading' → 'downloaded' when complete.
quitAndInstall()
Calls autoUpdater.quitAndInstall(). The app relaunches with the new version applied.
Renderer Integration
The renderer accesses update state via the IPC bridge:
| Channel | Description |
|---|---|
updates:get-status | Returns current UpdateStatus |
updates:check | Trigger an immediate check |
updates:download | Start downloading |
updates:install | Quit and install |
updates:status | Subscribe to status change events |
The UpdateCard component in Sidebar.tsx listens for status changes and shows appropriate CTAs (Download, Install & Restart).