Stop silent updates from waiting on the "Failed to uninstall" dialog
Small installer fix, independent of the telemetry MVP in #141. For Ilia's review. Do not merge yet.
Summary
During an upgrade, the NSIS installer first runs the previous version's uninstaller. If that uninstaller fails, electron-builder shows "Failed to uninstall old application files. Please try running the installer again." This MessageBox has no /SD default, so it also appears in a silent install. A silent auto-update therefore waits on a dialog that the user did not start, and the update looks stuck until someone clicks OK.
build/installer.nsh now defines customUnInstallCheck and customUnInstallCheckCurrentUser. They reproduce electron-builder's default handling (handleUninstallResult in app-builder-lib 26.x) and add only /SD IDOK:
- A silent run now fails at once with error level 2.
- An interactive install still shows the dialog.
/SDapplies only to silent runs. src/main/__tests__/nsisUninstallCheck.test.tspins the upstream function. An electron-builder upgrade that changes it fails the test, so the copy gets reviewed.
Overlap with #141
#141 defines the same two macros to add telemetry. The second of the two PRs to merge gets a small conflict in installer.nsh. I will rebase #141 onto this fix when one of them merges.
Test plan
-
npm run typecheck,npx vitest run: 211 tests pass, 1 new (pin test). - Cross-built both installers on Linux (electron-builder + wine,
-WX): unchangedmain, and this branch. - Under wine, silent update (
/S --updated) with the oldUninstall SealGate.exereplaced by a program that exits with code 1:main: the dialog appears and the installer waits until it is killed. The harness stopped it after 60 s (exit 124).- this branch: no dialog. The installer exits with code 2 after 8.8 s.
- A silent update with a working old uninstaller still succeeds (exit 0) on both builds.
- Interactive install with a failing old uninstaller still shows the dialog. Under wine the run stops earlier, at the known wine "SealGate cannot be closed" artifact, so this needs a Windows VM.
Generated by Claude Code
Summary by cubic
Fixes silent auto-updates hanging when the previous version's uninstaller fails. The NSIS installer now defines customUnInstallCheck and customUnInstallCheckCurrentUser to reproduce electron-builder's default handling with /SD IDOK added, so a silent run fails at once with error level 2 instead of waiting on a dialog the user didn't start. Interactive installs still show the "Failed to uninstall" dialog. A new test pins the upstream handleUninstallResult so an electron-builder upgrade that changes it fails the test.