# Biz Connect Desktop — packaging & updates

## How updates reach installed apps (two kinds)

1. **Web / UI / feature / bug-fix changes → instant, no app update.**
   The app loads the live UI from `https://remote.bizgaze.com`. Deploy the server
   (`./deploy.sh`) and every installed desktop app has it on next open/reload. This is ~95%
   of all changes.
2. **Native shell changes (`main.js` / `preload.js`) → auto-update.**
   Baked into the `.exe`. Shipped via **electron-updater** against a **self-hosted feed** on
   `https://remote.bizgaze.com/downloads/`. On launch (and every 6h) the app checks
   `latest.yml`, downloads a newer version in the background, and installs on next restart.

## Build an installer
```bash
cd desktop
npm install
npm run dist          # electron-builder → dist/  (Win: NSIS .exe + latest.yml + .blockmap)
```
Output in `desktop/dist/`:
- `Biz Connect Setup <version>.exe` — the installer
- `latest.yml` — the update manifest electron-updater reads
- `*.blockmap` — enables delta downloads

A PACKAGED build points at production (`main.js` defaults `SERVER_URL` to
`https://remote.bizgaze.com` when `app.isPackaged`); running from source in dev defaults to
`http://localhost:8090`. `SERVER_URL` overrides either.

## Publish a release (self-hosted feed)
1. Bump `version` in `desktop/package.json` (semver — electron-updater compares this).
2. `npm run dist`.
3. Upload **all** of `dist/` (the `.exe`, `latest.yml`, `.blockmap`) to whatever the server
   serves at `https://remote.bizgaze.com/downloads/`.
   - Behind Nginx Proxy Manager: point `/downloads/` at a static folder, or add a static
     route in the app. The files are large binaries — host them on disk/volume, **not** git.
4. Installed apps pick it up within 6h (or on next launch).

> First release: users install the `.exe` manually (download link on your site). Every
> release after that updates automatically.

## Code signing (add when the cert is ready)
Unsigned installers work but trip Windows SmartScreen ("More info → Run anyway"). To sign:
- **Azure Trusted Signing** (recommended): set `win.azureSignOptions` (or use the
  `@electron/windows-sign` path) with the Trusted Signing account/endpoint. Cloud, no token.
- **EV/OV cert (.pfx or token)**: set env `CSC_LINK` (path to .pfx) + `CSC_KEY_PASSWORD`,
  or configure a hardware-token signing tool. electron-builder signs automatically.
Once signing is on, auto-updates are silent (no SmartScreen).

## App identity
`appId` = `com.bizgaze.connect.desktop`; the NSIS installer registers this as the
AppUserModelID and creates a Start-menu shortcut — which is also the prerequisite for the
**Phase D inline-reply Windows Toast notifications** (see ../CLIENTS.md).
