Skip to content

feat(updater): auto-update on launch + manual check in Settings#47

Merged
aicayzer merged 1 commit into
mainfrom
feat/auto-updater
May 12, 2026
Merged

feat(updater): auto-update on launch + manual check in Settings#47
aicayzer merged 1 commit into
mainfrom
feat/auto-updater

Conversation

@aicayzer

Copy link
Copy Markdown
Owner

Summary

Now that release builds are signed + notarised, wire electron-updater so installed apps stay current.

Behaviour

  • On launch (production builds only): silent check 4s after the window opens. New releases auto-download in the background. When the download completes a native macOS dialog asks the user to restart; clicking Restart calls autoUpdater.quitAndInstall().
  • Manual check: Settings → About now has an "Updates" row showing the current state and a "Check now" button. States: Not checked yet / Checking… / Up to date / Update available (vX) / Downloading… 30% / Update downloaded (vX) — restart to install / Couldn't check (msg).
  • Dev builds: skip the updater entirely (electron-updater errors on non-packaged apps).

Plumbing

  • src/main/updater.ts — encapsulates the autoUpdater event lifecycle, broadcasts status to all windows.
  • src/main/ipc.tsupdater:status / updater:check handlers.
  • src/preload/api.ts — exposes window.api.updater.{status,check,onStatus}; UpdaterStatus union exported here so both sides share the type.
  • src/renderer/src/screens/Settings.tsx — AboutCard subscribes to push updates on mount.

Other tidy-ups bundled in

  • .github/workflows/codeql.yml — drop the push: branches: [main] trigger. Every change hits main via PR, so the push run just duplicated the PR run. PR + weekly cron + manual dispatch are enough.

Test plan

  • pnpm typecheck && pnpm lint && pnpm format:check && pnpm test clean
  • pnpm exec electron-vite build succeeds locally
  • CI green
  • After merge + a future release: install v0.2.1, then publish v0.2.2 → confirm the running app detects the update, downloads it, and the restart dialog appears
  • Settings → About "Check now" button works on a packaged build

Now that release builds are signed + notarised, wire electron-updater
to keep installs current.

Main process:
- New `src/main/updater.ts` initialises electron-updater on app ready
  (production only — dev builds skip).
- Silent check 4s after launch; auto-downloads new releases in the
  background; native macOS dialog asks the user to restart once a
  download completes; `quitAndInstall` on Restart.
- Status broadcast to all renderer windows via `updater:status`
  channel so the Settings card stays live.

Renderer:
- Settings → About card gains an "Updates" row showing current state
  ("Up to date", "Update available (vX)", "Downloading… 30%", etc.)
  alongside a "Check now" button that triggers a manual check.

IPC contract:
- `window.api.updater.status()` / `.check()` / `.onStatus(handler)`.
- `UpdaterStatus` union exported from `preload/api.ts` so both sides
  share the type.

Also trimmed the CodeQL workflow's `push: branches: [main]` trigger —
every change reaches main via PR, so the push run just duplicated the
PR run. Pull-request + weekly cron + manual dispatch are enough.
@aicayzer aicayzer merged commit ffa4eaa into main May 12, 2026
3 checks passed
@aicayzer aicayzer deleted the feat/auto-updater branch May 12, 2026 14:51
aicayzer added a commit that referenced this pull request May 18, 2026
…er (#66)

electron-builder + pnpm has a known dep-walker bug
(electron-userland/electron-builder#9654) that drops `ms` from the
packaged asar even when node_modules is hoisted flat. Without `ms`,
packaged builds crash on launch the moment `electron-updater` loads —
the require chain is `electron-updater → builder-util-runtime → debug
→ ms`. The bug has been latent on main since #47 merged 90s after
v0.2.1 was tagged, so no shipped release has exercised it.

Workaround: promote `debug` and `ms` from transitives of
`electron-updater` to direct dependencies. electron-builder includes
direct deps reliably regardless of its pnpm walker behaviour.

Also set `nodeLinker: hoisted` + `shamefullyHoist: true` in
pnpm-workspace.yaml (pnpm 10+ ignores these in .npmrc). With the
explicit deps the hoisted linker isn't strictly required, but it
keeps the layout predictable for any other electron-builder traversal.

Verified locally: `npx asar list` on the built .app now shows
`/node_modules/ms/package.json`, and the installed .app launches
without the `Cannot find module 'ms'` exception.

Remove these explicit deps when #9654 is fixed upstream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant