Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): do not strand a staged update carried in from a previous session (PRD-6993) (#3808)

Andrew Mikofalvy354e6d2a9d7a
diff --git a/.changeset/update-freshness-at-intent.md b/.changeset/update-freshness-at-intent.md
index e0959827b..8e09e8bc8 100644
--- a/.changeset/update-freshness-at-intent.md
+++ b/.changeset/update-freshness-at-intent.md
@@ -4,6 +4,6 @@
Updating no longer immediately asks you to update again. Releases often land less than an hour apart, so the build waiting behind the "ready to install" banner was frequently already superseded by the time you clicked it — and the check that runs as the app comes back up would spot the newer one and put the banner straight back, replacing the "Updated to Version X" confirmation you had just earned.
-Clicking Relaunch now re-checks first. If a newer build has appeared since the banner was raised, the app fetches that one and installs it instead, showing "Getting the latest version…" while it does — so finishing an update leaves you on the newest build available at the moment you asked for it. For the minutes right after an update, a build that arrives is downloaded and staged silently rather than announced; it still installs the next time you quit.
+Clicking Relaunch now re-checks first. If a newer build has appeared since the banner was raised, the app fetches that one and installs it instead, showing "Getting the latest version…" while it does — so finishing an update leaves you on the newest build available at the moment you asked for it. On macOS and Windows, where updates install on quit, a build that arrives in the minutes right after an update is downloaded and staged silently rather than announced, and installs the next time you quit. On Linux the banner is the only way to apply an update, so it appears as before.
This also fixes a class of failed installs. The app could previously call into the installer while a newer build was still being written into place, which surfaced as an update that failed and then worked on retry. Two things close that: a relaunch now waits for any download in progress instead of racing it, and a build that is already staged is no longer needlessly re-staged on every hourly check.
diff --git a/packages/app/src/components/UpdateNotices.shared.ts b/packages/app/src/components/UpdateNotices.shared.ts
index b5f2ac079..6f46f1c88 100644
--- a/packages/app/src/components/UpdateNotices.shared.ts
+++ b/packages/app/src/components/UpdateNotices.shared.ts
@@ -385,7 +385,12 @@ export function attachUpdateSubscribers(
);
unsubscribers.push(
- bridge.onUpdateRelaunchFailed(({ version, message, downloadUrl }) => {
+ bridge.onUpdateRelaunchFailed(({ version, message, downloadUrl, dismissPending }) => {
+ // The click repainted every window with the button-less, non-dismissible
+ // fetching card and then found nothing to install. No banner re-arm is
+ // coming (there is nothing staged), so clear that card here — otherwise
+ // the error notice below just layers over one the user can never remove.
+ if (dismissPending) dismissNotice(downloadedNoticeId);
// Boot-detected failed install (a clean quit whose post-quit install
// never ran) arrives with a `downloadUrl` — main re-armed
// versionPendingInstall, so show the richer two-action recovery card:
diff --git a/packages/app/src/components/UpdateNotices.test.ts b/packages/app/src/components/UpdateNotices.test.ts
index dae9146bd..221ac6d26 100644
--- a/packages/app/src/components/UpdateNotices.test.ts
+++ b/packages/app/src/components/UpdateNotices.test.ts
@@ -314,6 +314,48 @@ describe('Notice A cross-window relaunch — ok:update:relaunching', () => {
expect(bridge.update.relaunchNow).not.toHaveBeenCalled();
});
+ test('relaunch-failed with dismissPending clears the stuck fetching card', () => {
+ // The click repainted every window with the button-less, non-dismissible
+ // fetching card and then found nothing staged to install. No banner re-arm
+ // follows, so the card has to be cleared explicitly or the error notice
+ // simply layers over one the user can never remove.
+ const bridge = makeFakeBridge();
+ const addNotice = vi.fn<(notice: UpdateNotice) => void>(() => {});
+ const dismissed: string[] = [];
+ attachUpdateSubscribers(castBridge(bridge), addNotice, (id: string) => {
+ dismissed.push(id);
+ });
+
+ bridge._fetchingLatest?.({ version: '0.1.1' });
+ bridge._relaunchFailed?.({
+ version: '0.1.1',
+ message: 'the update stopped being available',
+ dismissPending: true,
+ });
+
+ expect(dismissed).toContain('update-downloaded');
+ // Both halves of the contract: clearing the stuck card is only correct if
+ // the user is also told why it went away. An early return after the
+ // dismiss would satisfy the assertion above and leave them with nothing.
+ const error = addNotice.mock.calls.at(-1)?.[0] as UpdateNotice;
+ expect(error.id).toBe('relaunch-error-0.1.1');
+ expect(error.variant).toBe('error');
+ expect(error.body).toContain('the update stopped being available');
+ });
+
+ test('an ordinary relaunch-failed leaves the banner alone (main re-arms it)', () => {
+ const bridge = makeFakeBridge();
+ const addNotice = vi.fn<(notice: UpdateNotice) => void>(() => {});
+ const dismissed: string[] = [];
+ attachUpdateSubscribers(castBridge(bridge), addNotice, (id: string) => {
+ dismissed.push(id);
+ });
+
+ bridge._relaunchFailed?.({ version: '0.1.1', message: 'App Still Running Error' });
+
+ expect(dismissed).not.toContain('update-downloaded');
+ });
+
test('onUpdateRelaunchFailed → error notice with detail, same id as the rejection path', () => {
const bridge = makeFakeBridge();
const addNotice = vi.fn<(notice: UpdateNotice) => void>(() => {});
diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.ts
index 42465ba1c..8b0311c9b 100644
--- a/packages/core/src/desktop-bridge.ts
+++ b/packages/core/src/desktop-bridge.ts
@@ -385,6 +385,8 @@ export interface OkUpdateRelaunchFailedInfo {
readonly version: string;
readonly message?: string;
readonly downloadUrl?: string;
+ /** Clear the shared in-progress card instead of layering the error over it. */
+ readonly dismissPending?: boolean;
}
/**
diff --git a/packages/desktop/src/main/auto-updater.ts b/packages/desktop/src/main/auto-updater.ts
index af35635b9..644f2ec16 100644
--- a/packages/desktop/src/main/auto-updater.ts
+++ b/packages/desktop/src/main/auto-updater.ts
@@ -1100,6 +1100,24 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
// stage is running.
let stagingInFlight: { version: string } | null = null;
+ // The version THIS process has actually staged, as opposed to the one
+ // `versionPendingInstall` remembers from a previous run.
+ //
+ // The two come apart whenever a staged update does not get installed in the
+ // session that fetched it — a crash, a force-quit, a failed ShipIt swap, or
+ // simply any Linux session the user did not click through, since
+ // install-on-quit is off there. `versionPendingInstall` deliberately survives
+ // that (boot only clears it once the running version catches up), but
+ // electron-updater keeps nothing: its downloaded-update helper is built
+ // inside `downloadUpdate()` and dies with the process. Without the helper
+ // there is no installer path and no quit handler, so both install routes are
+ // dead until something calls `downloadUpdate()` again.
+ //
+ // So the re-download skip has to be scoped to what this process staged.
+ // Skipping the first offer of a session would strand exactly the population
+ // that already has a failed install behind them.
+ let stagedThisSession: string | null = null;
+
/** Accessor form, so a read after an `await` is not stale-narrowed. */
const currentStaging = (): { version: string } | null => stagingInFlight;
@@ -1235,12 +1253,24 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
// the re-armed banner below is the user's retry affordance and would be
// inert without this.
installRequested = false;
- if (
- persistSafely({ ...readState(), versionPendingInstall: version }, 'relaunch-failed-restore')
- ) {
+ const restored = persistSafely(
+ { ...readState(), versionPendingInstall: version },
+ 'relaunch-failed-restore',
+ );
+ if (restored) {
broadcastToAllWindows('ok:update:downloaded', { version });
}
- broadcastToAllWindows('ok:update:relaunch-failed', { version, message });
+ broadcastToAllWindows('ok:update:relaunch-failed', {
+ version,
+ message,
+ // Every window is on the shared in-progress card by now — a relaunch
+ // only fails after it was announced — and that card has no action and
+ // no dismiss. A successful restore replaces it by id, so nothing more is
+ // needed. A failed one leaves it there, and the error notice lands under
+ // a different id at higher priority, so dismissing the error would just
+ // reveal the stuck card underneath. Clear it instead.
+ ...(restored ? {} : { dismissPending: true }),
+ });
logger.warn('relaunch failed — restored pending install and re-armed windows', {
version,
kind,
@@ -1363,7 +1393,18 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
// `stagingInFlight`), so an hourly re-stage of a build we already hold is
// pure downside. A version CHANGE still re-downloads, and a download that
// failed left `versionPendingInstall` unset, so retries are unaffected.
- if (offeredVersion && readState().versionPendingInstall === offeredVersion) {
+ //
+ // Both conditions are required. `stagedThisSession` is what makes the skip
+ // safe (see its declaration): the persisted field alone would also match on
+ // the FIRST offer of a session that inherited a staged-but-uninstalled
+ // build, and skipping there leaves electron-updater with no installer path
+ // and no quit handler, so the update becomes uninstallable until a newer
+ // one ships.
+ if (
+ offeredVersion &&
+ stagedThisSession === offeredVersion &&
+ readState().versionPendingInstall === offeredVersion
+ ) {
logger.debug('update-available for the already-staged version — skipping re-download', {
version: offeredVersion,
});
@@ -1478,6 +1519,10 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
onDispatch?.('update-downloaded-empty-version');
return;
}
+ // Record before the dedupe below: this is the point electron-updater holds
+ // a real staged artifact for this process, which is what the re-download
+ // skip keys on. A deduped re-fire is still a stage.
+ stagedThisSession = version;
const state = readState();
if (state.versionPendingInstall === version) {
logger.info('update-downloaded re-fired for same pending version — deduped', { version });
@@ -1875,11 +1920,24 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
// The refresh cleared the gate rather than advancing it, which means the
// staged build stopped being installable while we waited. Recover the
// windows instead of calling into Squirrel with nothing staged.
+ //
+ // Deliberately NOT also gated on `stagedThisSession`. A click on a build
+ // this process never staged is the case the refresh above exists to
+ // resolve, and it normally does by downloading it. When it cannot (an
+ // offline check), electron-updater reports the missing installer path
+ // through its error event, which `failRelaunch` already turns into a
+ // re-armed banner plus an explained failure — the same recovery this
+ // branch performs, reached one step later.
logger.warn('relaunch-now lost its staged build during the freshness check — ignoring');
installRequested = false;
broadcastToAllWindows('ok:update:relaunch-failed', {
version: preRefresh.versionPendingInstall,
message: 'the update stopped being available',
+ // Nothing is staged, so there is no banner to re-arm — but every
+ // window is still showing the fetching card this click painted, and
+ // that card has no action and no dismiss. Clear it explicitly, or the
+ // error notice merely stacks on top of a permanent one.
+ dismissPending: true,
});
return undefined;
}
@@ -1966,9 +2024,32 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
)
) {
// The whole point of bailing here is that the user can click again once
- // the disk is healthy, so the commit flag has to come back off with it.
+ // the disk is healthy, so the commit flag has to come back off with it —
+ // and so does the banner. Every window is currently showing the fetching
+ // card, which has no action and no dismiss, so releasing the flag alone
+ // would leave the click with nothing to click.
+ //
+ // The broadcast covers the other windows; the throw covers the clicked
+ // one, and it has to be a throw rather than a quiet return. Resolving
+ // would run that window's success continuation, which dismisses the
+ // shared notice id and so removes the banner this broadcast just put
+ // back — and whether it wins is a race, because the broadcast and the
+ // invoke reply travel different IPC pipes and are ordered only within a
+ // pipe. Rejecting instead routes the clicked window to its failure arm,
+ // which re-arms the banner itself and tells the user the click did not
+ // take. Same reasoning as the `quitAndInstall` throw below.
installRequested = false;
- return undefined;
+ broadcastToAllWindows('ok:update:downloaded', { version: pending });
+ // Pair the re-arm with the reason, the way `failRelaunch` does for the
+ // watchdog and throw paths. Without it the other windows watch the
+ // banner reappear with no account of why, and the clicked window is the
+ // only one that learns a relaunch was even attempted. Same version-keyed
+ // id as the rejection notice below, so the clicked window dedupes.
+ broadcastToAllWindows('ok:update:relaunch-failed', {
+ version: pending,
+ message: 'could not save the update state',
+ });
+ throw new Error('could not save the update state');
}
// Tell EVERY window the relaunch is underway BEFORE the teardown await:
// each renderer swaps its "…ready to install [Relaunch]" banner to the
@@ -2374,7 +2455,13 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
// to update again for a while. A fresh install (`lastSeenVersion === null`)
// is deliberately excluded — nobody just sat through an update, and the
// installer is often already a release or two behind.
- if (shouldShowVersionNotice) {
+ //
+ // Gated on install-on-quit, which is what makes deferring the banner free:
+ // the update still lands at the next quit, so only the interruption moves.
+ // Where install-on-quit is off (Linux), the banner is not a notification at
+ // all, it is the sole install affordance — holding it would withhold the
+ // only way to apply the update and leave the build staged and uninstalled.
+ if (shouldShowVersionNotice && updater.autoInstallOnAppQuit) {
postUpdateQuietUntil = now().getTime() + POST_UPDATE_QUIET_MS;
logger.info('post-update quiet window armed', {
from: state.lastSeenVersion,
diff --git a/packages/desktop/src/shared/ipc-events.ts b/packages/desktop/src/shared/ipc-events.ts
index 5feb85bc0..e58e782d8 100644
--- a/packages/desktop/src/shared/ipc-events.ts
+++ b/packages/desktop/src/shared/ipc-events.ts
@@ -98,7 +98,21 @@ export interface EventChannels {
* two routes dedupe to one card.
*/
'ok:update:relaunch-failed': {
- payload: { version: string; message?: string; downloadUrl?: string };
+ payload: {
+ version: string;
+ message?: string;
+ downloadUrl?: string;
+ /**
+ * Clear the shared in-progress card rather than leaving it under the
+ * error notice. Set only on the paths that already repainted every
+ * window with `ok:update:fetching-latest` and then found there is
+ * nothing to install: the fetching card carries no action and no
+ * dismiss, so without this it would sit there for the rest of the
+ * session. Paths that re-arm the banner via `ok:update:downloaded`
+ * replace the card by id and do not need it.
+ */
+ dismissPending?: boolean;
+ };
};
/**
* First-launch-post-update signal: main compared `app.getVersion()` to
diff --git a/packages/desktop/tests/integration/auto-updater.test.ts b/packages/desktop/tests/integration/auto-updater.test.ts
index e00007c9b..73bc955d2 100644
--- a/packages/desktop/tests/integration/auto-updater.test.ts
+++ b/packages/desktop/tests/integration/auto-updater.test.ts
@@ -3213,7 +3213,14 @@ describe('async relaunch failure — error event + no-quit watchdog', () => {
expect(captured.filter((c) => c.channel === 'ok:update:downloaded')).toHaveLength(0);
const failed = captured.filter((c) => c.channel === 'ok:update:relaunch-failed');
expect(failed).toHaveLength(1);
- expect(failed[0]?.payload).toEqual({ version: '0.3.2', message: 'the update timed out' });
+ // With no re-arm to replace it, every window is still on the shared
+ // in-progress card, which has no action and no dismiss — so the failure
+ // has to carry the instruction to clear it.
+ expect(failed[0]?.payload).toEqual({
+ version: '0.3.2',
+ message: 'the update timed out',
+ dismissPending: true,
+ });
});
test('updater error with NO relaunch in flight → no relaunch-failed broadcast (normal error path)', () => {
@@ -3916,7 +3923,7 @@ describe('relaunch-now idempotency (Major #2)', () => {
expect(rig.state.versionPendingInstall).toBeNull();
});
- test('persistSafely failure → no quitAndInstall call (better to retry)', () => {
+ test('persistSafely failure → no quitAndInstall call (better to retry)', async () => {
const updater = new FakeUpdater();
const ipc = makeFakeIpc();
const clock = makeFakeClock();
@@ -3942,7 +3949,9 @@ describe('relaunch-now idempotency (Major #2)', () => {
debug: vi.fn(() => {}),
},
});
- ipc.invoke('ok:update:relaunch-now');
+ // Rejects so the clicked window runs its failure arm rather than its
+ // success one, which would dismiss the banner the bail just re-armed.
+ await expect(Promise.resolve(ipc.invoke('ok:update:relaunch-now'))).rejects.toThrow();
expect(updater.quitAndInstall).not.toHaveBeenCalled();
// State stays pending since persist failed — user can click again.
expect(state.versionPendingInstall).toBe('0.3.2');
@@ -4497,9 +4506,16 @@ function fireTimerFor(clock: FakeClock, ms: number): void {
}
describe('same-version download guard', () => {
- test('an offer for the already-staged version does not re-download', () => {
- const { rig } = makeRig({ versionPendingInstall: '0.3.2' });
+ /** Take a rig through a real in-session stage of `version`. */
+ function stageInSession(rig: TestRig, version: string): void {
+ rig.updater.emit('update-available', { version });
+ rig.updater.emit('update-downloaded', { version });
rig.updater.downloadUpdate.mockClear();
+ }
+
+ test('a re-offer of the build this session staged does not re-download', () => {
+ const { rig } = makeRig({ versionPendingInstall: null });
+ stageInSession(rig, '0.3.2');
rig.updater.emit('update-available', { version: '0.3.2' });
@@ -4511,11 +4527,44 @@ describe('same-version download guard', () => {
// The pipeline reached a parsed manifest; only the download was declined.
// Treating it as a failure would march the 7-day stuck-hint toward firing
// on a healthy updater that simply has nothing new to fetch.
- const { rig } = makeRig({ versionPendingInstall: '0.3.2' });
+ const { rig } = makeRig({ versionPendingInstall: null });
+ stageInSession(rig, '0.3.2');
+ rig.dispatches.length = 0;
+
rig.updater.emit('update-available', { version: '0.3.2' });
+
expect(rig.dispatches).toContain('check-success' as DispatchKind);
});
+ test('the FIRST offer of a session re-downloads even when state says it is staged', async () => {
+ // A staged build that never installed (crash, force-quit, failed swap, or
+ // any Linux session the user did not click through) carries
+ // `versionPendingInstall` into the next session, but electron-updater
+ // keeps nothing across processes: no download means no installer path and
+ // no quit handler, so skipping here would leave the update uninstallable
+ // until a newer one shipped.
+ const { rig } = makeRig({ versionPendingInstall: '0.3.2' });
+ rig.updater.downloadUpdate.mockClear();
+
+ rig.updater.emit('update-available', { version: '0.3.2' });
+
+ expect(rig.updater.downloadUpdate).toHaveBeenCalledTimes(1);
+ expect(rig.dispatches).not.toContain('download-skipped-already-staged' as DispatchKind);
+
+ // And the install route is live again once that download completes.
+ rig.updater.emit('update-downloaded', { version: '0.3.2' });
+ rig.updater.downloadUpdate.mockClear();
+
+ // Having staged it for real, the skip re-engages — the inherited-state
+ // re-download is a one-time correction, not a permanent opt-out.
+ rig.updater.emit('update-available', { version: '0.3.2' });
+ expect(rig.updater.downloadUpdate).not.toHaveBeenCalled();
+ expect(rig.dispatches).toContain('download-skipped-already-staged' as DispatchKind);
+
+ await rig.ipc.invoke('ok:update:relaunch-now');
+ expect(rig.updater.quitAndInstall).toHaveBeenCalledTimes(1);
+ });
+
test('a genuinely newer offer still downloads', () => {
const { rig } = makeRig({ versionPendingInstall: '0.3.2' });
rig.updater.downloadUpdate.mockClear();
@@ -4639,6 +4688,29 @@ describe('click-gated freshness check', () => {
expect(rig.state.versionPendingInstall).toBeNull();
});
+ test('a staged build that vanishes during the check clears the fetching card', async () => {
+ // Every window is showing the button-less, non-dismissible fetching card
+ // by this point, and there is nothing staged left to re-arm the banner
+ // with — so the failure notice has to carry the flag that clears that
+ // card, or it just layers on top of one the user can never remove.
+ const { rig } = makeRig({ versionPendingInstall: '0.3.2', extraWindowCount: 2 });
+ rig.updater.checkForUpdates.mockImplementation(() => {
+ rig.state = { ...rig.state, versionPendingInstall: null };
+ return Promise.resolve(undefined);
+ });
+
+ await rig.ipc.invoke('ok:update:relaunch-now');
+
+ expect(rig.updater.quitAndInstall).not.toHaveBeenCalled();
+ for (const win of rig.windows) {
+ const failed = win.filter((c) => c.channel === 'ok:update:relaunch-failed');
+ expect(failed).toHaveLength(1);
+ expect(failed[0]?.payload).toMatchObject({ version: '0.3.2', dismissPending: true });
+ // No banner re-arm on this path — there is nothing staged to offer.
+ expect(win.filter((c) => c.channel === 'ok:update:downloaded')).toHaveLength(0);
+ }
+ });
+
test('a check that never reports back falls through on the timeout', async () => {
const { rig } = makeRig({ versionPendingInstall: '0.3.2' });
rig.updater.checkForUpdates.mockImplementation(() => new Promise(() => {}));
@@ -4664,7 +4736,9 @@ describe('the commit flag releases on every path that re-offers the click', () =
const { rig } = makeRig({ versionPendingInstall: '0.3.2' });
rig.failNextPersist = true;
- await rig.ipc.invoke('ok:update:relaunch-now');
+ await expect(Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'))).rejects.toThrow(
+ 'could not save the update state',
+ );
expect(rig.updater.quitAndInstall).not.toHaveBeenCalled();
rig.failNextPersist = false;
@@ -4673,6 +4747,60 @@ describe('the commit flag releases on every path that re-offers the click', () =
expect(rig.updater.quitAndInstall).toHaveBeenCalledTimes(1);
});
+ test('a relaunch failure that restores cleanly does NOT ask to clear the card', async () => {
+ // The re-armed banner replaces the in-progress card by id, so clearing as
+ // well would take the retry affordance away again.
+ const { rig } = makeRig({ versionPendingInstall: '0.3.2' });
+ await rig.ipc.invoke('ok:update:relaunch-now');
+ rig.updater.emit('error', new Error('ShipIt swap failed'));
+
+ const failed = rig.captured.filter((c) => c.channel === 'ok:update:relaunch-failed');
+ expect(failed).toHaveLength(1);
+ expect((failed[0]?.payload as { dismissPending?: boolean }).dismissPending).toBeUndefined();
+ expect(rig.captured.filter((c) => c.channel === 'ok:update:downloaded')).toHaveLength(1);
+ });
+
+ test('a persist failure rejects the click rather than resolving it', async () => {
+ // Resolving would run the clicked window's success continuation, which
+ // dismisses the shared notice id and removes the banner the broadcast just
+ // re-armed — and whether it wins is a race, since the broadcast and the
+ // invoke reply travel different IPC pipes. Rejecting routes that window to
+ // its failure arm, which re-arms the banner itself and says the click did
+ // not take.
+ const { rig } = makeRig({ versionPendingInstall: '0.3.2' });
+ rig.failNextPersist = true;
+
+ await expect(Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'))).rejects.toThrow();
+ });
+
+ test('a persist failure re-arms the banner in EVERY window, not just the clicked one', async () => {
+ // The click already repainted every window with the button-less,
+ // non-dismissible fetching card. Only the clicked window has a failure arm
+ // of its own, so without a broadcast the others are stranded on it.
+ const { rig } = makeRig({ versionPendingInstall: '0.3.2', extraWindowCount: 2 });
+ rig.failNextPersist = true;
+
+ await expect(Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'))).rejects.toThrow();
+
+ for (const win of rig.windows) {
+ expect(win.filter((c) => c.channel === 'ok:update:fetching-latest')).toHaveLength(1);
+ const rearm = win.filter((c) => c.channel === 'ok:update:downloaded');
+ expect(rearm).toHaveLength(1);
+ expect(rearm[0]?.payload).toEqual({ version: '0.3.2' });
+ // Paired with the reason, so a window that did not click still learns a
+ // relaunch was attempted rather than watching the banner reappear on its
+ // own. No `dismissPending` here: the re-arm above already replaced the
+ // in-progress card by id, and clearing as well would take the retry
+ // affordance away again.
+ const failed = win.filter((c) => c.channel === 'ok:update:relaunch-failed');
+ expect(failed).toHaveLength(1);
+ expect(failed[0]?.payload).toEqual({
+ version: '0.3.2',
+ message: 'could not save the update state',
+ });
+ }
+ });
+
test('the linux no-graphical-auth preflight leaves the banner clickable again', async () => {
const hasGraphicalAuth = vi.fn(() => false);
const { rig } = makeRig({
@@ -4731,6 +4859,24 @@ describe('post-update quiet window', () => {
expect(handle.isWithinPostUpdateQuietWindow()).toBe(false);
});
+ test('linux does not arm it — the banner there is the only install route', () => {
+ // Install-on-quit is off on Linux, so the banner is not a notification the
+ // user can ignore, it is the sole affordance for applying the update.
+ // Holding it back would withhold the install entirely and leave the build
+ // staged and uninstalled.
+ const { rig, handle } = makeRig({
+ platform: 'linux',
+ lastSeenVersion: '0.3.0',
+ appVersion: '0.3.1',
+ });
+ expect(handle.isWithinPostUpdateQuietWindow()).toBe(false);
+
+ rig.updater.emit('update-downloaded', { version: '0.3.2' });
+
+ expect(rig.captured.filter((c) => c.channel === 'ok:update:downloaded')).toHaveLength(1);
+ expect(rig.dispatches).not.toContain('toast-a-deferred-post-update-quiet' as DispatchKind);
+ });
+
test('outside the window the banner fires immediately, as before', () => {
const { rig, handle } = makeRig({ lastSeenVersion: '0.3.1', appVersion: '0.3.1' });
expect(handle.isWithinPostUpdateQuietWindow()).toBe(false);