Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): propagate update relaunch notice to all windows (#1764)

Andrew Mikofalvyc94457a8ffe4
diff --git a/.changeset/relaunch-notice-all-windows.md b/.changeset/relaunch-notice-all-windows.md
new file mode 100644
index 000000000..76a3673a6
--- /dev/null
+++ b/.changeset/relaunch-notice-all-windows.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Fix the update "Relaunch" notice so it propagates to every open window. Previously, clicking "Relaunch" on the "Version X ready to install" banner swapped only that one window to "Relaunching to install the update…"; any other open windows kept showing the stale, still-clickable "ready to install" banner for the several seconds it takes to tear down each project's server before the app quits and reinstalls. Now the relaunch fans out to all windows the instant it commits in the main process, so every window swaps to the in-progress "Relaunching…" card in lockstep and the Relaunch button can't be fired a second time from another window.
diff --git a/packages/app/src/components/UpdateNotices.shared.ts b/packages/app/src/components/UpdateNotices.shared.ts
index f103694b8..b243f44eb 100644
--- a/packages/app/src/components/UpdateNotices.shared.ts
+++ b/packages/app/src/components/UpdateNotices.shared.ts
@@ -61,9 +61,11 @@ export function attachUpdateSubscribers(
const unsubscribers: Array<() => void> = [];
const autoDismissTimers = new Set<ReturnType<typeof setTimeout>>();
+ const downloadedNoticeId = 'update-downloaded';
+
unsubscribers.push(
bridge.onUpdateDownloaded(({ version }) => {
- const noticeId = 'update-downloaded';
+ const noticeId = downloadedNoticeId;
const armReadyNotice = () => {
addNotice({
@@ -102,6 +104,17 @@ export function attachUpdateSubscribers(
}),
);
+ unsubscribers.push(
+ bridge.onUpdateRelaunching(() => {
+ addNotice({
+ id: downloadedNoticeId,
+ body: TOAST_A_PROGRESS_BODY,
+ priority: PRIORITY_UPDATE_DOWNLOADED,
+ dismissible: false,
+ });
+ }),
+ );
+
unsubscribers.push(
bridge.onWhatsNew(({ version, releaseUrl }) => {
const noticeId = `whats-new-${version}`;
diff --git a/packages/app/src/components/UpdateNotices.test.ts b/packages/app/src/components/UpdateNotices.test.ts
index 3caec62ea..7e7c6ec8a 100644
--- a/packages/app/src/components/UpdateNotices.test.ts
+++ b/packages/app/src/components/UpdateNotices.test.ts
@@ -21,12 +21,14 @@ import {
} from './UpdateNotices';
type UpdateDownloadedCb = (info: { version: string }) => void;
+type RelaunchingCb = (info: { version: string }) => void;
type WhatsNewCb = (info: { version: string; releaseUrl: string }) => void;
type WhatsNewDismissedCb = (info: { version: string }) => void;
type StuckHintCb = (info: { downloadUrl: string }) => void;
interface FakeBridge {
onUpdateDownloaded: ReturnType<typeof mock>;
+ onUpdateRelaunching: ReturnType<typeof mock>;
onWhatsNew: ReturnType<typeof mock>;
onWhatsNewDismissed: ReturnType<typeof mock>;
onUpdateStuckHint: ReturnType<typeof mock>;
@@ -40,10 +42,12 @@ interface FakeBridge {
};
shell: { openExternal: ReturnType<typeof mock> };
_downloaded?: UpdateDownloadedCb;
+ _relaunching?: RelaunchingCb;
_whatsNew?: WhatsNewCb;
_whatsNewDismissed?: WhatsNewDismissedCb;
_stuckHint?: StuckHintCb;
_downloadedUnsub: ReturnType<typeof mock>;
+ _relaunchingUnsub: ReturnType<typeof mock>;
_whatsNewUnsub: ReturnType<typeof mock>;
_whatsNewDismissedUnsub: ReturnType<typeof mock>;
_stuckHintUnsub: ReturnType<typeof mock>;
@@ -52,10 +56,12 @@ interface FakeBridge {
function makeFakeBridge(): FakeBridge {
const b: FakeBridge = {
_downloadedUnsub: mock(() => {}),
+ _relaunchingUnsub: mock(() => {}),
_whatsNewUnsub: mock(() => {}),
_whatsNewDismissedUnsub: mock(() => {}),
_stuckHintUnsub: mock(() => {}),
onUpdateDownloaded: mock(() => {}),
+ onUpdateRelaunching: mock(() => {}),
onWhatsNew: mock(() => {}),
onWhatsNewDismissed: mock(() => {}),
onUpdateStuckHint: mock(() => {}),
@@ -73,6 +79,10 @@ function makeFakeBridge(): FakeBridge {
b._downloaded = cb;
return b._downloadedUnsub;
});
+ b.onUpdateRelaunching = mock((cb: RelaunchingCb) => {
+ b._relaunching = cb;
+ return b._relaunchingUnsub;
+ });
b.onWhatsNew = mock((cb: WhatsNewCb) => {
b._whatsNew = cb;
return b._whatsNewUnsub;
@@ -155,28 +165,68 @@ describe('appendErrorDetail', () => {
});
describe('attachUpdateSubscribers — registration', () => {
- test('subscribes to all four update channels on the bridge', () => {
+ test('subscribes to all five update channels on the bridge', () => {
const bridge = makeFakeBridge();
const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
attachUpdateSubscribers(castBridge(bridge), addNotice);
expect(bridge.onUpdateDownloaded).toHaveBeenCalledTimes(1);
+ expect(bridge.onUpdateRelaunching).toHaveBeenCalledTimes(1);
expect(bridge.onWhatsNew).toHaveBeenCalledTimes(1);
expect(bridge.onWhatsNewDismissed).toHaveBeenCalledTimes(1);
expect(bridge.onUpdateStuckHint).toHaveBeenCalledTimes(1);
});
- test('returns a single unsubscribe closure that detaches ALL four listeners', () => {
+ test('returns a single unsubscribe closure that detaches ALL five listeners', () => {
const bridge = makeFakeBridge();
const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
const unsubscribe = attachUpdateSubscribers(castBridge(bridge), addNotice);
unsubscribe();
expect(bridge._downloadedUnsub).toHaveBeenCalledTimes(1);
+ expect(bridge._relaunchingUnsub).toHaveBeenCalledTimes(1);
expect(bridge._whatsNewUnsub).toHaveBeenCalledTimes(1);
expect(bridge._whatsNewDismissedUnsub).toHaveBeenCalledTimes(1);
expect(bridge._stuckHintUnsub).toHaveBeenCalledTimes(1);
});
});
+describe('Notice A cross-window relaunch — ok:update:relaunching', () => {
+ test('swaps the update-downloaded card to the button-less in-progress card', () => {
+ const bridge = makeFakeBridge();
+ const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice);
+
+ bridge._relaunching?.({ version: '0.1.1' });
+ expect(addNotice).toHaveBeenCalledTimes(1);
+ const inProgress = addNotice.mock.calls[0]?.[0] as UpdateNotice;
+ expect(inProgress.id).toBe('update-downloaded');
+ expect(inProgress.body).toBe(TOAST_A_PROGRESS_BODY);
+ expect(inProgress.action).toBeUndefined();
+ expect(inProgress.priority).toBe(2);
+ expect(inProgress.dismissible).toBe(false);
+ });
+
+ test('does NOT invoke relaunchNow — it is the echo, not the trigger (no loop)', () => {
+ const bridge = makeFakeBridge();
+ const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice);
+ bridge._relaunching?.({ version: '0.1.1' });
+ expect(bridge.update.relaunchNow).not.toHaveBeenCalled();
+ });
+
+ test('a downloaded re-broadcast after a failed relaunch replaces the stuck in-progress card in place', () => {
+ const bridge = makeFakeBridge();
+ const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice);
+ bridge._relaunching?.({ version: '0.1.1' });
+ bridge._downloaded?.({ version: '0.1.1' });
+ const reArmed = addNotice.mock.calls.at(-1)?.[0] as UpdateNotice;
+ expect(reArmed.id).toBe('update-downloaded');
+ expect(reArmed.body).toBe(toastABody('0.1.1'));
+ expect(reArmed.action?.label).toBe(TOAST_A_ACTION);
+ expect(reArmed.dismissible).toBeUndefined();
+ });
+});
+
describe('Notice A — ok:update:downloaded', () => {
test('emits notice with canonical copy + relaunch action on dispatch', () => {
const bridge = makeFakeBridge();
@@ -565,12 +615,13 @@ describe('pickActiveNotice', () => {
});
describe('unsubscribe semantics', () => {
- test('after unsubscribe, all four per-channel unsub closures fire', () => {
+ test('after unsubscribe, all five per-channel unsub closures fire', () => {
const bridge = makeFakeBridge();
const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
const unsubscribe = attachUpdateSubscribers(castBridge(bridge), addNotice);
unsubscribe();
expect(bridge._downloadedUnsub).toHaveBeenCalledTimes(1);
+ expect(bridge._relaunchingUnsub).toHaveBeenCalledTimes(1);
expect(bridge._whatsNewUnsub).toHaveBeenCalledTimes(1);
expect(bridge._whatsNewDismissedUnsub).toHaveBeenCalledTimes(1);
expect(bridge._stuckHintUnsub).toHaveBeenCalledTimes(1);
diff --git a/packages/app/src/lib/desktop-bridge-types.ts b/packages/app/src/lib/desktop-bridge-types.ts
index e7f6148ed..8b00db139 100644
--- a/packages/app/src/lib/desktop-bridge-types.ts
+++ b/packages/app/src/lib/desktop-bridge-types.ts
@@ -183,6 +183,10 @@ interface OkUpdateDownloadedInfo {
readonly version: string;
}
+interface OkUpdateRelaunchingInfo {
+ readonly version: string;
+}
+
interface OkWhatsNewInfo {
readonly version: string;
readonly releaseUrl: string;
@@ -422,6 +426,7 @@ export interface OkDesktopBridge {
onProjectSwitched(cb: (next: OkDesktopConfig) => void): OkUnsubscribe;
onMenuAction(cb: (action: OkMenuAction) => void): OkUnsubscribe;
onUpdateDownloaded(cb: (info: OkUpdateDownloadedInfo) => void): OkUnsubscribe;
+ onUpdateRelaunching(cb: (info: OkUpdateRelaunchingInfo) => void): OkUnsubscribe;
onWhatsNew(cb: (info: OkWhatsNewInfo) => void): OkUnsubscribe;
onWhatsNewDismissed(cb: (info: { readonly version: string }) => void): OkUnsubscribe;
onUpdateStuckHint(cb: (info: OkUpdateStuckHintInfo) => void): OkUnsubscribe;
diff --git a/packages/app/tests/stress/file-tree-create.e2e.ts b/packages/app/tests/stress/file-tree-create.e2e.ts
index a6392ba4d..2d2bcb12a 100644
--- a/packages/app/tests/stress/file-tree-create.e2e.ts
+++ b/packages/app/tests/stress/file-tree-create.e2e.ts
@@ -181,6 +181,7 @@ async function installDelayedDesktopSessionBridge(
onProjectSwitched: () => unsubscribe,
onMenuAction: () => unsubscribe,
onUpdateDownloaded: () => unsubscribe,
+ onUpdateRelaunching: () => unsubscribe,
onWhatsNew: () => unsubscribe,
onWhatsNewDismissed: () => unsubscribe,
onUpdateStuckHint: () => unsubscribe,
diff --git a/packages/app/tests/stress/fixtures/handoff-mocks.ts b/packages/app/tests/stress/fixtures/handoff-mocks.ts
index 9e4de37b7..7b80e2426 100644
--- a/packages/app/tests/stress/fixtures/handoff-mocks.ts
+++ b/packages/app/tests/stress/fixtures/handoff-mocks.ts
@@ -216,6 +216,7 @@ export async function installHandoffMocks(page: Page, cfg: HandoffMockConfig): P
onProjectSwitched: () => () => {},
onMenuAction: () => () => {},
onUpdateDownloaded: () => () => {},
+ onUpdateRelaunching: () => () => {},
onWhatsNew: () => () => {},
onWhatsNewDismissed: () => () => {},
onUpdateStuckHint: () => () => {},
diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.ts
index 63e83025d..a6e9e04b8 100644
--- a/packages/core/src/desktop-bridge.ts
+++ b/packages/core/src/desktop-bridge.ts
@@ -81,6 +81,10 @@ interface OkUpdateDownloadedInfo {
readonly version: string;
}
+interface OkUpdateRelaunchingInfo {
+ readonly version: string;
+}
+
interface OkWhatsNewInfo {
readonly version: string;
readonly releaseUrl: string;
@@ -411,6 +415,7 @@ export interface OkDesktopBridge {
onProjectSwitched(cb: (next: OkDesktopConfig) => void): OkUnsubscribe;
onMenuAction(cb: (action: OkMenuAction) => void): OkUnsubscribe;
onUpdateDownloaded(cb: (info: OkUpdateDownloadedInfo) => void): OkUnsubscribe;
+ onUpdateRelaunching(cb: (info: OkUpdateRelaunchingInfo) => void): OkUnsubscribe;
onWhatsNew(cb: (info: OkWhatsNewInfo) => void): OkUnsubscribe;
onWhatsNewDismissed(cb: (info: { readonly version: string }) => void): OkUnsubscribe;
onUpdateStuckHint(cb: (info: OkUpdateStuckHintInfo) => void): OkUnsubscribe;
diff --git a/packages/desktop/src/main/auto-updater.ts b/packages/desktop/src/main/auto-updater.ts
index 51d0ff159..86cfbfd6d 100644
--- a/packages/desktop/src/main/auto-updater.ts
+++ b/packages/desktop/src/main/auto-updater.ts
@@ -45,6 +45,8 @@ export type DispatchKind =
| 'error-classified'
| 'error-unclassified'
| 'relaunch-now'
+ | 'relaunching-broadcast'
+ | 'relaunch-failed-rearm'
| 'skipped-dev-mode'
| 'stale-pending-cleared'
| 'cross-channel-blocked';
@@ -457,6 +459,8 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
const pending = snapshot.versionPendingInstall;
if (!persistSafely({ ...snapshot, versionPendingInstall: null }, 'relaunch-now'))
return undefined;
+ broadcastToAllWindows('ok:update:relaunching', { version: pending });
+ onDispatch?.('relaunching-broadcast');
if (opts.prepareForRelaunch) {
try {
await opts.prepareForRelaunch();
@@ -468,7 +472,21 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
}
logger.info('relaunch-now invoked — calling autoUpdater.quitAndInstall', { pending });
onDispatch?.('relaunch-now');
- updater.quitAndInstall();
+ try {
+ updater.quitAndInstall();
+ } catch (err) {
+ if (
+ persistSafely({ ...readState(), versionPendingInstall: pending }, 'relaunch-failed-restore')
+ ) {
+ broadcastToAllWindows('ok:update:downloaded', { version: pending });
+ }
+ logger.warn('quitAndInstall threw — restored pending install and re-armed windows', {
+ pending,
+ message: err instanceof Error ? err.message : String(err),
+ });
+ onDispatch?.('relaunch-failed-rearm');
+ throw err;
+ }
return undefined;
});
diff --git a/packages/desktop/src/preload/index.ts b/packages/desktop/src/preload/index.ts
index 20f3c63e4..b09c7a514 100644
--- a/packages/desktop/src/preload/index.ts
+++ b/packages/desktop/src/preload/index.ts
@@ -16,6 +16,7 @@ import type {
OkShareReceivedPayload,
OkThemeSource,
OkUpdateDownloadedInfo,
+ OkUpdateRelaunchingInfo,
OkUpdateStuckHintInfo,
OkWhatsNewInfo,
} from '../shared/bridge-contract.ts';
@@ -187,6 +188,13 @@ const bridge: OkDesktopBridge = {
return () => ipcRenderer.removeListener('ok:update:downloaded', listener);
},
+ onUpdateRelaunching(cb: (info: OkUpdateRelaunchingInfo) => void) {
+ const listener = (_event: IpcRendererEvent, info: OkUpdateRelaunchingInfo) => cb(info);
+ // biome-ignore lint/plugin/no-loosely-typed-webcontents-ipc: preload-side subscription wrapper (precedent #14)
+ ipcRenderer.on('ok:update:relaunching', listener);
+ return () => ipcRenderer.removeListener('ok:update:relaunching', listener);
+ },
+
onWhatsNew(cb: (info: OkWhatsNewInfo) => void) {
const listener = (_event: IpcRendererEvent, info: OkWhatsNewInfo) => cb(info);
// biome-ignore lint/plugin/no-loosely-typed-webcontents-ipc: preload-side subscription wrapper (precedent #14)
diff --git a/packages/desktop/src/shared/bridge-contract.ts b/packages/desktop/src/shared/bridge-contract.ts
index 0d3f9d1ec..57c8c2435 100644
--- a/packages/desktop/src/shared/bridge-contract.ts
+++ b/packages/desktop/src/shared/bridge-contract.ts
@@ -145,6 +145,10 @@ export interface OkUpdateDownloadedInfo {
readonly version: string;
}
+export interface OkUpdateRelaunchingInfo {
+ readonly version: string;
+}
+
export interface OkWhatsNewInfo {
readonly version: string;
readonly releaseUrl: string;
@@ -399,6 +403,7 @@ export interface OkDesktopBridge {
onProjectSwitched(cb: (next: OkDesktopConfig) => void): OkUnsubscribe;
onMenuAction(cb: (action: OkMenuAction) => void): OkUnsubscribe;
onUpdateDownloaded(cb: (info: OkUpdateDownloadedInfo) => void): OkUnsubscribe;
+ onUpdateRelaunching(cb: (info: OkUpdateRelaunchingInfo) => void): OkUnsubscribe;
onWhatsNew(cb: (info: OkWhatsNewInfo) => void): OkUnsubscribe;
onWhatsNewDismissed(cb: (info: { readonly version: string }) => void): OkUnsubscribe;
onUpdateStuckHint(cb: (info: OkUpdateStuckHintInfo) => void): OkUnsubscribe;
diff --git a/packages/desktop/src/shared/ipc-events.ts b/packages/desktop/src/shared/ipc-events.ts
index fa8825d0b..264cb830b 100644
--- a/packages/desktop/src/shared/ipc-events.ts
+++ b/packages/desktop/src/shared/ipc-events.ts
@@ -15,6 +15,7 @@ export interface EventChannels {
'ok:project:switched': { payload: OkDesktopConfig };
'ok:menu-action': { payload: OkMenuAction };
'ok:update:downloaded': { payload: { version: string } };
+ 'ok:update:relaunching': { payload: { version: string } };
'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 944f31abe..6ebf4c284 100644
--- a/packages/desktop/tests/integration/auto-updater.test.ts
+++ b/packages/desktop/tests/integration/auto-updater.test.ts
@@ -1044,6 +1044,83 @@ describe('ok:update:relaunch-now IPC handler (AC18)', () => {
expect(rig.logger.warn).toHaveBeenCalled();
});
+ test('broadcasts ok:update:relaunching to EVERY open window so all swap in lockstep', () => {
+ const { rig } = makeRig({ versionPendingInstall: '0.3.2', extraWindowCount: 2 });
+ expect(rig.windows).toHaveLength(3);
+ rig.ipc.invoke('ok:update:relaunch-now');
+ for (const win of rig.windows) {
+ const relaunching = win.filter((c) => c.channel === 'ok:update:relaunching');
+ expect(relaunching).toHaveLength(1);
+ expect(relaunching[0]?.payload).toEqual({ version: '0.3.2' });
+ }
+ expect(rig.dispatches.filter((d) => d === 'relaunching-broadcast')).toHaveLength(1);
+ });
+
+ test('quitAndInstall throw → state restored + every window re-armed via ok:update:downloaded + invoke rejects', async () => {
+ const { rig } = makeRig({ versionPendingInstall: '0.3.2', extraWindowCount: 2 });
+ rig.updater.quitAndInstall = mock(() => {
+ throw new Error('SQRLInstallerErrorDomain Code=-9');
+ });
+ await expect(Promise.resolve(rig.ipc.invoke('ok:update:relaunch-now'))).rejects.toThrow(
+ 'SQRLInstallerErrorDomain Code=-9',
+ );
+ expect(rig.state.versionPendingInstall).toBe('0.3.2');
+ for (const win of rig.windows) {
+ expect(win.filter((c) => c.channel === 'ok:update:relaunching')).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' });
+ }
+ expect(rig.dispatches).toContain('relaunch-failed-rearm' as DispatchKind);
+ rig.updater.quitAndInstall = mock(() => {});
+ await rig.ipc.invoke('ok:update:relaunch-now');
+ expect(rig.updater.quitAndInstall).toHaveBeenCalledTimes(1);
+ });
+
+ test('does NOT broadcast ok:update:relaunching when nothing is pending (gated)', () => {
+ const { rig } = makeRig({ versionPendingInstall: null, extraWindowCount: 2 });
+ rig.ipc.invoke('ok:update:relaunch-now');
+ for (const win of rig.windows) {
+ expect(win.filter((c) => c.channel === 'ok:update:relaunching')).toHaveLength(0);
+ }
+ expect(rig.dispatches).not.toContain('relaunching-broadcast' as DispatchKind);
+ });
+
+ test('broadcasts ok:update:relaunching BEFORE the prepareForRelaunch teardown runs', async () => {
+ const captured: CapturedSend[] = [];
+ const ipc = makeFakeIpc();
+ let state: AppState = { ...emptyState(), versionPendingInstall: '0.3.2' };
+ let relaunchingSeenAtTeardown = -1;
+ const win = makeFakeWindow(captured);
+ startAutoUpdater({
+ updater: new FakeUpdater(),
+ ipcMain: ipc,
+ readState: () => state,
+ writeState: (next) => {
+ state = next;
+ },
+ getPrimaryWindow: () => win,
+ getAllWindows: () => [win],
+ getAppVersion: () => '0.3.1',
+ isPackaged: true,
+ prepareForRelaunch: async () => {
+ relaunchingSeenAtTeardown = captured.filter(
+ (c) => c.channel === 'ok:update:relaunching',
+ ).length;
+ },
+ clock: makeFakeClock(),
+ now: () => new Date(),
+ logger: {
+ info: mock(() => {}),
+ warn: mock(() => {}),
+ error: mock(() => {}),
+ debug: mock(() => {}),
+ },
+ });
+ await ipc.invoke('ok:update:relaunch-now');
+ expect(relaunchingSeenAtTeardown).toBe(1);
+ });
+
test('destroy() removes the IPC handler', () => {
const { rig, handle } = makeRig();
handle.destroy();
diff --git a/packages/desktop/tests/preload/update-listeners.test.ts b/packages/desktop/tests/preload/update-listeners.test.ts
index 670c09a35..3c45a324a 100644
--- a/packages/desktop/tests/preload/update-listeners.test.ts
+++ b/packages/desktop/tests/preload/update-listeners.test.ts
@@ -76,6 +76,7 @@ describe('M3 update-listener subscribe/unsubscribe pattern', () => {
test('all update listeners follow the same pattern (channel-name parametric)', () => {
const channels = [
'ok:update:downloaded',
+ 'ok:update:relaunching',
'ok:update:whats-new',
'ok:update:whats-new-dismissed',
'ok:update:stuck-hint',