Cosmo Docs
Desktop App

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:

ParamValue
versionCurrent app version (from app.getVersion())
platformdarwin / win32 / linux
archx64 / arm64
channelstable (default) / beta / canary
clientIdStable 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:

ChannelDescription
updates:get-statusReturns current UpdateStatus
updates:checkTrigger an immediate check
updates:downloadStart downloading
updates:installQuit and install
updates:statusSubscribe to status change events

The UpdateCard component in Sidebar.tsx listens for status changes and shows appropriate CTAs (Download, Install & Restart).