Skip to content

Commit f87c3f2

Browse files
committed
fix(updater): per-user NSIS updates, skip auto-update in dev
The Windows auto-updater shipped a per-machine MSI installed silently (installMode "quiet"). Per-machine MSI upgrades need elevation; "quiet" suppresses the UAC prompt and apps run non-elevated by default, so the silent install failed (1603 / "must be Administrator") for ordinary users — and since the app quits to apply the update, it looked like a crash/loop. This affected any non-elevated user on auto-update, not just dev. - bundle.targets: drop "msi" (was "all"). Windows now ships NSIS only, which is already configured per-user (nsis.installMode "currentUser") — so updates install without elevation. The updater manifest will reference the NSIS "-setup.exe"; the api.mcpmux.com resolver rewrites URLs filename-agnostically, so no worker change is needed. - updater.windows.installMode: "quiet" -> "passive". Shows a small progress UI and, crucially, surfaces a UAC prompt if elevation is ever needed instead of failing invisibly. With per-user NSIS the normal path still needs no elevation. - App.tsx: skip the startup auto-update entirely when import.meta.env.DEV (i.e. under `pnpm dev`) — otherwise a dev build detects a newer published release, installs it over the dev build, and relaunches, so local changes never appear. Production builds are unaffected. Tests: App update-banner suite stubs DEV=false to keep exercising the production flow; all 12 pass. Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
1 parent 05ac1b1 commit f87c3f2

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

apps/desktop/src-tauri/tauri.conf.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
],
2727
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDdCQUZGMEVCMEZBOTk5RTcKUldUbm1ha1A2L0N2ZTlOZjN5T3pGOHBHRUlibytMY2tPeWJkQ01heDJzdTJqK3B3a2lBdDZ1T1oK",
2828
"windows": {
29-
"installMode": "quiet"
29+
"installMode": "passive"
3030
}
3131
}
3232
},
@@ -50,7 +50,14 @@
5050
"bundle": {
5151
"active": true,
5252
"createUpdaterArtifacts": true,
53-
"targets": "all",
53+
"targets": [
54+
"app",
55+
"dmg",
56+
"deb",
57+
"rpm",
58+
"appimage",
59+
"nsis"
60+
],
5461
"icon": [
5562
"icons/32x32.png",
5663
"icons/128x128.png",

apps/desktop/src/App.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ function AppContent() {
104104
// into the new version — so a restart picks up updates with no clicks.
105105
// Otherwise just surface the dismissible banner for a manual install.
106106
useEffect(() => {
107+
// Never auto-update under `pnpm dev`. A dev build would otherwise detect a
108+
// newer published release, install it over this build, and relaunch — so
109+
// your local changes would vanish before you could see them. Production
110+
// builds (import.meta.env.DEV === false) are unaffected.
111+
if (import.meta.env.DEV) return;
112+
107113
const checkForUpdates = async () => {
108114
try {
109115
const { checkForUpdate } = await import('@/lib/updates');

tests/ts/components/App.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ describe('App – dynamic gateway URL display', () => {
288288

289289
describe('App – update banner', () => {
290290
beforeEach(() => {
291+
// The startup auto-update check is gated behind `!import.meta.env.DEV`
292+
// (it must never run under `pnpm dev`). Vitest runs in dev mode, so stub
293+
// DEV=false here to exercise the production update flow.
294+
vi.stubEnv('DEV', false);
291295
vi.useFakeTimers();
292296
gatewayEventCallbacks = [];
293297
setupInvoke({ get_version: '0.1.2' });
@@ -296,6 +300,7 @@ describe('App – update banner', () => {
296300

297301
afterEach(() => {
298302
vi.useRealTimers();
303+
vi.unstubAllEnvs();
299304
});
300305

301306
it('should show update banner when update is available', async () => {

0 commit comments

Comments
 (0)