Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(updater): stop dismissed releases from downloading

vastsae356fb348ca4
diff --git a/apps/desktop/electron/main/updater.ts b/apps/desktop/electron/main/updater.ts
index 9c1cdbe8c..61f2cf193 100644
--- a/apps/desktop/electron/main/updater.ts
+++ b/apps/desktop/electron/main/updater.ts
@@ -95,6 +95,8 @@ export type UpdaterOptions = {
persistLastNotifiedVersion?: (version: string) => Promise<void>;
/** Persists the version whose update notice the user dismissed (#1317). */
persistDismissedVersion?: (version: string | null) => Promise<void>;
+ /** Overrides the Electron singleton in controller tests. */
+ autoUpdater?: AppUpdater;
/**
* Active product UI locale for shipped-locale release notes.
* Called when attaching notes to update state; defaults to English.
@@ -126,6 +128,7 @@ export class AppUpdaterController {
private readonly persistDismissedVersion?: (
version: string | null,
) => Promise<void>;
+ private dismissedVersionPersistence: Promise<void> = Promise.resolve();
private readonly manualReminderTracker = new ManualUpdateReminderTracker();
private preference: UpdatePreference;
private preferenceRevision = 0;
@@ -135,6 +138,10 @@ export class AppUpdaterController {
private state: UpdateState;
/** Version whose notice the user dismissed; cleared when a new one appears. */
private dismissedVersion?: string;
+ private activeDownloadCancellation?: {
+ version: string;
+ cancel: () => void;
+ };
private manualRequested = false;
private initialTimer: NodeJS.Timeout | null = null;
private intervalTimer: NodeJS.Timeout | null = null;
@@ -239,7 +246,7 @@ export class AppUpdaterController {
{ data: { platform } },
);
}
- this.autoUpdater = relocated ?? autoUpdater;
+ this.autoUpdater = options.autoUpdater ?? relocated ?? autoUpdater;
this.cacheMaintenance = new UpdateCacheMaintenance({
resourcesPath: process.resourcesPath,
activeBasePath,
@@ -345,8 +352,11 @@ export class AppUpdaterController {
const preferenceChanged =
effectivePreference !== this.preference || mode !== previousMode;
this.preference = effectivePreference;
- this.autoUpdater.autoDownload = mode === "in-app";
- this.autoUpdater.autoInstallOnAppQuit = mode === "in-app";
+ const dismissed =
+ this.state.availableVersion !== undefined &&
+ this.dismissedVersion === this.state.availableVersion;
+ this.autoUpdater.autoDownload = mode === "in-app" && !dismissed;
+ this.autoUpdater.autoInstallOnAppQuit = mode === "in-app" && !dismissed;
if (!preferenceChanged) return;
const patch: Partial<UpdateState> = {
@@ -393,14 +403,53 @@ export class AppUpdaterController {
const version = this.state.availableVersion;
if (!version) return;
this.dismissedVersion = version;
- this.setState({ dismissed: true });
- if (!this.persistDismissedVersion) return;
- try {
- await this.persistDismissedVersion(version);
- } catch (error) {
+ if (this.state.mode === "in-app") {
+ this.autoUpdater.autoDownload = false;
+ this.autoUpdater.autoInstallOnAppQuit = false;
+ }
+ this.setState({
+ status:
+ this.state.status === "downloading" || this.state.status === "downloaded"
+ ? "available"
+ : this.state.status,
+ progressPercent: undefined,
+ dismissed: true,
+ });
+ if (this.activeDownloadCancellation?.version === version) {
+ this.activeDownloadCancellation.cancel();
+ this.activeDownloadCancellation = undefined;
+ }
+ await this.persistDismissedVersionInOrder(version);
+ }
+
+ private persistDismissedVersionInOrder(version: string | null): Promise<void> {
+ if (!this.persistDismissedVersion) return Promise.resolve();
+ const write = this.dismissedVersionPersistence.then(() =>
+ this.persistDismissedVersion?.(version),
+ );
+ this.dismissedVersionPersistence = write.catch((error: unknown) => {
this.logger.app("updater", "warn", "update dismissal persistence failed", {
data: { detail: String(error), version },
});
+ });
+ return this.dismissedVersionPersistence;
+ }
+
+ private trackAutomaticDownload(
+ result: Awaited<ReturnType<AppUpdater["checkForUpdates"]>>,
+ ): void {
+ const downloadPromise = result?.downloadPromise;
+ const cancellationToken = result?.cancellationToken;
+ if (!downloadPromise || !cancellationToken) return;
+ this.activeDownloadCancellation = {
+ version: result.updateInfo.version,
+ cancel: () => cancellationToken.cancel(),
+ };
+ // electron-updater emits `error` or `update-cancelled` before rejecting
+ // this promise. The event handlers own diagnostics and state transitions.
+ void downloadPromise.catch(() => undefined);
+ if (this.dismissedVersion === result.updateInfo.version) {
+ cancellationToken.cancel();
}
}
@@ -442,20 +491,21 @@ export class AppUpdaterController {
this.setState({ status: "checking", error: undefined });
});
this.autoUpdater.on("update-available", (info: UpdateInfo) => {
- const automatic = this.state.mode === "in-app";
// A newly discovered version supersedes any earlier dismissal.
if (this.dismissedVersion && this.dismissedVersion !== info.version) {
this.dismissedVersion = undefined;
- if (this.persistDismissedVersion) {
- void this.persistDismissedVersion(null).catch(() => undefined);
- }
+ void this.persistDismissedVersionInOrder(null);
}
+ const dismissed = this.dismissedVersion === info.version;
+ const automatic = this.state.mode === "in-app" && !dismissed;
+ this.autoUpdater.autoDownload = automatic;
+ this.autoUpdater.autoInstallOnAppQuit = automatic;
this.setState({
status: automatic ? "downloading" : "available",
availableVersion: info.version,
releaseNotes: this.notesFor(info.version),
progressPercent: automatic ? 0 : undefined,
- dismissed: this.dismissedVersion === info.version,
+ dismissed,
manualReminder: automatic
? false
: this.manualReminderFor(info.version),
@@ -478,6 +528,7 @@ export class AppUpdaterController {
});
this.autoUpdater.on("download-progress", (progress: ProgressInfo) => {
if (this.state.mode !== "in-app") return;
+ if (this.dismissedVersion === this.state.availableVersion) return;
this.setState({
status: "downloading",
// Preserve notes already attached when discovery advanced to download.
@@ -487,17 +538,32 @@ export class AppUpdaterController {
});
});
this.autoUpdater.on("update-downloaded", (info: UpdateInfo) => {
- const automatic = this.state.mode === "in-app";
+ const dismissed = this.dismissedVersion === info.version;
+ const automatic = this.state.mode === "in-app" && !dismissed;
+ this.activeDownloadCancellation = undefined;
+ this.autoUpdater.autoInstallOnAppQuit = automatic;
this.setState({
status: automatic ? "downloaded" : "available",
availableVersion: info.version,
releaseNotes: this.notesFor(info.version),
progressPercent: automatic ? 100 : undefined,
+ dismissed,
manualReminder: automatic
? false
: this.manualReminderFor(info.version),
});
});
+ this.autoUpdater.on("update-cancelled", (info: UpdateInfo) => {
+ if (this.activeDownloadCancellation?.version === info.version) {
+ this.activeDownloadCancellation = undefined;
+ }
+ if (this.dismissedVersion !== info.version) return;
+ this.setState({
+ status: "available",
+ progressPercent: undefined,
+ dismissed: true,
+ });
+ });
this.autoUpdater.on("error", (error: Error) => {
// Auto checks fail quietly (offline, private repo, rate limits);
// the renderer only surfaces errors when `manual` is set.
@@ -548,11 +614,12 @@ export class AppUpdaterController {
// Fire-and-forget relative to boot: callers must not await this from the
// first-window path. The race only bounds *our* wait; electron-updater
// may still finish later and emit available/up-to-date.
- await raceWithTimeout(
- this.autoUpdater.checkForUpdates(),
- timeoutMs,
- "update check",
+ const checkPromise = this.autoUpdater.checkForUpdates();
+ void checkPromise.then(
+ (result) => this.trackAutomaticDownload(result),
+ () => undefined,
);
+ await raceWithTimeout(checkPromise, timeoutMs, "update check");
} catch (error) {
const timedOut =
(error as { code?: unknown } | null)?.code === UPDATE_CHECK_TIMEOUT_CODE;
diff --git a/apps/desktop/test/auto-update.test.mjs b/apps/desktop/test/auto-update.test.mjs
index c38ff0fa5..37e1eb967 100644
--- a/apps/desktop/test/auto-update.test.mjs
+++ b/apps/desktop/test/auto-update.test.mjs
@@ -60,6 +60,7 @@ test("update IPC channels are declared and whitelisted for the preload bridge",
"updatesDownload",
"updatesInstall",
"updatesOpenReleases",
+ "updatesDismiss",
"updatesState",
]) {
assert.match(protocolSource, new RegExp(`${channel}:`), channel);
@@ -82,6 +83,7 @@ test("main process registers update handlers and the auto-check lifecycle", () =
"IPC.invoke.updatesDownload",
"IPC.invoke.updatesInstall",
"IPC.invoke.updatesOpenReleases",
+ "IPC.invoke.updatesDismiss",
]) {
assert.ok(mainSource.includes(channel), channel);
}
@@ -175,6 +177,8 @@ test("renderer exposes the updates API, banner and settings row", () => {
assert.match(apiSource, /updatesGetState:/);
assert.match(apiSource, /updatesCheck:/);
assert.match(apiSource, /updatesInstall:/);
+ assert.match(bannerSource, /update\.dismissed === true/);
+ assert.match(bannerSource, /api\.updatesDismiss\(\)/);
assert.match(apiSource, /onUpdateState:/);
assert.match(bannerSource, /updates\.restart/);
assert.match(bannerSource, /updates\.viewRelease/);
diff --git a/apps/desktop/test/helpers/updater-electron-stub.mjs b/apps/desktop/test/helpers/updater-electron-stub.mjs
new file mode 100644
index 000000000..e1bd91c81
--- /dev/null
+++ b/apps/desktop/test/helpers/updater-electron-stub.mjs
@@ -0,0 +1,7 @@
+export const app = {
+ getAppPath: () => process.cwd(),
+ getVersion: () => "0.16.0",
+ isPackaged: false,
+};
+
+export const shell = { openExternal: async () => undefined };
diff --git a/apps/desktop/test/helpers/updater-electron-updater-stub.mjs b/apps/desktop/test/helpers/updater-electron-updater-stub.mjs
new file mode 100644
index 000000000..57c021fda
--- /dev/null
+++ b/apps/desktop/test/helpers/updater-electron-updater-stub.mjs
@@ -0,0 +1,16 @@
+import { EventEmitter } from "node:events";
+
+export class StubAutoUpdater extends EventEmitter {
+ autoDownload = false;
+ autoInstallOnAppQuit = false;
+ allowPrerelease = false;
+ logger = null;
+}
+
+export class NsisUpdater extends StubAutoUpdater {
+ app = { getAppPath: () => process.cwd() };
+}
+
+export const autoUpdater = new StubAutoUpdater();
+
+export default { NsisUpdater, autoUpdater };
diff --git a/apps/desktop/test/helpers/updater-module-stubs.mjs b/apps/desktop/test/helpers/updater-module-stubs.mjs
new file mode 100644
index 000000000..8976f9a94
--- /dev/null
+++ b/apps/desktop/test/helpers/updater-module-stubs.mjs
@@ -0,0 +1,20 @@
+import { dirname, join } from "node:path";
+import { fileURLToPath, pathToFileURL } from "node:url";
+
+const here = dirname(fileURLToPath(import.meta.url));
+
+export async function resolve(specifier, context, nextResolve) {
+ if (specifier === "electron") {
+ return {
+ url: pathToFileURL(join(here, "updater-electron-stub.mjs")).href,
+ shortCircuit: true,
+ };
+ }
+ if (specifier === "electron-updater") {
+ return {
+ url: pathToFileURL(join(here, "updater-electron-updater-stub.mjs")).href,
+ shortCircuit: true,
+ };
+ }
+ return nextResolve(specifier, context);
+}
diff --git a/apps/desktop/test/updater-controller.test.mjs b/apps/desktop/test/updater-controller.test.mjs
new file mode 100644
index 000000000..efae98361
--- /dev/null
+++ b/apps/desktop/test/updater-controller.test.mjs
@@ -0,0 +1,122 @@
+import assert from "node:assert/strict";
+import { EventEmitter } from "node:events";
+import test from "node:test";
+import { dirname, join } from "node:path";
+import { register } from "node:module";
+import { fileURLToPath, pathToFileURL } from "node:url";
+
+const here = dirname(fileURLToPath(import.meta.url));
+register(pathToFileURL(join(here, "helpers/ts-import-hooks.mjs")));
+register(pathToFileURL(join(here, "helpers/updater-module-stubs.mjs")));
+
+const { AppUpdaterController } = await import("../electron/main/updater.ts");
+
+class FakeUpdater extends EventEmitter {
+ autoDownload = false;
+ autoInstallOnAppQuit = false;
+ allowPrerelease = false;
+ logger = null;
+ nextVersion = "0.16.1";
+ downloadStarts = [];
+ cancellations = [];
+
+ async checkForUpdates() {
+ this.emit("checking-for-update");
+ const info = {
+ version: this.nextVersion,
+ files: [],
+ path: "",
+ sha512: "",
+ releaseDate: "2026-10-03T00:00:00.000Z",
+ };
+ this.emit("update-available", info);
+ const cancellationToken = {
+ cancel: () => {
+ this.cancellations.push(info.version);
+ this.emit("update-cancelled", info);
+ },
+ };
+ const downloadPromise = this.autoDownload
+ ? (this.downloadStarts.push(info.version), Promise.resolve([]))
+ : null;
+ return { updateInfo: info, cancellationToken, downloadPromise };
+ }
+
+ async downloadUpdate() {
+ return [];
+ }
+
+ quitAndInstall() {}
+}
+
+function createController({ updater, settings = {}, persist = async () => {} }) {
+ const logger = { app: () => {} };
+ const sent = [];
+ const controller = new AppUpdaterController({
+ logger,
+ send: (channel, payload) => sent.push({ channel, payload }),
+ currentVersion: "0.16.0",
+ platform: "darwin",
+ isPackaged: true,
+ autoUpdater: updater,
+ readUpdateSettings: async () => settings,
+ persistDismissedVersion: persist,
+ });
+ return { controller, sent };
+}
+
+test("dismissing an in-app update cancels its download and disables install on quit", async () => {
+ const updater = new FakeUpdater();
+ const persisted = [];
+ const { controller } = createController({
+ updater,
+ persist: async (version) => persisted.push(version),
+ });
+
+ await controller.check();
+ assert.deepEqual(updater.downloadStarts, ["0.16.1"]);
+ assert.equal(controller.getState().status, "downloading");
+
+ await controller.dismiss();
+
+ assert.deepEqual(updater.cancellations, ["0.16.1"]);
+ assert.equal(updater.autoDownload, false);
+ assert.equal(updater.autoInstallOnAppQuit, false);
+ assert.equal(controller.getState().status, "available");
+ assert.equal(controller.getState().dismissed, true);
+ assert.deepEqual(persisted, ["0.16.1"]);
+ controller.dispose();
+});
+
+test("a restored dismissal blocks that release and a newer release resumes automatic delivery", async () => {
+ const updater = new FakeUpdater();
+ const persisted = [];
+ let clearDismissal;
+ const cleared = new Promise((resolve) => {
+ clearDismissal = resolve;
+ });
+ const { controller } = createController({
+ updater,
+ settings: { updatePreference: "automatic", updateDismissedVersion: "0.16.1" },
+ persist: async (version) => {
+ persisted.push(version);
+ if (version === null) clearDismissal();
+ },
+ });
+
+ await controller.check();
+ assert.deepEqual(updater.downloadStarts, []);
+ assert.equal(updater.autoDownload, false);
+ assert.equal(updater.autoInstallOnAppQuit, false);
+ assert.equal(controller.getState().dismissed, true);
+
+ updater.nextVersion = "0.16.2";
+ await controller.check();
+ await cleared;
+ assert.deepEqual(updater.downloadStarts, ["0.16.2"]);
+ assert.equal(updater.autoDownload, true);
+ assert.equal(updater.autoInstallOnAppQuit, true);
+ assert.equal(controller.getState().dismissed, false);
+ assert.deepEqual(persisted, [null]);
+ controller.dispose();
+});
diff --git a/docs/adr/0022-application-update-delivery.md b/docs/adr/0022-application-update-delivery.md
index bb1d64918..9fc423121 100644
--- a/docs/adr/0022-application-update-delivery.md
+++ b/docs/adr/0022-application-update-delivery.md
@@ -115,6 +115,12 @@ download and install-on-quit, and raises one reminder per discovered version.
The last reminded version is stored in the existing Host-owned app settings
JSON and is intentionally omitted from portable configuration sync.
+An update-banner dismissal is also persisted for its available version. In-app
+dismissal cancels an active download and disables install-on-quit for that
+version. Scheduled and explicit checks continue; rediscovering the dismissed
+version does not restart its download, while discovering a newer version clears
+the dismissal and restores automatic delivery.
+
Installed Windows NSIS, packaged macOS, and Linux AppImage default to Automatic.
Windows ZIP/portable packages default to Manual; opting into Automatic is
available on supported Windows packages only after the UI warns that NSIS may
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index 61bf0c25b..3807a7a96 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -809,6 +809,10 @@ system while preserving their different data ownership:
list under the status text (same notes as the ambient banner; D164). The
full-history modal remains available when the app is up to date or update
checks are disabled in development
+- Dismissing an update applies to that version across restarts. In-app
+ dismissal cancels an active download and prevents install-on-quit; discovery
+ continues, and a newer version clears the dismissal and resumes automatic
+ delivery.
## 3. Navigation rules
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 94c37e076..e29247e23 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -13080,22 +13080,27 @@ are withdrawn with ADR 0165.
Dismiss it, navigate away and back, repeat the check, then restart and check
again. 4) Confirm the same version does not raise another notice, while the
Settings row still shows it and opens Releases. 5) Select Automatic and
- confirm the existing in-app download/install behavior resumes. 6) Launch the
- portable ZIP profile and confirm Manual is the default; inspect the warning
- before explicitly selecting Automatic.
+ surface an available version. Dismiss the in-app banner while downloading;
+ verify the transfer is cancelled and the update will not install on quit.
+ Restart, check the same version again, and verify it remains dismissed and
+ does not download. Then surface a newer version and verify automatic
+ downloading resumes. 6) Launch the portable ZIP profile and confirm Manual
+ is the default; inspect the warning before explicitly selecting Automatic.
- **Expected**: The preference persists per installation. Manual performs
discovery only and stores the last reminded version so repeated checks and
- app restarts do not repeat the notice; the Info row remains actionable.
- Automatic retains the existing installer behavior where supported. ZIP and
- legacy portable builds default to Manual, and Automatic is an explicit,
- warned opt-in that can replace the extracted copy with NSIS.
+ app restarts do not repeat the notice; the Info row remains actionable. A
+ dismissed version stays ignored across restarts in either mode. In-app
+ dismissal cancels an active transfer and prevents install-on-quit for that
+ version; a newer release clears the dismissal and resumes automatic delivery.
+ ZIP and legacy portable builds default to Manual, and Automatic is an
+ explicit, warned opt-in that can replace the extracted copy with NSIS.
- **Specs linked**: `03-runtime/07-process-model.md`,
`04-ux/09-interaction-patterns.md`, ADR 0022 / D628
- **Acceptance**: Quality (settings interaction and release safety)
- **Milestone**: M6+
- **Status**: Setting selection/persistence covered by
- `pnpm test:e2e:settings-scroll`; mode/reminder policy covered by
- `update-preference.test.mjs`. Packaged Windows installer journey remains
+ `pnpm test:e2e:settings-scroll`; dismissal and download cancellation covered
+ by `updater-controller.test.mjs`. Packaged Windows installer journey remains
runner validation.
#### E2E-213: The first Composer model menu paint keeps configured aliases