Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(windows): manual update marker routes to a passive notice; refuse quitAndInstall off self-install

review8f4c73d35a73
diff --git a/src/main/updater.no-channel.test.ts b/src/main/updater.no-channel.test.ts
index 8ff52ceb8..8c6a28f89 100644
--- a/src/main/updater.no-channel.test.ts
+++ b/src/main/updater.no-channel.test.ts
@@ -94,6 +94,7 @@ beforeEach(() => {
for (const k of Object.keys(updaterEvents)) delete updaterEvents[k]
sent.length = 0
autoUpdater.checkForUpdates.mockClear()
+ autoUpdater.quitAndInstall.mockClear()
autoUpdater.autoDownload = true
autoUpdater.autoInstallOnAppQuit = true
appMock.isPackaged = true
@@ -208,3 +209,77 @@ describe('the paths that must not move', () => {
expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1)
})
})
+
+const restart = (): void => ipcOn[IPC.appRestartToUpdate]?.()
+
+/**
+ * The unsigned Windows beta (`dist:win:release` → `nodeTermUpdates=manual`): it must LEARN that a
+ * new version is out — a passive "available, download it" card — and must never download or
+ * install it, because an unsigned auto-update is a downgrade in trust.
+ */
+describe('the unsigned Windows beta (manual marker)', () => {
+ const onBeforeRestart = vi.fn()
+
+ beforeEach(() => {
+ onBeforeRestart.mockClear()
+ setPlatform('win32')
+ packageWith('manual')
+ initUpdater(onBeforeRestart)
+ })
+
+ it('checks the feed on launch and every six hours', () => {
+ expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1)
+ vi.advanceTimersByTime(6 * 60 * 60 * 1000)
+ expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(2)
+ })
+
+ it('never downloads and never installs on quit', () => {
+ expect(autoUpdater.autoDownload).toBe(false)
+ expect(autoUpdater.autoInstallOnAppQuit).toBe(false)
+ })
+
+ it('surfaces a found version as the manual Download card, not "no channel"', () => {
+ updaterEvents['update-available']?.({ version: '9.9.9' })
+ expect(sent.at(-1)).toEqual({
+ channel: IPC.appUpdateAvailable,
+ payload: { version: '9.9.9', notes: '', manual: true }
+ })
+ check()
+ expect(channels()).not.toContain(IPC.appUpdateNoChannel)
+ })
+
+ it('refuses restart-to-update in main: quitAndInstall never runs', () => {
+ restart()
+ expect(autoUpdater.quitAndInstall).not.toHaveBeenCalled()
+ // Nor is the app flagged as quitting for a quit that will never come.
+ expect(onBeforeRestart).not.toHaveBeenCalled()
+ })
+})
+
+describe('restart-to-update elsewhere', () => {
+ it('a self-installing release still restarts into the update', () => {
+ const onBeforeRestart = vi.fn()
+ setPlatform('darwin')
+ packageWith(undefined)
+ initUpdater(onBeforeRestart)
+ restart()
+ expect(onBeforeRestart).toHaveBeenCalledTimes(1)
+ expect(autoUpdater.quitAndInstall).toHaveBeenCalledTimes(1)
+ })
+
+ it('a Linux .deb (manual-install) refuses it too', () => {
+ setPlatform('linux')
+ packageWith(undefined)
+ initUpdater()
+ restart()
+ expect(autoUpdater.quitAndInstall).not.toHaveBeenCalled()
+ })
+
+ it('a no-channel build refuses it — it has nothing to install', () => {
+ setPlatform('win32')
+ packageWith('disabled')
+ initUpdater()
+ restart()
+ expect(autoUpdater.quitAndInstall).not.toHaveBeenCalled()
+ })
+})
diff --git a/src/main/updater.ts b/src/main/updater.ts
index cd05602ab..349563068 100644
--- a/src/main/updater.ts
+++ b/src/main/updater.ts
@@ -11,7 +11,7 @@ import path from 'path'
// electron-vite v5's CJS interop.
import { autoUpdater } from 'electron-updater'
import { IPC } from '../shared/ipc'
-import { toUpdateAvailablePayload, updateDelivery } from '../shared/update-platform'
+import { mayQuitAndInstall, toUpdateAvailablePayload, updateDelivery } from '../shared/update-platform'
import { getMainWindow, sendToMain } from './main-window'
import { retainUntilDismissed } from './notifications'
@@ -20,7 +20,9 @@ const SIX_HOURS = 6 * 60 * 60 * 1000
/**
* The `nodeTermUpdates` marker a LOCAL package carries in its packaged package.json, injected by
* the `dist*` scripts via electron-builder's `extraMetadata`. `release` does not set it, so a
- * promoted build is untouched and keeps updating itself.
+ * promoted build is untouched and keeps updating itself. The one RELEASE that carries a marker is
+ * the unsigned Windows beta (`dist:win:release` → `manual`): it checks the feed but never
+ * downloads or installs — see `updateDelivery`.
*
* It exists because a locally packaged app is indistinguishable from a release at runtime —
* `app.isPackaged` is true for both — so it polled the production feed for a version that was
@@ -63,13 +65,6 @@ function packagedUpdateMode(): unknown {
export function initUpdater(onBeforeRestart?: () => void): void {
const send = (channel: string, payload?: unknown) => sendToMain(channel, payload)
- // Always available, even in dev: current version, manual check, restart.
- ipcMain.handle(IPC.appGetVersion, () => app.getVersion())
- ipcMain.on(IPC.appRestartToUpdate, () => {
- onBeforeRestart?.()
- autoUpdater.quitAndInstall()
- })
-
const delivery = updateDelivery({
isPackaged: app.isPackaged,
updateMode: packagedUpdateMode(),
@@ -77,12 +72,26 @@ export function initUpdater(onBeforeRestart?: () => void): void {
hasAppImage: !!process.env.APPIMAGE
})
+ // Always available, even in dev: current version, manual check, restart.
+ ipcMain.handle(IPC.appGetVersion, () => app.getVersion())
+ ipcMain.on(IPC.appRestartToUpdate, () => {
+ // A build that must not self-install refuses here, in main — not only by the card never
+ // offering the button. The unsigned Windows beta (`nodeTermUpdates=manual`) is the reason:
+ // quitAndInstall must never run there, whatever the renderer sends. It also skips
+ // onBeforeRestart, which would otherwise leave the app flagged as quitting with no quit.
+ if (!mayQuitAndInstall(delivery)) {
+ console.warn(`[updater] restart-to-update ignored: this build does not self-install (${delivery})`)
+ return
+ }
+ onBeforeRestart?.()
+ autoUpdater.quitAndInstall()
+ })
+
if (delivery === 'dev' || delivery === 'no-channel') {
// Neither can reach a feed, so automatic networking and updater event wiring stay off — but
// the two answer a MANUAL check differently, because only one of them has a user to mislead.
//
- // `no-channel` is a packaged app someone installed (a Windows build today: no signed release
- // job, no `latest.yml`). Telling them "up to date" is a statement this build is structurally
+ // `no-channel` is a packaged app someone installed from a local `dist*` package. Telling them "up to date" is a statement this build is structurally
// unable to make — it was issue #814's actual complaint, read by the reporter as a dead
// button. It now says it has no channel and points at the download page.
//
@@ -94,8 +103,10 @@ export function initUpdater(onBeforeRestart?: () => void): void {
}
// A Linux .deb/.rpm install (no APPIMAGE env) cannot self-install and would re-download the
- // full AppImage every 6h only to throw on install. Degrade to a manual-download link: don't
- // auto-download; surface update-available with `manual: true` so the card shows a Download link.
+ // full AppImage every 6h only to throw on install; the unsigned Windows beta must not
+ // self-install. Degrade both to a manual-download link: don't auto-download; surface
+ // update-available with `manual: true` so the card shows a Download link. (electron-updater's
+ // NsisUpdater verifies a signature only at install time, which this path never reaches.)
const manualUpdates = delivery === 'manual-install'
autoUpdater.autoDownload = !manualUpdates
diff --git a/src/shared/update-platform.test.ts b/src/shared/update-platform.test.ts
index 7d52d270d..e1ceceed2 100644
--- a/src/shared/update-platform.test.ts
+++ b/src/shared/update-platform.test.ts
@@ -2,7 +2,9 @@ import { describe, expect, it } from 'vitest'
import fs from 'fs'
import path from 'path'
import {
+ MANUAL_UPDATE_MODE,
isManualUpdatePlatform,
+ mayQuitAndInstall,
noSelfInstallCopy,
shouldEnableUpdater,
toUpdateAvailablePayload,
@@ -53,15 +55,36 @@ describe('local dist scripts opt out of the production update feed', () => {
fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf8')
) as { scripts: Record<string, string> }
const MARKER = '-c.extraMetadata.nodeTermUpdates=disabled'
-
- it('every dist script carries the marker — not just the one whose 404 was noticed', () => {
- const dist = Object.keys(pkg.scripts).filter((s) => s === 'dist' || s.startsWith('dist:'))
- expect(dist.length).toBeGreaterThanOrEqual(2) // dist, dist:linux
+ const MANUAL = `-c.extraMetadata.nodeTermUpdates=${MANUAL_UPDATE_MODE}`
+ // The one dist-named script that is a RELEASE package: the unsigned Windows beta, which checks
+ // the feed but never self-installs. Everything else under `dist*` is a local package.
+ const WIN_RELEASE = 'dist:win:release'
+
+ it('every local dist script carries the marker — not just the one whose 404 was noticed', () => {
+ const dist = Object.keys(pkg.scripts).filter(
+ (s) => (s === 'dist' || s.startsWith('dist:')) && s !== WIN_RELEASE
+ )
+ expect(dist.length).toBeGreaterThanOrEqual(3) // dist, dist:linux, dist:win
expect(dist.filter((s) => !pkg.scripts[s].includes(MARKER))).toEqual([])
})
+ it('plain dist:win stays a local package that never polls', () => {
+ expect(pkg.scripts['dist:win']).toContain(MARKER)
+ expect(pkg.scripts['dist:win']).not.toContain(MANUAL)
+ })
+
+ it('the Windows release package is stamped manual — feed check, never self-install', () => {
+ const cmd = pkg.scripts[WIN_RELEASE]
+ expect(cmd).toContain(MANUAL)
+ expect(cmd).not.toContain(MARKER)
+ expect(cmd).toContain('--win')
+ // It still never publishes from the build step; release.yml uploads the assets itself.
+ expect(cmd).toContain('--publish never')
+ })
+
it('release does NOT carry it — a promoted build must keep updating itself', () => {
expect(pkg.scripts.release).not.toContain(MARKER)
+ expect(pkg.scripts.release).not.toContain(MANUAL)
})
})
@@ -88,10 +111,10 @@ describe('toUpdateAvailablePayload', () => {
/**
- * Issue #814: a Windows build carries `nodeTermUpdates=disabled` (no signed release job, no
- * `latest.yml`), so the updater never wires a feed — and the one thing that branch DID wire was a
- * manual check answering "up to date". These pin the three delivery paths apart, and pin that the
- * macOS and Linux release paths are untouched by the new one.
+ * Issue #814: a local package carries `nodeTermUpdates=disabled` (no feed), so the updater never
+ * wires a feed — and the one thing that branch DID wire was a manual check answering "up to date".
+ * These pin the delivery paths apart, and pin that the macOS and Linux release paths are untouched
+ * by the Windows `manual` marker.
*/
describe('updateDelivery', () => {
const pkgd = { isPackaged: true, updateMode: undefined as unknown, hasAppImage: false }
@@ -131,6 +154,24 @@ describe('updateDelivery', () => {
}
})
+ it('the manual marker is a feed check that never self-installs (the unsigned Windows beta)', () => {
+ expect(updateDelivery({ ...pkgd, updateMode: 'manual', platform: 'win32' })).toBe('manual-install')
+ expect(shouldEnableUpdater(true, 'manual')).toBe(true)
+ })
+
+ it('the manual marker wins over the platform — even where self-install would work', () => {
+ expect(updateDelivery({ ...pkgd, updateMode: 'manual', platform: 'darwin' })).toBe('manual-install')
+ expect(
+ updateDelivery({ ...pkgd, updateMode: 'manual', platform: 'linux', hasAppImage: true })
+ ).toBe('manual-install')
+ })
+
+ it('an unpackaged run with the manual marker is still dev', () => {
+ expect(
+ updateDelivery({ isPackaged: false, updateMode: 'manual', platform: 'win32', hasAppImage: false })
+ ).toBe('dev')
+ })
+
it('stays composed from the two primitives — no second definition to drift', () => {
for (const platform of ['win32', 'darwin', 'linux']) {
for (const hasAppImage of [false, true]) {
@@ -146,6 +187,20 @@ describe('updateDelivery', () => {
})
})
+describe('mayQuitAndInstall', () => {
+ it('only a self-installing build (or dev, unchanged) may reach quitAndInstall', () => {
+ expect(mayQuitAndInstall('self-install')).toBe(true)
+ expect(mayQuitAndInstall('dev')).toBe(true)
+ expect(mayQuitAndInstall('manual-install')).toBe(false)
+ expect(mayQuitAndInstall('no-channel')).toBe(false)
+ })
+
+ it('the unsigned Windows beta can never install from the feed', () => {
+ const d = updateDelivery({ isPackaged: true, updateMode: 'manual', platform: 'win32', hasAppImage: false })
+ expect(mayQuitAndInstall(d)).toBe(false)
+ })
+})
+
describe('noSelfInstallCopy', () => {
const manual = noSelfInstallCopy('manual-install', '0.3.8')
const none = noSelfInstallCopy('no-channel')
diff --git a/src/shared/update-platform.ts b/src/shared/update-platform.ts
index 998d4e78c..612306723 100644
--- a/src/shared/update-platform.ts
+++ b/src/shared/update-platform.ts
@@ -6,7 +6,12 @@
* the `APPIMAGE` env var, which quitAndInstall re-execs). A .deb / .rpm install has no
* APPIMAGE, so quitAndInstall throws "APPIMAGE env is not defined" AND every 6h check would
* still download the full ~231MB AppImage for nothing. For that case we degrade to a
- * manual-download link. macOS (dmg/zip) and Windows self-install as before.
+ * manual-download link. macOS (dmg/zip) self-installs as before.
+ *
+ * The unsigned Windows beta reaches the same manual-download link by a different route: its
+ * release package carries the `nodeTermUpdates=manual` build marker (see `updateDelivery`), not a
+ * platform rule — so the day a signed Windows release drops the marker it self-installs with
+ * nothing to edit here.
*/
import type { UpdateInfo } from './types'
@@ -15,6 +20,14 @@ export function isManualUpdatePlatform(platform: string, hasAppImage: boolean):
return platform === 'linux' && !hasAppImage
}
+/**
+ * The build marker that asks for a feed check WITHOUT self-install: the updater learns which
+ * version is out, never downloads it and never installs it. `dist:win:release` stamps it on the
+ * unsigned Windows beta — an unsigned auto-update is a downgrade in trust, a "new version is
+ * available — download it" card is not.
+ */
+export const MANUAL_UPDATE_MODE = 'manual'
+
/** True when updater networking should be initialized for this runtime/build. */
export function shouldEnableUpdater(isPackaged: boolean, updateMode: unknown): boolean {
return isPackaged && updateMode !== 'disabled'
@@ -39,20 +52,21 @@ export function toUpdateAvailablePayload(
* - `self-install` there is a feed and electron-updater can relaunch the new binary: macOS
* dmg/zip, a Linux AppImage, and a Windows release once one is signed and
* published. The ordinary download-progress → "Restart to update" flow.
- * - `manual-install` there IS a feed, but this install cannot self-install (Linux .deb/.rpm: no
- * APPIMAGE, so quitAndInstall throws). We know which version is out; the user
- * installs that package themselves.
+ * - `manual-install` there IS a feed, but this install cannot — or must not — self-install:
+ * Linux .deb/.rpm (no APPIMAGE, so quitAndInstall throws), and any build
+ * stamped `nodeTermUpdates=manual` (the unsigned Windows beta, until signing
+ * lands). We know which version is out; the user installs it themselves.
* - `no-channel` there is no feed AT ALL — the build was packaged with updates switched off
- * (`nodeTermUpdates=disabled`, which every `dist*` script sets, and which a
- * Windows build carries today because Windows has no signed release job or
- * `latest.yml`). This build can never learn that a newer version exists, so a
+ * (`nodeTermUpdates=disabled`, which every LOCAL `dist*` script sets). This
+ * build can never learn that a newer version exists, so a
* check must say so and point at the download page. Reporting "up to date"
* here — what shipped before issue #814 — is a false statement, not feedback.
* - `dev` unpackaged. Deliberately keeps the old quiet "up to date" reply: a developer
* running `npm run dev` is not a user who can be misled about their install.
*
- * `no-channel` is decided by the BUILD MARKER, never by a platform name. That is what makes the
- * first Windows release with a real channel show the ordinary path with nothing to edit here.
+ * `no-channel` and the marker-driven `manual-install` are decided by the BUILD MARKER, never by a
+ * platform name. That is what makes the first signed Windows release (no marker) take the
+ * ordinary self-install path with nothing to edit here.
*/
export type UpdateDelivery = 'self-install' | 'manual-install' | 'no-channel' | 'dev'
@@ -66,9 +80,22 @@ export function updateDelivery(opts: {
// Composed from the two primitives above rather than re-deciding either — one definition of
// "has a feed" and one of "can self-install", so the wiring and the copy cannot drift apart.
if (!shouldEnableUpdater(opts.isPackaged, opts.updateMode)) return 'no-channel'
+ // The marker wins over the platform: it is the build saying "never install yourself".
+ if (opts.updateMode === MANUAL_UPDATE_MODE) return 'manual-install'
return isManualUpdatePlatform(opts.platform, opts.hasAppImage) ? 'manual-install' : 'self-install'
}
+/**
+ * Whether a "Restart to update" request may reach `autoUpdater.quitAndInstall()`. Only a build
+ * that self-installs (or a dev run, which keeps its historical no-op behaviour) may. A
+ * `manual-install` build never downloads anything, and on the unsigned Windows beta an install
+ * from the feed is exactly the trust downgrade the `manual` marker exists to prevent — so the
+ * guard holds in main even if a renderer (or a stale card) asks.
+ */
+export function mayQuitAndInstall(delivery: UpdateDelivery): boolean {
+ return delivery === 'self-install' || delivery === 'dev'
+}
+
/** What the update card says when this build will not install the update by itself. */
export interface NoSelfInstallCopy {
title: string