Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): keep the update-ready notice reachable, add Quit and Restart (PRD-9007) (#5610)

Andrew Mikofalvy9d1a7f1f7235
diff --git a/.changeset/update-ready-quit-and-restart.md b/.changeset/update-ready-quit-and-restart.md
new file mode 100644
index 000000000..85fbc207e
--- /dev/null
+++ b/.changeset/update-ready-quit-and-restart.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge-desktop": patch
+---
+
+The relaunch notice for a downloaded update now reappears in new or reloaded windows and after Check for Updates, and the Update Ready dialog offers Quit and Restart to install it right away.
diff --git a/knip.config.ts b/knip.config.ts
index 65f0e8807..d3638888e 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -147,11 +147,15 @@ export default {
'packages/server': {
entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],
project: 'src/**',
- ignoreDependencies: ['@types/shell-quote'],
+ ignoreDependencies: [
+ '@types/shell-quote',
+ ],
},
'packages/cli': {
entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],
- ignoreDependencies: ['yjs'],
+ ignoreDependencies: [
+ 'yjs',
+ ],
},
'packages/desktop': {
entry: [
diff --git a/packages/app/src/components/UpdateNotices.dom.test.tsx b/packages/app/src/components/UpdateNotices.dom.test.tsx
index f24ad4a5a..43204b8eb 100644
--- a/packages/app/src/components/UpdateNotices.dom.test.tsx
+++ b/packages/app/src/components/UpdateNotices.dom.test.tsx
@@ -1,7 +1,13 @@
+import type { OkUpdateRelaunchFailedInfo } from '@inkeep/open-knowledge-core/desktop-bridge';
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
import { afterEach, describe, expect, test, vi } from 'vitest';
+import type { OkDesktopBridge } from '@/lib/desktop-bridge-types';
import { NoticeCard } from './UpdateNotices';
-import { TOAST_A_PROGRESS_BODY, type UpdateNotice } from './UpdateNotices.shared';
+import {
+ attachUpdateSubscribers,
+ TOAST_A_PROGRESS_BODY,
+ type UpdateNotice,
+} from './UpdateNotices.shared';
const DISMISS_NAME = 'Dismiss notice';
@@ -54,3 +60,41 @@ describe('NoticeCard — dismiss X visibility', () => {
expect(screen.getByText('Stay')).toBeDefined();
});
});
+
+describe('NoticeCard — update no longer pending', () => {
+ afterEach(() => {
+ cleanup();
+ });
+
+ test('renders the not-ready copy with a Check for updates button that starts a check', () => {
+ let relaunchFailed: ((info: OkUpdateRelaunchFailedInfo) => void) | undefined;
+ const checkNow = vi.fn(() => Promise.resolve());
+ const noop = () => () => {};
+ const bridge = {
+ onUpdateDownloaded: noop,
+ onUpdateRelaunching: noop,
+ onUpdateFetchingLatest: noop,
+ onUpdateRelaunchFailed: (cb: (info: OkUpdateRelaunchFailedInfo) => void) => {
+ relaunchFailed = cb;
+ return () => {};
+ },
+ onWhatsNew: noop,
+ onWhatsNewDismissed: noop,
+ onUpdateStuckHint: noop,
+ onUpdateManualCheck: noop,
+ update: { relaunchNow: vi.fn(), checkNow, dismissWhatsNew: vi.fn() },
+ } as unknown as OkDesktopBridge;
+ const notices: UpdateNotice[] = [];
+ attachUpdateSubscribers(bridge, (n) => notices.push(n));
+
+ relaunchFailed?.({ version: '', reason: 'no-longer-pending', dismissPending: true });
+ const notice = notices.at(-1);
+ if (!notice) throw new Error('expected a notice');
+ render(<NoticeCard notice={notice} onDismiss={() => {}} />);
+
+ expect(screen.getByText('This update is no longer ready to install.')).toBeDefined();
+ expect(screen.queryByText(/restart manually/)).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Check for updates' }));
+ expect(checkNow).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/packages/app/src/components/UpdateNotices.shared.ts b/packages/app/src/components/UpdateNotices.shared.ts
index f4c2482ae..859f4e7ab 100644
--- a/packages/app/src/components/UpdateNotices.shared.ts
+++ b/packages/app/src/components/UpdateNotices.shared.ts
@@ -82,11 +82,13 @@ export function attachUpdateSubscribers(
let manualCheckAutoDismissTimer: ReturnType<typeof setTimeout> | null = null;
const downloadedNoticeId = 'update-downloaded';
+ const noLongerPendingNoticeId = 'update-no-longer-pending';
const manualCheckNoticeId = 'update-checking';
unsubscribers.push(
bridge.onUpdateDownloaded(({ version }) => {
const noticeId = downloadedNoticeId;
+ dismissNotice(noLongerPendingNoticeId);
const armReadyNotice = () => {
addNotice({
@@ -148,8 +150,28 @@ export function attachUpdateSubscribers(
);
unsubscribers.push(
- bridge.onUpdateRelaunchFailed(({ version, message, downloadUrl, dismissPending }) => {
+ bridge.onUpdateRelaunchFailed(({ version, message, downloadUrl, dismissPending, reason }) => {
if (dismissPending) dismissNotice(downloadedNoticeId);
+ if (reason === 'no-longer-pending') {
+ addNotice({
+ id: noLongerPendingNoticeId,
+ body: t`This update is no longer ready to install.`,
+ priority: PRIORITY_RELAUNCH_ERROR,
+ action: {
+ label: t`Check for updates`,
+ onClick: () => {
+ dismissNotice(noLongerPendingNoticeId);
+ bridge.update.checkNow().catch((err: unknown) => {
+ console.warn(
+ '[update-notice] check-for-updates from no-longer-pending rejected',
+ err,
+ );
+ });
+ },
+ },
+ });
+ return;
+ }
if (downloadUrl) {
const failedId = `install-failed-${version}`;
const armFailedNotice = (): void => {
diff --git a/packages/app/src/components/UpdateNotices.test.ts b/packages/app/src/components/UpdateNotices.test.ts
index 6ec0aeb7b..f568623a3 100644
--- a/packages/app/src/components/UpdateNotices.test.ts
+++ b/packages/app/src/components/UpdateNotices.test.ts
@@ -27,7 +27,13 @@ import {
type UpdateDownloadedCb = (info: { version: string }) => void;
type RelaunchingCb = (info: { version: string }) => void;
type FetchingLatestCb = (info: { version: string }) => void;
-type RelaunchFailedCb = (info: { version: string; message?: string; downloadUrl?: string }) => void;
+type RelaunchFailedCb = (info: {
+ version: string;
+ message?: string;
+ downloadUrl?: string;
+ dismissPending?: boolean;
+ reason?: 'no-longer-pending';
+}) => void;
type WhatsNewCb = (info: { version: string; releaseUrl: string }) => void;
type WhatsNewDismissedCb = (info: { version: string }) => void;
type StuckHintCb = (info: { downloadUrl: string }) => void;
@@ -44,6 +50,7 @@ interface FakeBridge {
onUpdateManualCheck: ReturnType<typeof vi.fn>;
update: {
relaunchNow: ReturnType<typeof vi.fn>;
+ checkNow: ReturnType<typeof vi.fn>;
dismissWhatsNew: ReturnType<typeof vi.fn>;
};
state: {
@@ -89,6 +96,7 @@ function makeFakeBridge(): FakeBridge {
onUpdateManualCheck: vi.fn(() => {}),
update: {
relaunchNow: vi.fn(() => Promise.resolve(undefined)),
+ checkNow: vi.fn(() => Promise.resolve(undefined)),
dismissWhatsNew: vi.fn(() => Promise.resolve(undefined)),
},
state: {
@@ -442,7 +450,7 @@ describe('Notice A cross-window relaunch — ok:update:relaunching', () => {
bridge._fetchingLatest?.({ version: '0.1.1' });
bridge._relaunchFailed?.({
version: '0.1.1',
- message: 'the update stopped being available',
+ message: 'the update timed out',
dismissPending: true,
});
@@ -450,7 +458,104 @@ describe('Notice A cross-window relaunch — ok:update:relaunching', () => {
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');
+ expect(error.body).toBe(`${TOAST_A_ERROR_BODY}: the update timed out`);
+ });
+
+ test('no-longer-pending says the update is not ready and offers a check, not a manual restart', () => {
+ 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',
+ reason: 'no-longer-pending',
+ dismissPending: true,
+ });
+
+ expect(dismissed).toContain('update-downloaded');
+ const notice = addNotice.mock.calls.at(-1)?.[0] as UpdateNotice;
+ expect(notice.id).toBe('update-no-longer-pending');
+ expect(notice.body).toBe('This update is no longer ready to install.');
+ expect(notice.body).not.toContain(TOAST_A_ERROR_BODY);
+ expect(notice.variant).toBeUndefined();
+ expect(notice.priority).toBe(1);
+ expect(notice.action?.label).toBe('Check for updates');
+ expect(notice.secondaryAction).toBeUndefined();
+ });
+
+ test('the no-longer-pending notice id does not depend on the version, even an empty one', () => {
+ const bridge = makeFakeBridge();
+ const addNotice = vi.fn<(notice: UpdateNotice) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice);
+
+ bridge._relaunchFailed?.({ version: '', reason: 'no-longer-pending', dismissPending: true });
+ bridge._relaunchFailed?.({
+ version: '0.1.1',
+ reason: 'no-longer-pending',
+ dismissPending: true,
+ });
+
+ expect(addNotice.mock.calls.map(([n]) => n.id)).toEqual([
+ 'update-no-longer-pending',
+ 'update-no-longer-pending',
+ ]);
+ });
+
+ test('Check for updates dismisses the notice and starts a check', async () => {
+ const bridge = makeFakeBridge();
+ const addNotice = vi.fn<(notice: UpdateNotice) => void>(() => {});
+ const dismissNotice = vi.fn<(id: string) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice, dismissNotice);
+ bridge._relaunchFailed?.({ version: '', reason: 'no-longer-pending', dismissPending: true });
+ dismissNotice.mockClear();
+
+ const notice = addNotice.mock.calls.at(-1)?.[0] as UpdateNotice;
+ notice.action?.onClick();
+ await Promise.resolve();
+
+ expect(dismissNotice).toHaveBeenCalledExactlyOnceWith('update-no-longer-pending');
+ expect(bridge.update.checkNow).toHaveBeenCalledTimes(1);
+ expect(bridge.update.relaunchNow).not.toHaveBeenCalled();
+ });
+
+ test('a rejected check from the no-longer-pending notice is logged, not thrown', async () => {
+ const bridge = makeFakeBridge();
+ const failure = new Error('updater offline');
+ bridge.update.checkNow = vi.fn(() => Promise.reject(failure));
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ const addNotice = vi.fn<(notice: UpdateNotice) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice);
+ bridge._relaunchFailed?.({ version: '', reason: 'no-longer-pending', dismissPending: true });
+
+ const notice = addNotice.mock.calls.at(-1)?.[0] as UpdateNotice;
+ notice.action?.onClick();
+ await Promise.resolve();
+ await Promise.resolve();
+
+ expect(warn).toHaveBeenCalledWith(
+ '[update-notice] check-for-updates from no-longer-pending rejected',
+ failure,
+ );
+ warn.mockRestore();
+ });
+
+ test('a newly downloaded build clears a stale no-longer-pending notice so the card can show', () => {
+ const bridge = makeFakeBridge();
+ const addNotice = vi.fn<(notice: UpdateNotice) => void>(() => {});
+ const dismissNotice = vi.fn<(id: string) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice, dismissNotice);
+ bridge._relaunchFailed?.({ version: '', reason: 'no-longer-pending', dismissPending: true });
+ dismissNotice.mockClear();
+
+ bridge._downloaded?.({ version: '0.1.2' });
+
+ expect(dismissNotice).toHaveBeenCalledExactlyOnceWith('update-no-longer-pending');
+ const card = addNotice.mock.calls.at(-1)?.[0] as UpdateNotice;
+ expect(card.id).toBe('update-downloaded');
});
test('an ordinary relaunch-failed leaves the banner alone (main re-arms it)', () => {
@@ -642,6 +747,7 @@ describe('Notice A — ok:update:downloaded', () => {
const dismissNotice = vi.fn<(id: string) => void>(() => {});
attachUpdateSubscribers(castBridge(bridge), addNotice, dismissNotice);
bridge._downloaded?.({ version: '0.1.1' });
+ dismissNotice.mockClear();
const notice = addNotice.mock.calls[0]?.[0] as UpdateNotice;
notice.action?.onClick();
await Promise.resolve();
@@ -657,6 +763,7 @@ describe('Notice A — ok:update:downloaded', () => {
const dismissNotice = vi.fn<(id: string) => void>(() => {});
attachUpdateSubscribers(castBridge(bridge), addNotice, dismissNotice);
bridge._downloaded?.({ version: '0.1.1' });
+ dismissNotice.mockClear();
const notice = addNotice.mock.calls[0]?.[0] as UpdateNotice;
notice.action?.onClick();
await Promise.resolve();
diff --git a/packages/app/src/locales/ar/messages.json b/packages/app/src/locales/ar/messages.json
index 744db5c37..4e692f9b1 100644
--- a/packages/app/src/locales/ar/messages.json
+++ b/packages/app/src/locales/ar/messages.json
@@ -5547,6 +5547,7 @@
"pI_bKs": ["<0>مسافة</0> للقفز · <1>↓</1> للانحناء"],
"pJ7XCo": ["لا تشير هذه الصفحة إلى أي ملفات أو صور محلية."],
"pMPnZv": ["تم حذف ", ["deleted"], " مهارات"],
+ "pNy87H": ["لم يعد هذا التحديث جاهزًا للتثبيت."],
"pOo4Aa": ["نص عادي"],
"pPiV8s": ["تفعيل تلقائي (سحب ودفع)"],
"pSF7TJ": ["يتعذر قراءة مسار نسخة العمل هذه."],
diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.po
index 03e59a6f9..6876d1c5e 100644
--- a/packages/app/src/locales/ar/messages.po
+++ b/packages/app/src/locales/ar/messages.po
@@ -2909,6 +2909,7 @@ msgid "Chat name"
msgstr "اسم المحادثة"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "التحقق من التحديثات"
@@ -15571,6 +15572,10 @@ msgstr "تعذّرت قراءة ملف السمة هذا"
msgid "This theme file is too large"
msgstr "ملف السمة هذا كبير جدًا"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "لم يعد هذا التحديث جاهزًا للتثبيت."
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "يعني هذا عادةً أحد الأمور التالية:"
diff --git a/packages/app/src/locales/bn/messages.json b/packages/app/src/locales/bn/messages.json
index 185c37003..3ed5a3fa7 100644
--- a/packages/app/src/locales/bn/messages.json
+++ b/packages/app/src/locales/bn/messages.json
@@ -4706,6 +4706,7 @@
"pI_bKs": ["লাফাতে <0>স্পেস</0> · নিচু হতে <1>↓</1>"],
"pJ7XCo": ["এই পাতাটি কোনো স্থানীয় ফাইল বা ছবি উল্লেখ করে না।"],
"pMPnZv": [["deleted"], "টি স্কিল মুছে ফেলা হয়েছে"],
+ "pNy87H": ["এই হালনাগাদটি আর ইনস্টলের জন্য প্রস্তুত নয়।"],
"pOo4Aa": ["সাধারণ টেক্সট"],
"pPiV8s": ["স্বয়ংক্রিয় (টানুন ও পাঠান) চালু করুন"],
"pSF7TJ": ["এই চেকআউট পাথ পড়া যাচ্ছে না।"],
diff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.po
index 942ef4c72..11ef18325 100644
--- a/packages/app/src/locales/bn/messages.po
+++ b/packages/app/src/locales/bn/messages.po
@@ -2905,6 +2905,7 @@ msgid "Chat name"
msgstr "চ্যাটের নাম"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "হালনাগাদ দেখুন"
@@ -15567,6 +15568,10 @@ msgstr "এই থিম ফাইলটি পড়া যায়নি"
msgid "This theme file is too large"
msgstr "এই থিম ফাইলটি খুব বড়"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "এই হালনাগাদটি আর ইনস্টলের জন্য প্রস্তুত নয়।"
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "এর সাধারণত অর্থ এগুলোর একটি:"
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index c54bfb47a..13a6b5c2d 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -4863,6 +4863,7 @@
"pI_bKs": ["<0>Space</0> to jump · <1>↓</1> to duck"],
"pJ7XCo": ["This page references no local files or images."],
"pMPnZv": ["Deleted ", ["deleted"], " skills"],
+ "pNy87H": ["This update is no longer ready to install."],
"pOo4Aa": ["Plain text"],
"pPiV8s": ["Enable Auto (Pull and Push)"],
"pSF7TJ": ["This checkout path cannot be read."],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 07c42879a..cd1f1978b 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -2909,6 +2909,7 @@ msgid "Chat name"
msgstr "Chat name"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "Check for updates"
@@ -15571,6 +15572,10 @@ msgstr "This theme file couldn’t be read"
msgid "This theme file is too large"
msgstr "This theme file is too large"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "This update is no longer ready to install."
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "This usually means one of:"
diff --git a/packages/app/src/locales/es/messages.json b/packages/app/src/locales/es/messages.json
index 8c701dfcd..aefd03c65 100644
--- a/packages/app/src/locales/es/messages.json
+++ b/packages/app/src/locales/es/messages.json
@@ -5606,6 +5606,7 @@
"pI_bKs": ["<0>Espacio</0> para saltar · <1>↓</1> para agacharse"],
"pJ7XCo": ["Esta página no hace referencia a ningún archivo o imagen local."],
"pMPnZv": [["deleted"], " habilidades eliminadas"],
+ "pNy87H": ["Esta actualización ya no está lista para instalarse."],
"pOo4Aa": ["Texto sin formato"],
"pPiV8s": ["Activar Automático (Pull y Push)"],
"pSF7TJ": ["No se puede leer esta ruta de checkout."],
diff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.po
index 0b888df8f..0e2da6201 100644
--- a/packages/app/src/locales/es/messages.po
+++ b/packages/app/src/locales/es/messages.po
@@ -2909,6 +2909,7 @@ msgid "Chat name"
msgstr "Nombre del chat"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "Buscar actualizaciones"
@@ -15571,6 +15572,10 @@ msgstr "No se pudo leer este archivo de tema"
msgid "This theme file is too large"
msgstr "Este archivo de tema es demasiado grande"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "Esta actualización ya no está lista para instalarse."
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "Esto suele significar una de estas cosas:"
diff --git a/packages/app/src/locales/fr/messages.json b/packages/app/src/locales/fr/messages.json
index 40ec4d317..2d3f81f5b 100644
--- a/packages/app/src/locales/fr/messages.json
+++ b/packages/app/src/locales/fr/messages.json
@@ -5653,6 +5653,7 @@
"pI_bKs": ["<0>Espace</0> pour sauter · <1>↓</1> pour s’accroupir"],
"pJ7XCo": ["Cette page ne référence aucun fichier ou image local."],
"pMPnZv": [["deleted"], " compétences supprimées"],
+ "pNy87H": ["Cette mise à jour n'est plus prête à être installée."],
"pOo4Aa": ["Texte brut"],
"pPiV8s": ["Activer Auto (Tirer et Pousser)"],
"pSF7TJ": ["Impossible de lire cet emplacement de checkout."],
diff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.po
index 9baafe7d2..acaeb7e49 100644
--- a/packages/app/src/locales/fr/messages.po
+++ b/packages/app/src/locales/fr/messages.po
@@ -2909,6 +2909,7 @@ msgid "Chat name"
msgstr "Nom du chat"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "Rechercher les mises à jour"
@@ -15571,6 +15572,10 @@ msgstr "Impossible de lire ce fichier de thème"
msgid "This theme file is too large"
msgstr "Ce fichier de thème est trop volumineux"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "Cette mise à jour n'est plus prête à être installée."
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "Cela signifie généralement l'une de ces choses :"
diff --git a/packages/app/src/locales/hi/messages.json b/packages/app/src/locales/hi/messages.json
index a62259034..97bae96e1 100644
--- a/packages/app/src/locales/hi/messages.json
+++ b/packages/app/src/locales/hi/messages.json
@@ -4695,6 +4695,7 @@
"pI_bKs": ["कूदने के लिए <0>स्पेस</0> · झुकने के लिए <1>↓</1>"],
"pJ7XCo": ["यह पेज किसी स्थानीय फ़ाइल या छवि को संदर्भित नहीं करता।"],
"pMPnZv": [["deleted"], " स्किलें हटाई गईं"],
+ "pNy87H": ["यह अपडेट अब इंस्टॉल करने के लिए तैयार नहीं है।"],
"pOo4Aa": ["सादा टेक्स्ट"],
"pPiV8s": ["स्वचालित (खींचें और भेजें) चालू करें"],
"pSF7TJ": ["इस चेकआउट पथ को पढ़ा नहीं जा सकता।"],
diff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.po
index bd8c31684..098522d32 100644
--- a/packages/app/src/locales/hi/messages.po
+++ b/packages/app/src/locales/hi/messages.po
@@ -2905,6 +2905,7 @@ msgid "Chat name"
msgstr "चैट का नाम"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "अपडेट देखें"
@@ -15567,6 +15568,10 @@ msgstr "यह थीम फ़ाइल पढ़ी नहीं जा सक
msgid "This theme file is too large"
msgstr "यह थीम फ़ाइल बहुत बड़ी है"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "यह अपडेट अब इंस्टॉल करने के लिए तैयार नहीं है।"
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "इसका आमतौर पर मतलब इनमें से एक होता है:"
diff --git a/packages/app/src/locales/id/messages.json b/packages/app/src/locales/id/messages.json
index 1d8bbdc5e..8ffdf1c70 100644
--- a/packages/app/src/locales/id/messages.json
+++ b/packages/app/src/locales/id/messages.json
@@ -4877,6 +4877,7 @@
"pI_bKs": ["<0>Spasi</0> untuk melompat · <1>↓</1> untuk menunduk"],
"pJ7XCo": ["Halaman ini tidak merujuk ke berkas atau gambar lokal apa pun."],
"pMPnZv": [["deleted"], " keterampilan dihapus"],
+ "pNy87H": ["Pembaruan ini tidak lagi siap dipasang."],
"pOo4Aa": ["Teks biasa"],
"pPiV8s": ["Aktifkan Otomatis (Pull dan Push)"],
"pSF7TJ": ["Jalur checkout ini tidak dapat dibaca."],
diff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.po
index f2efeeb82..3e3c7ba35 100644
--- a/packages/app/src/locales/id/messages.po
+++ b/packages/app/src/locales/id/messages.po
@@ -2905,6 +2905,7 @@ msgid "Chat name"
msgstr "Nama obrolan"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "Periksa pembaruan"
@@ -15567,6 +15568,10 @@ msgstr "Berkas tema ini tidak dapat dibaca"
msgid "This theme file is too large"
msgstr "Berkas tema ini terlalu besar"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "Pembaruan ini tidak lagi siap dipasang."
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "Biasanya ini berarti salah satu dari:"
diff --git a/packages/app/src/locales/ko/messages.json b/packages/app/src/locales/ko/messages.json
index bb21b2201..bb067b821 100644
--- a/packages/app/src/locales/ko/messages.json
+++ b/packages/app/src/locales/ko/messages.json
@@ -4667,6 +4667,7 @@
"pI_bKs": ["<0>스페이스</0>로 점프 · <1>↓</1>로 숙이기"],
"pJ7XCo": ["이 페이지는 로컬 파일이나 이미지를 참조하지 않습니다."],
"pMPnZv": ["스킬 ", ["deleted"], "개 삭제됨"],
+ "pNy87H": ["이 업데이트는 더 이상 설치할 준비가 되어 있지 않습니다."],
"pOo4Aa": ["일반 텍스트"],
"pPiV8s": ["자동(풀 및 푸시) 활성화"],
"pSF7TJ": ["이 체크아웃 경로를 읽을 수 없습니다."],
diff --git a/packages/app/src/locales/ko/messages.po b/packages/app/src/locales/ko/messages.po
index 2efcb4bb1..ed37364a9 100644
--- a/packages/app/src/locales/ko/messages.po
+++ b/packages/app/src/locales/ko/messages.po
@@ -2909,6 +2909,7 @@ msgid "Chat name"
msgstr "채팅 이름"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "업데이트 확인"
@@ -15571,6 +15572,10 @@ msgstr "이 테마 파일을 읽지 못했습니다"
msgid "This theme file is too large"
msgstr "이 테마 파일은 너무 큽니다"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "이 업데이트는 더 이상 설치할 준비가 되어 있지 않습니다."
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "일반적으로 다음 중 하나입니다:"
diff --git a/packages/app/src/locales/pl/messages.json b/packages/app/src/locales/pl/messages.json
index 615efc3b4..40b2eb068 100644
--- a/packages/app/src/locales/pl/messages.json
+++ b/packages/app/src/locales/pl/messages.json
@@ -5723,6 +5723,7 @@
"pI_bKs": ["<0>Spacja</0>, aby przeskoczyć · <1>↓</1>, aby się schować"],
"pJ7XCo": ["Ta strona nie odwołuje się do żadnych lokalnych plików ani obrazów."],
"pMPnZv": ["Usunięto ", ["deleted"], " umiejętności"],
+ "pNy87H": ["Ta aktualizacja nie jest już gotowa do instalacji."],
"pOo4Aa": ["Tekst zwykły"],
"pPiV8s": ["Włącz Auto (pobieranie i wysyłanie)"],
"pSF7TJ": ["Nie można odczytać tej ścieżki checkoutu."],
diff --git a/packages/app/src/locales/pl/messages.po b/packages/app/src/locales/pl/messages.po
index 6c3347f8b..fcddfcf76 100644
--- a/packages/app/src/locales/pl/messages.po
+++ b/packages/app/src/locales/pl/messages.po
@@ -2909,6 +2909,7 @@ msgid "Chat name"
msgstr "Nazwa czatu"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "Sprawdź aktualizacje"
@@ -15571,6 +15572,10 @@ msgstr "Nie udało się odczytać tego pliku motywu"
msgid "This theme file is too large"
msgstr "Ten plik motywu jest za duży"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "Ta aktualizacja nie jest już gotowa do instalacji."
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "Zwykle oznacza to jedno z:"
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index cadb1b863..28a1ab6d7 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -4863,6 +4863,7 @@
"pI_bKs": ["<0>Śƥàćē</0> ţō Ĵũḿƥ · <1>↓</1> ţō ďũćķ"],
"pJ7XCo": ["Ţĥĩś ƥàĝē ŕēƒēŕēńćēś ńō ĺōćàĺ ƒĩĺēś ōŕ ĩḿàĝēś."],
"pMPnZv": ["Ďēĺēţēď ", ["deleted"], " śķĩĺĺś"],
+ "pNy87H": ["Ţĥĩś ũƥďàţē ĩś ńō ĺōńĝēŕ ŕēàďŷ ţō ĩńśţàĺĺ."],
"pOo4Aa": ["Ƥĺàĩń ţēxţ"],
"pPiV8s": ["Ēńàƀĺē Àũţō (Ƥũĺĺ àńď Ƥũśĥ)"],
"pSF7TJ": ["Ţĥĩś ćĥēćķōũţ ƥàţĥ ćàńńōţ ƀē ŕēàď."],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 7693ba942..37742c6a7 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -2905,6 +2905,7 @@ msgid "Chat name"
msgstr ""
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr ""
@@ -15567,6 +15568,10 @@ msgstr ""
msgid "This theme file is too large"
msgstr ""
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr ""
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr ""
diff --git a/packages/app/src/locales/pt-BR/messages.json b/packages/app/src/locales/pt-BR/messages.json
index cfa9fa87f..fba8ebbde 100644
--- a/packages/app/src/locales/pt-BR/messages.json
+++ b/packages/app/src/locales/pt-BR/messages.json
@@ -5493,6 +5493,7 @@
"pI_bKs": ["<0>Espaço</0> para pular · <1>↓</1> para agachar"],
"pJ7XCo": ["Esta página não faz referência a nenhum arquivo ou imagem local."],
"pMPnZv": [["deleted"], " habilidades excluídas"],
+ "pNy87H": ["Esta atualização não está mais pronta para ser instalada."],
"pOo4Aa": ["Texto simples"],
"pPiV8s": ["Ativar Automático (Pull e Push)"],
"pSF7TJ": ["Não é possível ler este caminho de checkout."],
diff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.po
index a6a0f3229..e9e070091 100644
--- a/packages/app/src/locales/pt-BR/messages.po
+++ b/packages/app/src/locales/pt-BR/messages.po
@@ -2905,6 +2905,7 @@ msgid "Chat name"
msgstr "Nome do chat"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "Buscar atualizações"
@@ -15567,6 +15568,10 @@ msgstr "Não foi possível ler este arquivo de tema"
msgid "This theme file is too large"
msgstr "Este arquivo de tema é muito grande"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "Esta atualização não está mais pronta para ser instalada."
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "Isto costuma significar uma destas coisas:"
diff --git a/packages/app/src/locales/ur/messages.json b/packages/app/src/locales/ur/messages.json
index 4e3d22f6e..a6235cb41 100644
--- a/packages/app/src/locales/ur/messages.json
+++ b/packages/app/src/locales/ur/messages.json
@@ -4955,6 +4955,7 @@
"pI_bKs": ["چھلانگ کے لیے <0>اسپیس</0> · جھکنے کے لیے <1>↓</1>"],
"pJ7XCo": ["یہ صفحہ کسی مقامی فائل یا تصویر کا حوالہ نہیں دیتا۔"],
"pMPnZv": [["deleted"], " مہارتیں حذف ہو گئیں"],
+ "pNy87H": ["یہ اپ ڈیٹ اب نصب کرنے کے لیے تیار نہیں ہے۔"],
"pOo4Aa": ["سادہ متن"],
"pPiV8s": ["خودکار (کھینچیں اور پُش) فعال کریں"],
"pSF7TJ": ["اس چیک آؤٹ پاتھ کو پڑھا نہیں جا سکتا۔"],
diff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.po
index 7170aa169..add1e01d2 100644
--- a/packages/app/src/locales/ur/messages.po
+++ b/packages/app/src/locales/ur/messages.po
@@ -2909,6 +2909,7 @@ msgid "Chat name"
msgstr "چیٹ کا نام"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "اپ ڈیٹس دیکھیں"
@@ -15571,6 +15572,10 @@ msgstr "یہ تھیم فائل پڑھی نہیں جا سکی"
msgid "This theme file is too large"
msgstr "یہ تھیم فائل بہت بڑی ہے"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "یہ اپ ڈیٹ اب نصب کرنے کے لیے تیار نہیں ہے۔"
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "اس کا عام طور پر مطلب ان میں سے کوئی ایک ہے:"
diff --git a/packages/app/src/locales/zh-Hans/messages.json b/packages/app/src/locales/zh-Hans/messages.json
index 5984259d1..461309135 100644
--- a/packages/app/src/locales/zh-Hans/messages.json
+++ b/packages/app/src/locales/zh-Hans/messages.json
@@ -4235,6 +4235,7 @@
"pI_bKs": ["<0>空格</0>跳跃 · <1>↓</1>下蹲"],
"pJ7XCo": ["此页面未引用任何本地文件或图片。"],
"pMPnZv": ["已删除 ", ["deleted"], " 个技能"],
+ "pNy87H": ["此更新已不再可供安装。"],
"pOo4Aa": ["纯文本"],
"pPiV8s": ["启用自动(拉取和推送)"],
"pSF7TJ": ["无法读取此检出路径。"],
diff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.po
index b0a4c2f58..7a66549a7 100644
--- a/packages/app/src/locales/zh-Hans/messages.po
+++ b/packages/app/src/locales/zh-Hans/messages.po
@@ -2909,6 +2909,7 @@ msgid "Chat name"
msgstr "对话名称"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "检查更新"
@@ -15571,6 +15572,10 @@ msgstr "无法读取此主题文件"
msgid "This theme file is too large"
msgstr "此主题文件过大"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "此更新已不再可供安装。"
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "这通常意味着以下之一:"
diff --git a/packages/app/src/locales/zh-Hant/messages.json b/packages/app/src/locales/zh-Hant/messages.json
index a56ac1eec..a0263caad 100644
--- a/packages/app/src/locales/zh-Hant/messages.json
+++ b/packages/app/src/locales/zh-Hant/messages.json
@@ -4255,6 +4255,7 @@
"pI_bKs": ["<0>空白鍵</0>跳躍 · <1>↓</1>蹲下"],
"pJ7XCo": ["此頁面未引用任何本機檔案或圖片。"],
"pMPnZv": ["已刪除 ", ["deleted"], " 個技能"],
+ "pNy87H": ["此更新已不再可供安裝。"],
"pOo4Aa": ["純文字"],
"pPiV8s": ["啟用自動(拉取與推送)"],
"pSF7TJ": ["無法讀取此簽出路徑。"],
diff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.po
index 13dd8facd..1136e002f 100644
--- a/packages/app/src/locales/zh-Hant/messages.po
+++ b/packages/app/src/locales/zh-Hant/messages.po
@@ -2909,6 +2909,7 @@ msgid "Chat name"
msgstr "對話名稱"
#: src/components/command-palette-commands.ts
+#: src/components/UpdateNotices.shared.ts
msgid "Check for updates"
msgstr "檢查更新"
@@ -15571,6 +15572,10 @@ msgstr "無法讀取這個主題檔案"
msgid "This theme file is too large"
msgstr "這個主題檔案太大"
+#: src/components/UpdateNotices.shared.ts
+msgid "This update is no longer ready to install."
+msgstr "此更新已不再可供安裝。"
+
#: src/components/ShareReceiveDialog.tsx
msgid "This usually means one of:"
msgstr "這通常代表下列其中之一:"
diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
index a50b00123..4549c74b3 100644
--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
@@ -1,3 +1,4 @@
+
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
index 6fcdc23f2..4fc2c11f9 100644
--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
@@ -1,3 +1,4 @@
+
import { setTimeout as wait } from 'node:timers/promises';
import { normalizeBridge } from '@inkeep/open-knowledge-core';
import { updateYFragment } from '@tiptap/y-tiptap';
diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.ts
index 40b5cdfd6..9f2f6feb6 100644
--- a/packages/app/tests/integration/interior-edit-freshness.test.ts
+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts
@@ -1,3 +1,4 @@
+
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
index 93666af70..2a085742b 100644
--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
@@ -1,3 +1,4 @@
+
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.ts
index 867598d34..878d5196b 100644
--- a/packages/app/tests/integration/producer-guard-wiring.test.ts
+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts
@@ -1,3 +1,4 @@
+
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
index 0970ac12f..4ada3cf26 100644
--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
@@ -1,3 +1,4 @@
+
import { randomUUID } from 'node:crypto';
import { afterEach, describe, expect, test } from 'vitest';
import { agentWriteMd, createTestServer, type TestServer } from './test-harness';
diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
index b632185e1..cbe2b705f 100644
--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
@@ -1,3 +1,4 @@
+
import { execFileSync } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { join } from 'node:path';
diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
index c530ce4ba..89bc9b4d9 100644
--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
@@ -1,3 +1,4 @@
+
import { randomUUID } from 'node:crypto';
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';
import type * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.ts
index d3767adc9..a78aeb0e4 100644
--- a/packages/app/tests/integration/undo-after-rollback.test.ts
+++ b/packages/app/tests/integration/undo-after-rollback.test.ts
@@ -1,3 +1,4 @@
+
import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.ts
index b076f955c..e7cc69c3f 100644
--- a/packages/app/tests/integration/undo-recycle-reset.test.ts
+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts
@@ -1,3 +1,4 @@
+
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.ts
index 7935e35f8..9ddcd0730 100644
--- a/packages/app/tests/integration/undo-rederive-survival.test.ts
+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts
@@ -1,3 +1,4 @@
+
import { prependFrontmatter } from '@inkeep/open-knowledge-core';
import { Plugin, PluginKey } from '@tiptap/pm/state';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.ts
index f4cc8a286..2a597ec3d 100644
--- a/packages/core/src/bridge/compose.ts
+++ b/packages/core/src/bridge/compose.ts
@@ -1,3 +1,4 @@
+
import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';
export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';
diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index 8fb428b90..01ef76a9f 100644
--- a/packages/core/src/bridge/doc-boundary-space.ts
+++ b/packages/core/src/bridge/doc-boundary-space.ts
@@ -1,3 +1,4 @@
+
import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';
import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';
diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.ts
index 37bf62270..fda83c6c7 100644
--- a/packages/core/src/desktop-bridge.ts
+++ b/packages/core/src/desktop-bridge.ts
@@ -260,6 +260,7 @@ export interface OkUpdateRelaunchFailedInfo {
readonly message?: string;
readonly downloadUrl?: string;
readonly dismissPending?: boolean;
+ readonly reason?: 'no-longer-pending';
}
export interface OkWhatsNewInfo {
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index fc267cbea..fb0ba5a7c 100644
--- a/packages/core/src/markdown/comment-promoter.ts
+++ b/packages/core/src/markdown/comment-promoter.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.ts
index bfd7e3109..fa3cfcd86 100644
--- a/packages/core/src/markdown/merged-walker.ts
+++ b/packages/core/src/markdown/merged-walker.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Parent, Root } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.ts
index 4d3250d3a..8be632ba4 100644
--- a/packages/core/src/markdown/safe-url.ts
+++ b/packages/core/src/markdown/safe-url.ts
@@ -1,3 +1,4 @@
+
export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;
const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');
diff --git a/packages/desktop/src/main/auto-updater.ts b/packages/desktop/src/main/auto-updater.ts
index 088d5be37..8214bc6d7 100644
--- a/packages/desktop/src/main/auto-updater.ts
+++ b/packages/desktop/src/main/auto-updater.ts
@@ -90,6 +90,8 @@ export type DispatchKind =
| 'relaunch-double-invoke-blocked'
| 'check-now-already-pending'
| 'check-now-watchdog-fired'
+ | 'check-now-relaunch-chosen'
+ | 'check-now-ready-reoffered'
| 'toast-a-deferred-post-update-quiet'
| 'toast-a-quiet-window-elapsed';
@@ -120,7 +122,7 @@ interface StartAutoUpdaterOpts {
showManualInstallFallback: (ctx: LinuxManualInstallContext) => undefined | Promise<unknown>;
stagedInstallerExists?: (path: string) => boolean;
};
- showCheckNowResult?: (result: CheckNowResult) => void;
+ showCheckNowResult?: (result: CheckNowResult) => undefined | Promise<CheckNowResultResponse>;
clock?: Clock;
now?: () => Date;
random?: () => number;
@@ -128,9 +130,18 @@ interface StartAutoUpdaterOpts {
logger?: Logger;
}
+type CheckNowResultResponse = 'relaunch' | 'dismiss';
+
+type StagedRelaunch = 'available' | 'installing' | 'not-pending';
+
type CheckNowResult =
| { kind: 'available'; currentVersion: string; latestVersion: string }
- | { kind: 'ready-to-install'; currentVersion: string; stagedVersion: string }
+ | {
+ kind: 'ready-to-install';
+ currentVersion: string;
+ stagedVersion: string;
+ relaunch: StagedRelaunch;
+ }
| { kind: 'not-available'; currentVersion: string }
| { kind: 'error'; message: string };
@@ -138,7 +149,7 @@ export interface StartAutoUpdaterHandle {
destroy(): void;
checkForUpdatesNow(): Promise<unknown>;
getActiveWhatsNew(): { version: string; releaseUrl: string } | null;
- isWithinPostUpdateQuietWindow(): boolean;
+ getPendingUpdate(): { version: string } | null;
suppressAutoInstallOnQuit(): void;
recordInstallHandoffOnQuit(): void;
}
@@ -678,16 +689,57 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
clock.clearTimeout(menuCheck.watchdog);
menuCheck = null;
broadcastToAllWindows('ok:update:manual-check', { phase: 'settled' });
- if (result !== null) {
- try {
- showCheckNowResult?.(result);
- } catch (err) {
- logger.error('showCheckNowResult threw, check-now result dialog not shown', {
- err,
- result,
- });
- }
+ if (result === null) return;
+ if (result.kind === 'ready-to-install') reofferStagedForMenuCheck(result.stagedVersion);
+ let response: ReturnType<NonNullable<typeof showCheckNowResult>>;
+ try {
+ response = showCheckNowResult?.(result);
+ } catch (err) {
+ logger.error('showCheckNowResult threw, check-now result dialog not shown', {
+ err,
+ result,
+ });
+ return;
}
+ if (response === undefined) return;
+ void Promise.resolve(response).then(
+ (choice) => {
+ logger.info('check-now result dialog answered', { kind: result.kind, choice });
+ if (result.kind !== 'ready-to-install' || result.relaunch !== 'available') return;
+ if (choice !== 'relaunch' || destroyed) return;
+ onDispatch?.('check-now-relaunch-chosen');
+ return relaunchNow(result.stagedVersion).then(undefined, (err: unknown) => {
+ logger.error('check-now Update Ready dialog Quit and Restart failed', {
+ err,
+ stagedVersion: result.stagedVersion,
+ });
+ });
+ },
+ (err: unknown) => {
+ logger.error('check-now result dialog failed', { err, kind: result.kind });
+ },
+ );
+ };
+
+ const relaunchableVersion = (): string | null =>
+ installRequested ? null : readState().versionPendingInstall;
+
+ const stagedRelaunchFor = (version: string): StagedRelaunch => {
+ if (relaunchableVersion() === version) return 'available';
+ return installRequested ? 'installing' : 'not-pending';
+ };
+
+ const pendingToastA = (): { version: string } | null => {
+ if (withinPostUpdateQuietWindow()) return null;
+ const version = relaunchableVersion();
+ return version === null ? null : { version };
+ };
+
+ const reofferStagedForMenuCheck = (version: string): void => {
+ if (pendingToastA()?.version !== version) return;
+ broadcastToAllWindows('ok:update:downloaded', { version });
+ logger.info('check-now found the staged build ready — re-offered Toast A', { version });
+ onDispatch?.('check-now-ready-reoffered');
};
let relaunchInFlight: {
@@ -935,10 +987,19 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
}
const armedVersion = declinedForStagedVersion(info.version);
if (armedVersion !== null) {
+ const relaunch = stagedRelaunchFor(armedVersion);
+ if (relaunch !== 'available') {
+ logger.info('check-now found the staged build but withholds Quit and Restart', {
+ stagedVersion: armedVersion,
+ reason: relaunch,
+ pendingVersion: readState().versionPendingInstall,
+ });
+ }
settleMenuCheck({
kind: 'ready-to-install',
currentVersion: getAppVersion(),
stagedVersion: armedVersion,
+ relaunch,
});
return;
}
@@ -1159,8 +1220,7 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
);
};
- const register = createHandler(ipcMain as IpcMain);
- register('ok:update:relaunch-now', async (_event: IpcMainInvokeEvent): Promise<undefined> => {
+ const relaunchNow = async (requestedVersion?: string): Promise<undefined> => {
if (installRequested) {
logger.warn('relaunch-now invoked while an install is already committed — ignoring');
onDispatch?.('relaunch-double-invoke-blocked');
@@ -1168,7 +1228,14 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
}
const preRefresh = readState();
if (!preRefresh.versionPendingInstall) {
- logger.warn('relaunch-now invoked without versionPendingInstall — ignoring');
+ logger.warn('relaunch-now invoked without versionPendingInstall — ignoring', {
+ requestedVersion,
+ });
+ broadcastToAllWindows('ok:update:relaunch-failed', {
+ version: requestedVersion ?? stagedThisSession ?? '',
+ reason: 'no-longer-pending',
+ dismissPending: true,
+ });
return undefined;
}
installRequested = true;
@@ -1182,7 +1249,7 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
installRequested = false;
broadcastToAllWindows('ok:update:relaunch-failed', {
version: preRefresh.versionPendingInstall,
- message: 'the update stopped being available',
+ reason: 'no-longer-pending',
dismissPending: true,
});
return undefined;
@@ -1280,7 +1347,13 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
throw err;
}
return undefined;
- });
+ };
+
+ const register = createHandler(ipcMain as IpcMain);
+ register(
+ 'ok:update:relaunch-now',
+ (_event: IpcMainInvokeEvent): Promise<undefined> => relaunchNow(),
+ );
register('ok:update:check-now', (_event: IpcMainInvokeEvent): undefined => {
void runMenuDrivenCheck();
@@ -1593,8 +1666,8 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
}
return { version: activeWhatsNew.version, releaseUrl: activeWhatsNew.releaseUrl };
},
- isWithinPostUpdateQuietWindow(): boolean {
- return withinPostUpdateQuietWindow();
+ getPendingUpdate(): { version: string } | null {
+ return pendingToastA();
},
suppressAutoInstallOnQuit(): void {
updater.autoInstallOnAppQuit = false;
diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.ts
index 7722cf76c..ea72dcef3 100644
--- a/packages/desktop/src/main/index.ts
+++ b/packages/desktop/src/main/index.ts
@@ -182,6 +182,7 @@ import { resolveEffectiveInstanceName } from './auto-instance.ts';
import {
bootAutoUpdater,
installWasInFlightDuring,
+ STUCK_HINT_DOWNLOAD_URL,
type StartAutoUpdaterHandle,
} from './auto-updater.ts';
import { applyBackgroundThrottle } from './background-throttle.ts';
@@ -529,6 +530,10 @@ import {
resolveUninstallEntryTarget,
resolveUninstallWindowTheme,
} from './uninstall-window.ts';
+import {
+ deliverUpdateNoticesToLoadedWindows,
+ replayUpdateNoticesOnEveryLoad,
+} from './update-notice-replay.ts';
import {
applyResetIncompatible,
applyStateQuery,
@@ -1159,6 +1164,8 @@ const reducedTransparencyDeps: ReducedTransparencyDeps = {
},
};
let autoUpdaterHandle: StartAutoUpdaterHandle | null = null;
+const updateNoticeSource = (): StartAutoUpdaterHandle | null =>
+ app.isPackaged || process.env.OK_UPDATER_FORCE_DEV === '1' ? autoUpdaterHandle : null;
let bundleReplaceWatcherHandle: BundleReplaceWatcherHandle | null = null;
let debugIpc: DebugIpcHandle | null = null;
let mcpWiringHandle: RunMcpWiringHandle | null = null;
@@ -6428,17 +6435,7 @@ function bootPrimaryInstance(): void {
startupWaterfall.mark('bootstrapDone');
app.on('browser-window-created', (_event, win) => {
- win.webContents.once('did-finish-load', () => {
- if (!(app.isPackaged || process.env.OK_UPDATER_FORCE_DEV === '1')) return;
- const pending = appState.versionPendingInstall;
- if (pending && !autoUpdaterHandle?.isWithinPostUpdateQuietWindow()) {
- sendToRenderer(win.webContents, 'ok:update:downloaded', { version: pending });
- }
- const whatsNew = autoUpdaterHandle?.getActiveWhatsNew();
- if (whatsNew) {
- sendToRenderer(win.webContents, 'ok:update:whats-new', whatsNew);
- }
- });
+ replayUpdateNoticesOnEveryLoad(win.webContents, updateNoticeSource);
});
mcpWiringHandle = armMcpWiring();
@@ -6763,14 +6760,45 @@ function bootPrimaryInstance(): void {
detail: `OpenKnowledge ${result.currentVersion} is the most current version available.`,
});
} else if (result.kind === 'ready-to-install') {
- void dialog.showMessageBox(target, {
- type: 'info',
- buttons: ['OK'],
- defaultId: 0,
- title: 'Update Ready',
- message: `OpenKnowledge ${result.stagedVersion} is downloaded and ready.`,
- detail: `It installs the next time you relaunch. Any newer build is offered after that.`,
- });
+ switch (result.relaunch) {
+ case 'available':
+ return dialog
+ .showMessageBox(target, {
+ type: 'info',
+ buttons: ['Quit and Restart', 'Later'],
+ defaultId: 0,
+ cancelId: 1,
+ title: 'Update Ready',
+ message: `OpenKnowledge ${result.stagedVersion} is downloaded and ready.`,
+ detail:
+ 'Quit and restart now to install it, or it installs the next time you quit OpenKnowledge.',
+ })
+ .then(({ response }) => (response === 0 ? 'relaunch' : 'dismiss'));
+ case 'installing':
+ void dialog.showMessageBox(target, {
+ type: 'info',
+ buttons: ['OK'],
+ defaultId: 0,
+ title: 'Update Ready',
+ message: `OpenKnowledge ${result.stagedVersion} is downloaded and ready.`,
+ detail: 'OpenKnowledge is already restarting to install it.',
+ });
+ return undefined;
+ case 'not-pending':
+ void dialog.showMessageBox(target, {
+ type: 'info',
+ buttons: ['OK'],
+ defaultId: 0,
+ title: 'Update Downloaded',
+ message: `OpenKnowledge ${result.stagedVersion} was downloaded.`,
+ detail: `It may install the next time you quit OpenKnowledge. If it doesn't, download the latest build from ${STUCK_HINT_DOWNLOAD_URL}.`,
+ });
+ return undefined;
+ default: {
+ const _exhaustive: never = result.relaunch;
+ return _exhaustive;
+ }
+ }
} else if (result.kind === 'available') {
void dialog.showMessageBox(target, {
type: 'info',
@@ -6792,6 +6820,10 @@ function bootPrimaryInstance(): void {
}
},
});
+ deliverUpdateNoticesToLoadedWindows(
+ BrowserWindow.getAllWindows().map((win) => win.webContents),
+ updateNoticeSource(),
+ );
refreshApplicationMenu();
if (process.platform === 'darwin' && app.isPackaged) {
diff --git a/packages/desktop/src/main/update-notice-replay.test.ts b/packages/desktop/src/main/update-notice-replay.test.ts
new file mode 100644
index 000000000..9d6a5bf7c
--- /dev/null
+++ b/packages/desktop/src/main/update-notice-replay.test.ts
@@ -0,0 +1,178 @@
+import { EventEmitter } from 'node:events';
+import { describe, expect, test } from 'vitest';
+import {
+ deliverUpdateNoticesToLoadedWindows,
+ type LoadStateWebContents,
+ replayUpdateNoticesOnEveryLoad,
+ type UpdateNoticeReplayTarget,
+ type UpdateNoticeSource,
+} from './update-notice-replay.ts';
+
+interface Sent {
+ channel: string;
+ payload: unknown;
+}
+
+function makeWebContents() {
+ const emitter = new EventEmitter();
+ const sent: Sent[] = [];
+ let destroyed = false;
+ const webContents: UpdateNoticeReplayTarget = {
+ send: (channel: string, ...args: unknown[]) => {
+ sent.push({ channel, payload: args[0] });
+ },
+ isDestroyed: () => destroyed,
+ on: (event, listener) => emitter.on(event, listener),
+ once: (event, listener) => emitter.once(event, listener),
+ removeListener: (event, listener) => emitter.removeListener(event, listener),
+ };
+ return {
+ webContents,
+ sent,
+ load: () => emitter.emit('did-finish-load'),
+ destroy: () => {
+ destroyed = true;
+ emitter.emit('destroyed');
+ },
+ loadListenerCount: () => emitter.listenerCount('did-finish-load'),
+ };
+}
+
+function makeSource(initial: {
+ pending?: { version: string } | null;
+ whatsNew?: { version: string; releaseUrl: string } | null;
+}): UpdateNoticeSource & {
+ pending: { version: string } | null;
+ whatsNew: { version: string; releaseUrl: string } | null;
+} {
+ const source = {
+ pending: initial.pending ?? null,
+ whatsNew: initial.whatsNew ?? null,
+ getPendingUpdate: () => source.pending,
+ getActiveWhatsNew: () => source.whatsNew,
+ };
+ return source;
+}
+
+describe('replayUpdateNoticesOnEveryLoad', () => {
+ test('sends nothing until the page finishes loading', () => {
+ const wc = makeWebContents();
+ replayUpdateNoticesOnEveryLoad(wc.webContents, () =>
+ makeSource({ pending: { version: '1.2.3' } }),
+ );
+ expect(wc.sent).toEqual([]);
+ });
+
+ test('every load, reloads included, re-delivers the card the source offers', () => {
+ const wc = makeWebContents();
+ const source = makeSource({ pending: { version: '1.2.3' } });
+ replayUpdateNoticesOnEveryLoad(wc.webContents, () => source);
+
+ wc.load();
+ wc.load();
+ wc.load();
+
+ expect(wc.sent).toEqual([
+ { channel: 'ok:update:downloaded', payload: { version: '1.2.3' } },
+ { channel: 'ok:update:downloaded', payload: { version: '1.2.3' } },
+ { channel: 'ok:update:downloaded', payload: { version: '1.2.3' } },
+ ]);
+ });
+
+ test('asks the source at load time, so a withdrawn card is not replayed', () => {
+ const wc = makeWebContents();
+ const source = makeSource({ pending: { version: '1.2.3' } });
+ replayUpdateNoticesOnEveryLoad(wc.webContents, () => source);
+ wc.load();
+
+ source.pending = null;
+ wc.load();
+
+ expect(wc.sent).toEqual([{ channel: 'ok:update:downloaded', payload: { version: '1.2.3' } }]);
+ });
+
+ test('replays the active release-notes card too', () => {
+ const wc = makeWebContents();
+ const whatsNew = { version: '1.2.2', releaseUrl: 'https://example.test/r/1.2.2' };
+ replayUpdateNoticesOnEveryLoad(wc.webContents, () => makeSource({ whatsNew }));
+
+ wc.load();
+ wc.load();
+
+ expect(wc.sent).toEqual([
+ { channel: 'ok:update:whats-new', payload: whatsNew },
+ { channel: 'ok:update:whats-new', payload: whatsNew },
+ ]);
+ });
+
+ test('sends nothing while there is no source', () => {
+ const wc = makeWebContents();
+ replayUpdateNoticesOnEveryLoad(wc.webContents, () => null);
+ wc.load();
+ expect(wc.sent).toEqual([]);
+ });
+
+ test('attaching twice still delivers once per load', () => {
+ const wc = makeWebContents();
+ const source = makeSource({ pending: { version: '1.2.3' } });
+ replayUpdateNoticesOnEveryLoad(wc.webContents, () => source);
+ replayUpdateNoticesOnEveryLoad(wc.webContents, () => source);
+
+ wc.load();
+
+ expect(wc.loadListenerCount()).toBe(1);
+ expect(wc.sent).toHaveLength(1);
+ });
+
+ test('drops its load listener when the web contents is destroyed', () => {
+ const wc = makeWebContents();
+ replayUpdateNoticesOnEveryLoad(wc.webContents, () =>
+ makeSource({ pending: { version: '1.2.3' } }),
+ );
+ expect(wc.loadListenerCount()).toBe(1);
+
+ wc.destroy();
+
+ expect(wc.loadListenerCount()).toBe(0);
+ });
+});
+
+function makeLoadState(state: { loading: boolean; url: string; destroyed?: boolean }) {
+ const sent: Sent[] = [];
+ const webContents: LoadStateWebContents = {
+ send: (channel: string, ...args: unknown[]) => {
+ sent.push({ channel, payload: args[0] });
+ },
+ isDestroyed: () => state.destroyed === true,
+ isLoading: () => state.loading,
+ getURL: () => state.url,
+ };
+ return { webContents, sent };
+}
+
+describe('deliverUpdateNoticesToLoadedWindows', () => {
+ test('delivers only to windows whose page already finished loading', () => {
+ const loaded = makeLoadState({ loading: false, url: 'app://ok/index.html' });
+ const loading = makeLoadState({ loading: true, url: 'app://ok/index.html' });
+ const blank = makeLoadState({ loading: false, url: '' });
+ const destroyed = makeLoadState({ loading: false, url: 'app://ok/', destroyed: true });
+
+ deliverUpdateNoticesToLoadedWindows(
+ [loaded.webContents, loading.webContents, blank.webContents, destroyed.webContents],
+ makeSource({ pending: { version: '1.2.3' } }),
+ );
+
+ expect(loaded.sent).toEqual([
+ { channel: 'ok:update:downloaded', payload: { version: '1.2.3' } },
+ ]);
+ expect(loading.sent).toEqual([]);
+ expect(blank.sent).toEqual([]);
+ expect(destroyed.sent).toEqual([]);
+ });
+
+ test('sends nothing without a source', () => {
+ const loaded = makeLoadState({ loading: false, url: 'app://ok/index.html' });
+ deliverUpdateNoticesToLoadedWindows([loaded.webContents], null);
+ expect(loaded.sent).toEqual([]);
+ });
+});
diff --git a/packages/desktop/src/main/update-notice-replay.ts b/packages/desktop/src/main/update-notice-replay.ts
new file mode 100644
index 000000000..bbd3a47cc
--- /dev/null
+++ b/packages/desktop/src/main/update-notice-replay.ts
@@ -0,0 +1,56 @@
+import { type SendableWebContents, sendToRenderer } from '../shared/ipc-send.ts';
+
+export interface UpdateNoticeSource {
+ getPendingUpdate(): { version: string } | null;
+ getActiveWhatsNew(): { version: string; releaseUrl: string } | null;
+}
+
+export interface UpdateNoticeReplayTarget extends SendableWebContents {
+ on(event: 'did-finish-load', listener: () => void): unknown;
+ once(event: 'destroyed', listener: () => void): unknown;
+ removeListener(event: 'did-finish-load', listener: () => void): unknown;
+}
+
+export interface LoadStateWebContents extends SendableWebContents {
+ isLoading(): boolean;
+ getURL(): string;
+}
+
+function deliverUpdateNotices(
+ webContents: SendableWebContents,
+ source: UpdateNoticeSource | null,
+): void {
+ if (source === null || webContents.isDestroyed?.() === true) return;
+ const pending = source.getPendingUpdate();
+ if (pending) sendToRenderer(webContents, 'ok:update:downloaded', pending);
+ const whatsNew = source.getActiveWhatsNew();
+ if (whatsNew) sendToRenderer(webContents, 'ok:update:whats-new', whatsNew);
+}
+
+const replaying = new WeakSet<UpdateNoticeReplayTarget>();
+
+export function replayUpdateNoticesOnEveryLoad(
+ webContents: UpdateNoticeReplayTarget,
+ getSource: () => UpdateNoticeSource | null,
+): void {
+ if (replaying.has(webContents)) return;
+ replaying.add(webContents);
+ const onLoad = (): void => {
+ deliverUpdateNotices(webContents, getSource());
+ };
+ webContents.on('did-finish-load', onLoad);
+ webContents.once('destroyed', () => {
+ webContents.removeListener('did-finish-load', onLoad);
+ });
+}
+
+export function deliverUpdateNoticesToLoadedWindows(
+ webContentsList: readonly LoadStateWebContents[],
+ source: UpdateNoticeSource | null,
+): void {
+ for (const webContents of webContentsList) {
+ if (webContents.isDestroyed?.() === true) continue;
+ if (webContents.isLoading() || webContents.getURL() === '') continue;
+ deliverUpdateNotices(webContents, source);
+ }
+}
diff --git a/packages/desktop/src/shared/ipc-events.ts b/packages/desktop/src/shared/ipc-events.ts
index 24aa616ca..3d6ce4216 100644
--- a/packages/desktop/src/shared/ipc-events.ts
+++ b/packages/desktop/src/shared/ipc-events.ts
@@ -16,6 +16,7 @@ import type {
OkServerRestartedInfo,
OkServerVersionDriftInfo,
OkShareReceivedPayload,
+ OkUpdateRelaunchFailedInfo,
} from './bridge-contract.ts';
import type {
McpWiringEditorDetection,
@@ -33,14 +34,7 @@ export interface EventChannels {
'ok:update:downloaded': { payload: { version: string } };
'ok:update:relaunching': { payload: { version: string } };
'ok:update:fetching-latest': { payload: { version: string } };
- 'ok:update:relaunch-failed': {
- payload: {
- version: string;
- message?: string;
- downloadUrl?: string;
- dismissPending?: boolean;
- };
- };
+ 'ok:update:relaunch-failed': { payload: OkUpdateRelaunchFailedInfo };
'ok:update:whats-new': { payload: { version: string; releaseUrl: string } };
'ok:update:whats-new-dismissed': { payload: { version: string } };
'ok:update:stuck-hint': { payload: { downloadUrl: string } };
diff --git a/packages/desktop/tests/integration/auto-updater.test.ts b/packages/desktop/tests/integration/auto-updater.test.ts
index c987403c6..957b432c2 100644
--- a/packages/desktop/tests/integration/auto-updater.test.ts
+++ b/packages/desktop/tests/integration/auto-updater.test.ts
@@ -38,6 +38,10 @@ import {
evaluateSchemaCompatibility,
MAX_SUPPORTED_SCHEMA_VERSION,
} from '../../src/main/state-store.ts';
+import {
+ replayUpdateNoticesOnEveryLoad,
+ type UpdateNoticeReplayTarget,
+} from '../../src/main/update-notice-replay.ts';
import type { SendableWebContents } from '../../src/shared/ipc-send.ts';
interface SendTarget {
@@ -5494,6 +5498,7 @@ describe('single-flight install handoff', () => {
kind: 'ready-to-install',
currentVersion: '0.3.1',
stagedVersion: '0.3.2',
+ relaunch: 'available',
});
});
@@ -5515,6 +5520,7 @@ describe('single-flight install handoff', () => {
kind: 'ready-to-install',
currentVersion: '0.3.1',
stagedVersion: '0.3.2',
+ relaunch: 'available',
});
});
@@ -5539,6 +5545,7 @@ describe('single-flight install handoff', () => {
kind: 'ready-to-install',
currentVersion: '0.3.1',
stagedVersion: '0.3.2',
+ relaunch: 'available',
});
},
);
@@ -5752,7 +5759,11 @@ describe('click-gated freshness check', () => {
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 });
+ expect(failed[0]?.payload).toEqual({
+ version: '0.3.2',
+ reason: 'no-longer-pending',
+ dismissPending: true,
+ });
expect(win.filter((c) => c.channel === 'ok:update:downloaded')).toHaveLength(0);
}
});
@@ -5858,29 +5869,50 @@ describe('the commit flag releases on every path that re-offers the click', () =
describe('post-update quiet window', () => {
test('a banner arriving right after an update is held, not dropped', () => {
const { rig, handle } = makeRig({ lastSeenVersion: '0.3.0', appVersion: '0.3.1' });
- expect(handle.isWithinPostUpdateQuietWindow()).toBe(true);
rig.updater.emit('update-downloaded', { version: '0.3.2' });
expect(rig.captured.filter((c) => c.channel === 'ok:update:downloaded')).toHaveLength(0);
expect(rig.dispatches).toContain('toast-a-deferred-post-update-quiet' as DispatchKind);
expect(rig.state.versionPendingInstall).toBe('0.3.2');
+ expect(handle.getPendingUpdate()).toBeNull();
fireTimerFor(rig.clock, POST_UPDATE_QUIET_MS);
expect(rig.captured.filter((c) => c.channel === 'ok:update:downloaded')).toHaveLength(1);
expect(rig.dispatches).toContain('toast-a-quiet-window-elapsed' as DispatchKind);
- expect(handle.isWithinPostUpdateQuietWindow()).toBe(false);
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
});
test('a fresh install does not arm it', () => {
- const { handle } = makeRig({ lastSeenVersion: null, appVersion: '0.3.1' });
- expect(handle.isWithinPostUpdateQuietWindow()).toBe(false);
+ const { handle } = makeRig({
+ lastSeenVersion: null,
+ appVersion: '0.3.1',
+ versionPendingInstall: '0.3.2',
+ });
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
});
test('a plain relaunch on the same version does not arm it', () => {
- const { handle } = makeRig({ lastSeenVersion: '0.3.1', appVersion: '0.3.1' });
- expect(handle.isWithinPostUpdateQuietWindow()).toBe(false);
+ const { handle } = makeRig({
+ lastSeenVersion: '0.3.1',
+ appVersion: '0.3.1',
+ versionPendingInstall: '0.3.2',
+ });
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
+ });
+
+ test('a build staged by an earlier session is held while the window runs', () => {
+ const { rig, handle } = makeRig({
+ lastSeenVersion: '0.3.0',
+ appVersion: '0.3.1',
+ versionPendingInstall: '0.3.2',
+ });
+ expect(handle.getPendingUpdate()).toBeNull();
+
+ rig.now = new Date(rig.now.getTime() + POST_UPDATE_QUIET_MS);
+
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
});
test('linux does not arm it — the banner there is the only install route', () => {
@@ -5889,21 +5921,561 @@ describe('post-update quiet window', () => {
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);
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
});
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);
rig.updater.emit('update-downloaded', { version: '0.3.2' });
expect(rig.captured.filter((c) => c.channel === 'ok:update:downloaded')).toHaveLength(1);
expect(rig.dispatches).toContain('update-downloaded-toast-a' as DispatchKind);
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
+ });
+});
+
+function downloadedBroadcasts(sends: CapturedSend[]): unknown[] {
+ return sends.filter((c) => c.channel === 'ok:update:downloaded').map((c) => c.payload);
+}
+
+async function settleAsyncWork(): Promise<void> {
+ await new Promise((resolve) => setTimeout(resolve, 0));
+}
+
+describe('Update Ready dialog offers Quit and Restart', () => {
+ test('choosing Quit and Restart installs through the same path as the in-app Relaunch', async () => {
+ const showCheckNowResult = vi.fn(() => Promise.resolve('relaunch' as const));
+ const prepareForRelaunch = vi.fn(() => {});
+ const { rig } = makeRig({
+ versionPendingInstall: null,
+ showCheckNowResult,
+ prepareForRelaunch,
+ extraWindowCount: 1,
+ });
+ stageInSession(rig, '0.3.2');
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.2' });
+ await settleAsyncWork();
+
+ expect(showCheckNowResult).toHaveBeenCalledWith({
+ kind: 'ready-to-install',
+ currentVersion: '0.3.1',
+ stagedVersion: '0.3.2',
+ relaunch: 'available',
+ });
+ expect(rig.logger.info).toHaveBeenCalledWith('check-now result dialog answered', {
+ kind: 'ready-to-install',
+ choice: 'relaunch',
+ });
+ expect(rig.dispatches).toContain('check-now-relaunch-chosen' as DispatchKind);
+ expect(prepareForRelaunch).toHaveBeenCalledTimes(1);
+ expect(rig.updater.quitAndInstall).toHaveBeenCalledTimes(1);
+ expect(rig.state.versionPendingInstall).toBeNull();
+ expect(rig.state.attemptedInstall).toBe('0.3.2');
+ for (const win of rig.windows) {
+ expect(win.filter((c) => c.channel === 'ok:update:relaunching')).toHaveLength(1);
+ }
+ expect(rig.dispatches).toContain('relaunch-now' as DispatchKind);
+ expect(rig.logger.error).not.toHaveBeenCalled();
+ });
+
+ test('choosing Later logs the answer and leaves the staged build alone', async () => {
+ const showCheckNowResult = vi.fn(() => Promise.resolve('dismiss' as const));
+ const { rig } = makeRig({ versionPendingInstall: null, showCheckNowResult });
+ stageInSession(rig, '0.3.2');
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.2' });
+ await settleAsyncWork();
+
+ expect(showCheckNowResult).toHaveBeenCalledTimes(1);
+ expect(rig.logger.info).toHaveBeenCalledWith('check-now result dialog answered', {
+ kind: 'ready-to-install',
+ choice: 'dismiss',
+ });
+ expect(rig.updater.quitAndInstall).not.toHaveBeenCalled();
+ expect(rig.captured.filter((c) => c.channel === 'ok:update:relaunching')).toHaveLength(0);
+ expect(rig.dispatches).not.toContain('check-now-relaunch-chosen' as DispatchKind);
+ expect(rig.state.versionPendingInstall).toBe('0.3.2');
+ expect(rig.logger.error).not.toHaveBeenCalled();
+ });
+
+ test('a relaunch answer to any other verdict is ignored, even with a build staged', async () => {
+ const showCheckNowResult = vi.fn(() => Promise.resolve('relaunch' as const));
+ const { rig } = makeRig({ versionPendingInstall: null, showCheckNowResult });
+ stageInSession(rig, '0.3.2');
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-not-available', { version: '0.3.1' });
+ await settleAsyncWork();
+
+ expect(showCheckNowResult).toHaveBeenCalledWith({
+ kind: 'not-available',
+ currentVersion: '0.3.1',
+ });
+ expect(rig.state.versionPendingInstall).toBe('0.3.2');
+ expect(rig.dispatches).not.toContain('check-now-relaunch-chosen' as DispatchKind);
+ expect(rig.updater.quitAndInstall).not.toHaveBeenCalled();
+ });
+
+ test('a dialog that rejects logs the dialog failure and installs nothing', async () => {
+ const dialogError = new Error('dialog torn down');
+ const showCheckNowResult = vi.fn(() => Promise.reject(dialogError));
+ const { rig } = makeRig({ versionPendingInstall: null, showCheckNowResult });
+ stageInSession(rig, '0.3.2');
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.2' });
+ await settleAsyncWork();
+
+ expect(rig.updater.quitAndInstall).not.toHaveBeenCalled();
+ expect(rig.logger.error).toHaveBeenCalledTimes(1);
+ expect(rig.logger.error).toHaveBeenCalledWith('check-now result dialog failed', {
+ err: dialogError,
+ kind: 'ready-to-install',
+ });
+ expect(rig.logger.info).not.toHaveBeenCalledWith(
+ 'check-now result dialog answered',
+ expect.anything(),
+ );
+ });
+
+ test('a failed Quit and Restart logs the relaunch failure and re-arms the card', async () => {
+ const showCheckNowResult = vi.fn(() => Promise.resolve('relaunch' as const));
+ const { rig } = makeRig({ versionPendingInstall: null, showCheckNowResult });
+ stageInSession(rig, '0.3.2');
+ const handoffError = new Error('squirrel refused the handoff');
+ rig.updater.quitAndInstall = vi.fn(() => {
+ throw handoffError;
+ });
+ rig.captured.length = 0;
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.2' });
+ await settleAsyncWork();
+
+ expect(rig.state.versionPendingInstall).toBe('0.3.2');
+ expect(rig.dispatches).toContain('relaunch-failed-rearm' as DispatchKind);
+ expect(rig.captured.filter((c) => c.channel === 'ok:update:relaunch-failed')).toHaveLength(1);
+ expect(rig.logger.info).toHaveBeenCalledWith('check-now result dialog answered', {
+ kind: 'ready-to-install',
+ choice: 'relaunch',
+ });
+ expect(rig.logger.error).toHaveBeenCalledTimes(1);
+ expect(rig.logger.error).toHaveBeenCalledWith(
+ 'check-now Update Ready dialog Quit and Restart failed',
+ { err: handoffError, stagedVersion: '0.3.2' },
+ );
+ });
+});
+
+describe('a manual check that finds the staged build re-offers the card', () => {
+ test('re-broadcasts ok:update:downloaded to every window', () => {
+ const { rig } = makeRig({ versionPendingInstall: null, extraWindowCount: 1 });
+ stageInSession(rig, '0.3.2');
+ for (const win of rig.windows) win.length = 0;
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.2' });
+
+ for (const win of rig.windows) {
+ expect(downloadedBroadcasts(win)).toEqual([{ version: '0.3.2' }]);
+ }
+ expect(rig.dispatches).toContain('check-now-ready-reoffered' as DispatchKind);
+ });
+
+ test('names the staged build when a newer offer was declined', () => {
+ const { rig } = makeRig({ versionPendingInstall: null });
+ stageInSession(rig, '0.3.2');
+ rig.captured.length = 0;
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.3' });
+
+ expect(downloadedBroadcasts(rig.captured)).toEqual([{ version: '0.3.2' }]);
+ });
+
+ test('does not re-offer, or offer Quit and Restart, while the click-time freshness check runs', async () => {
+ const showCheckNowResult = vi.fn(() => Promise.resolve('relaunch' as const));
+ const { rig } = makeRig({ versionPendingInstall: null, showCheckNowResult });
+ await Promise.resolve();
+ stageInSession(rig, '0.3.2');
+ rig.updater.checkForUpdates.mockImplementation(() => new Promise(() => {}));
+ const relaunch = Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'));
+ rig.ipc.invoke('ok:update:check-now');
+ rig.captured.length = 0;
+
+ rig.updater.emit('update-available', { version: '0.3.2' });
+
+ expect(rig.state.versionPendingInstall).toBe('0.3.2');
+ expect(showCheckNowResult).toHaveBeenCalledWith({
+ kind: 'ready-to-install',
+ currentVersion: '0.3.1',
+ stagedVersion: '0.3.2',
+ relaunch: 'installing',
+ });
+ expect(rig.logger.info).toHaveBeenCalledWith(
+ 'check-now found the staged build but withholds Quit and Restart',
+ { stagedVersion: '0.3.2', reason: 'installing', pendingVersion: '0.3.2' },
+ );
+ expect(downloadedBroadcasts(rig.captured)).toEqual([]);
+ expect(rig.dispatches).not.toContain('check-now-ready-reoffered' as DispatchKind);
+
+ await relaunch;
+ await settleAsyncWork();
+ expect(rig.dispatches).not.toContain('check-now-relaunch-chosen' as DispatchKind);
+ expect(rig.dispatches).not.toContain('relaunch-double-invoke-blocked' as DispatchKind);
+ expect(rig.updater.quitAndInstall).toHaveBeenCalledTimes(1);
+ });
+
+ test('does not re-offer while the post-update quiet window holds the card', () => {
+ const showCheckNowResult = vi.fn(() => undefined);
+ const { rig } = makeRig({
+ lastSeenVersion: '0.3.0',
+ appVersion: '0.3.1',
+ versionPendingInstall: null,
+ showCheckNowResult,
+ });
+ stageInSession(rig, '0.3.2');
+ rig.captured.length = 0;
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.2' });
+
+ expect(showCheckNowResult).toHaveBeenCalledWith({
+ kind: 'ready-to-install',
+ currentVersion: '0.3.1',
+ stagedVersion: '0.3.2',
+ relaunch: 'available',
+ });
+ expect(downloadedBroadcasts(rig.captured)).toEqual([]);
+ expect(rig.dispatches).not.toContain('check-now-ready-reoffered' as DispatchKind);
+ });
+
+ test('withholds Quit and Restart once the pending install was dropped', async () => {
+ const showCheckNowResult = vi.fn(() => Promise.resolve('relaunch' as const));
+ const { rig } = makeRig({ versionPendingInstall: null, showCheckNowResult });
+ stageInSession(rig, '0.3.2');
+ rig.updater.quitAndInstall = vi.fn(() => {
+ rig.failNextPersist = true;
+ throw new Error('squirrel refused the handoff');
+ });
+ await expect(Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'))).rejects.toThrow(
+ 'squirrel refused the handoff',
+ );
+ rig.failNextPersist = false;
+ rig.updater.quitAndInstall = vi.fn();
+ rig.captured.length = 0;
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.3' });
+ await settleAsyncWork();
+
+ expect(showCheckNowResult).toHaveBeenCalledWith({
+ kind: 'ready-to-install',
+ currentVersion: '0.3.1',
+ stagedVersion: '0.3.2',
+ relaunch: 'not-pending',
+ });
+ expect(rig.logger.info).toHaveBeenCalledWith(
+ 'check-now found the staged build but withholds Quit and Restart',
+ { stagedVersion: '0.3.2', reason: 'not-pending', pendingVersion: null },
+ );
+ expect(downloadedBroadcasts(rig.captured)).toEqual([]);
+ expect(rig.dispatches).not.toContain('check-now-ready-reoffered' as DispatchKind);
+ expect(rig.dispatches).not.toContain('check-now-relaunch-chosen' as DispatchKind);
+ expect(rig.updater.quitAndInstall).not.toHaveBeenCalled();
+ });
+
+ test('Quit and Restart after the pending install was dropped behind the open dialog tells the user', async () => {
+ let answer: (choice: 'relaunch' | 'dismiss') => void = () => {};
+ const showCheckNowResult = vi.fn(
+ () =>
+ new Promise<'relaunch' | 'dismiss'>((resolve) => {
+ answer = resolve;
+ }),
+ );
+ const { rig } = makeRig({
+ versionPendingInstall: null,
+ showCheckNowResult,
+ extraWindowCount: 1,
+ });
+ stageInSession(rig, '0.3.2');
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.2' });
+ expect(showCheckNowResult).toHaveBeenCalledWith(
+ expect.objectContaining({ kind: 'ready-to-install', relaunch: 'available' }),
+ );
+ rig.updater.quitAndInstall = vi.fn(() => {
+ rig.failNextPersist = true;
+ throw new Error('squirrel refused the handoff');
+ });
+ await expect(Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'))).rejects.toThrow(
+ 'squirrel refused the handoff',
+ );
+ rig.failNextPersist = false;
+ expect(rig.state.versionPendingInstall).toBeNull();
+ rig.updater.quitAndInstall = vi.fn();
+ for (const win of rig.windows) win.length = 0;
+
+ answer('relaunch');
+ await settleAsyncWork();
+
+ expect(rig.dispatches).toContain('check-now-relaunch-chosen' as DispatchKind);
+ expect(rig.updater.quitAndInstall).not.toHaveBeenCalled();
+ for (const win of rig.windows) {
+ expect(win.filter((c) => c.channel === 'ok:update:relaunch-failed')).toEqual([
+ {
+ channel: 'ok:update:relaunch-failed',
+ payload: {
+ version: '0.3.2',
+ reason: 'no-longer-pending',
+ dismissPending: true,
+ },
+ },
+ ]);
+ }
+ expect(rig.logger.warn).toHaveBeenCalledWith(
+ 'relaunch-now invoked without versionPendingInstall — ignoring',
+ { requestedVersion: '0.3.2' },
+ );
+ });
+
+ test('an in-app Relaunch with no pending install tells the user instead of doing nothing', async () => {
+ const { rig } = makeRig({ versionPendingInstall: null });
+
+ await rig.ipc.invoke('ok:update:relaunch-now');
+
+ expect(rig.updater.quitAndInstall).not.toHaveBeenCalled();
+ expect(rig.captured.filter((c) => c.channel === 'ok:update:relaunch-failed')).toEqual([
+ {
+ channel: 'ok:update:relaunch-failed',
+ payload: {
+ version: '',
+ reason: 'no-longer-pending',
+ dismissPending: true,
+ },
+ },
+ ]);
+ });
+
+ test('an ordinary available verdict does not broadcast the card', () => {
+ const { rig } = makeRig({ versionPendingInstall: null });
+ rig.captured.length = 0;
+
+ rig.ipc.invoke('ok:update:check-now');
+ rig.updater.emit('update-available', { version: '0.3.2' });
+
+ expect(downloadedBroadcasts(rig.captured)).toEqual([]);
+ });
+});
+
+describe('getPendingUpdate decides whether the ready card is on offer', () => {
+ test('is null before anything downloads', () => {
+ const { handle } = makeRig({ versionPendingInstall: null });
+ expect(handle.getPendingUpdate()).toBeNull();
+ });
+
+ test('offers a build staged by an earlier session that this session never broadcast', () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: '0.3.2' });
+ expect(downloadedBroadcasts(rig.captured)).toEqual([]);
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
+ });
+
+ test('offers a fresh download', () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: null });
+ stageInSession(rig, '0.3.2');
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
+ });
+
+ test('keeps offering a build whose re-download was deduped', () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: '0.3.2' });
+ rig.updater.emit('update-downloaded', { version: '0.3.2' });
+ expect(rig.dispatches).toContain('update-downloaded-deduped' as DispatchKind);
+ expect(downloadedBroadcasts(rig.captured)).toEqual([]);
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
+ });
+
+ test('offers the boot re-offer of a handoff that never committed', () => {
+ const { rig, handle } = makeRig({
+ versionPendingInstall: null,
+ attemptedInstall: '0.3.2',
+ versionPendingInstallStagedAt: COMMITTED_LONG_AGO,
+ });
+ expect(rig.dispatches).toContain('install-never-committed-reoffered' as DispatchKind);
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
+ });
+
+ test('is null once the running build has caught up with the persisted one', () => {
+ const { handle } = makeRig({ versionPendingInstall: '0.3.1', appVersion: '0.3.1' });
+ expect(handle.getPendingUpdate()).toBeNull();
+ });
+
+ test('is null once the relaunch commits', async () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: null });
+ stageInSession(rig, '0.3.2');
+ await rig.ipc.invoke('ok:update:relaunch-now');
+ expect(rig.updater.quitAndInstall).toHaveBeenCalledTimes(1);
+ expect(handle.getPendingUpdate()).toBeNull();
+ });
+
+ test('is null while the click-time freshness check runs, with the build still persisted', async () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: null });
+ await Promise.resolve();
+ stageInSession(rig, '0.3.2');
+ rig.updater.checkForUpdates.mockImplementation(() => new Promise(() => {}));
+ const relaunch = Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'));
+
+ expect(rig.state.versionPendingInstall).toBe('0.3.2');
+ expect(handle.getPendingUpdate()).toBeNull();
+ expect(rig.updater.quitAndInstall).not.toHaveBeenCalled();
+
+ fireTimerFor(rig.clock, RELAUNCH_REFRESH_CHECK_MS);
+ await relaunch;
+ expect(rig.updater.quitAndInstall).toHaveBeenCalledTimes(1);
+ });
+
+ test('offers the build again after a relaunch failure re-arms the card', async () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: null });
+ stageInSession(rig, '0.3.2');
+ rig.updater.quitAndInstall = vi.fn(() => {
+ throw new Error('squirrel refused the handoff');
+ });
+ await expect(Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'))).rejects.toThrow(
+ 'squirrel refused the handoff',
+ );
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.2' });
+ });
+
+ test('is null after a relaunch failure that drops the pending install', async () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: null });
+ stageInSession(rig, '0.3.2');
+ rig.updater.quitAndInstall = vi.fn(() => {
+ rig.failNextPersist = true;
+ throw new Error('squirrel refused the handoff');
+ });
+ await expect(Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'))).rejects.toThrow(
+ 'squirrel refused the handoff',
+ );
+ rig.failNextPersist = false;
+ expect(
+ rig.captured.some(
+ (c) =>
+ c.channel === 'ok:update:relaunch-failed' &&
+ (c.payload as { dismissPending?: boolean }).dismissPending === true,
+ ),
+ ).toBe(true);
+ expect(handle.getPendingUpdate()).toBeNull();
+ });
+
+ test('is null after the staged build vanishes during the freshness check', async () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: null });
+ await Promise.resolve();
+ stageInSession(rig, '0.3.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();
+ expect(handle.getPendingUpdate()).toBeNull();
+ });
+
+ test('tracks the newest build when a newer one replaces the staged one', () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: null, platform: 'win32' });
+ stageInSession(rig, '0.3.2');
+ stageInSession(rig, '0.3.3');
+ expect(handle.getPendingUpdate()).toEqual({ version: '0.3.3' });
+ });
+});
+
+function makeReloadableWebContents(): {
+ webContents: UpdateNoticeReplayTarget;
+ sent: CapturedSend[];
+ reload: () => void;
+} {
+ const emitter = new EventEmitter();
+ const sent: CapturedSend[] = [];
+ return {
+ sent,
+ webContents: {
+ send: (channel: string, ...args: unknown[]) => {
+ sent.push({ channel, payload: args[0] });
+ },
+ on: (event, listener) => emitter.on(event, listener),
+ once: (event, listener) => emitter.once(event, listener),
+ removeListener: (event, listener) => emitter.removeListener(event, listener),
+ },
+ reload: () => {
+ sent.length = 0;
+ emitter.emit('did-finish-load');
+ },
+ };
+}
+
+describe('a reloaded window gets the ready card back on every offer route', () => {
+ const routes: Array<[string, () => ReturnType<typeof startAutoUpdater>]> = [
+ [
+ 'a fresh download this session',
+ () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: null });
+ stageInSession(rig, '0.3.2');
+ return handle;
+ },
+ ],
+ [
+ 'the boot re-offer of a handoff that never committed',
+ () => {
+ const { rig, handle } = makeRig({
+ versionPendingInstall: null,
+ attemptedInstall: '0.3.2',
+ versionPendingInstallStagedAt: COMMITTED_LONG_AGO,
+ });
+ expect(rig.dispatches).toContain('install-never-committed-reoffered' as DispatchKind);
+ return handle;
+ },
+ ],
+ [
+ 'a build staged by an earlier session and never broadcast this session',
+ () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: '0.3.2' });
+ expect(downloadedBroadcasts(rig.captured)).toEqual([]);
+ return handle;
+ },
+ ],
+ ];
+
+ test.each(routes)('%s', (_route, boot) => {
+ const handle = boot();
+ const win = makeReloadableWebContents();
+ replayUpdateNoticesOnEveryLoad(win.webContents, () => handle);
+
+ for (let load = 0; load < 3; load++) {
+ win.reload();
+ expect(downloadedBroadcasts(win.sent)).toEqual([{ version: '0.3.2' }]);
+ }
+ });
+
+ test('a reload after the install commits brings no card back', async () => {
+ const { rig, handle } = makeRig({ versionPendingInstall: null });
+ stageInSession(rig, '0.3.2');
+ const win = makeReloadableWebContents();
+ replayUpdateNoticesOnEveryLoad(win.webContents, () => handle);
+ win.reload();
+ expect(downloadedBroadcasts(win.sent)).toEqual([{ version: '0.3.2' }]);
+
+ await rig.ipc.invoke('ok:update:relaunch-now');
+ win.reload();
+
+ expect(downloadedBroadcasts(win.sent)).toEqual([]);
});
});