fix(theseus/updater): --updated flag so silent install actually reinstalls

Users reported Theseus being uninstalled by the auto-updater and never
coming back. Reproduced on 0.3.31:

The 'Install & restart' handler was spawning the NSIS setup with
just [\"/S\"]. Our config is oneClick:false + perMachine:false +
allowToChangeInstallationDirectory:true, so NSIS in silent mode:

  1. runs the old uninstaller (wipes install dir + registry path)
  2. hits the install phase, which in wizard mode expects UI to pick
     the install directory
  3. silent mode has no UI, registry path is gone → exits without
     installing anything

Result: browser gone, nothing left, no error surfaced to the user.

Fix: pass --updated alongside /S. electron-builder's NSIS template
treats --updated as 'this is an auto-update, reuse the existing
install directory from registry, don't rerun the uninstaller'.
--force-run relaunches the app after install.

Users stuck on 0.3.31 need to manually install 0.3.32 once (from
dl.silentmode.st) — the auto-updater in 0.3.31 will not recover on
its own. Their %APPDATA%\theseus-navigator profile is untouched by
the uninstall so vault, addons and settings survive the reinstall.
This commit is contained in:
Local Dev 2026-09-08 19:34:06 +02:00
parent dc58d0426a
commit 0f1411094e

23
main.js
View file

@ -3073,15 +3073,26 @@ ipcMain.handle("recheck-update", async () => {
return { updateAvailable, currentVersion: app.getVersion() };
});
// One-click "Install & restart". Requires the silent pre-fetch to have
// finished (updateDownloadState === "ready"). Launches the setup with /S
// (skips the wizard; our nsis/installer.nsh's Ariadne prompt is bypassed
// too on upgrades because the Ariadne registry key is already present),
// then quits Theseus so the installer can overwrite it. When the installer
// finishes, the user re-launches Theseus and lands on the new version.
// finished (updateDownloadState === "ready").
//
// CRITICAL — spawning the setup with just ["/S"] uninstalls Theseus but
// then FAILS to reinstall on our config (oneClick:false + perMachine:false
// + allowToChangeInstallationDirectory:true). In wizard mode NSIS expects
// UI for the install-path picker, and in silent mode with the registry
// path wiped by the just-run uninstaller, it exits without installing.
// Users hit this in 0.3.31: browser gone, nothing left.
//
// Fix: pass --updated alongside /S. electron-builder's NSIS template
// treats --updated as "this is an auto-update, reuse the existing install
// directory from registry, don't re-run the uninstaller". --force-run
// tells it to relaunch the app after install so the user isn't stranded
// even if the wizard-mode path somehow trips again.
ipcMain.handle("install-update-now", () => {
if (updateDownloadState !== "ready" || !updateDownloadPath) return false;
try {
const p = spawn(updateDownloadPath, ["/S"], { detached: true, stdio: "ignore" });
const p = spawn(updateDownloadPath,
["--updated", "/S", "--force-run"],
{ detached: true, stdio: "ignore" });
p.unref();
} catch (e) { console.warn("update spawn failed:", e?.message); return false; }
// Give the child a moment to inherit our arguments before we exit.