Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

feat(ok-desktop): show release-notes notice on all project windows (#1611)

Andrew Mikofalvy885c60a806d1
diff --git a/.changeset/release-notes-multi-window-dismiss.md b/.changeset/release-notes-multi-window-dismiss.md
new file mode 100644
index 000000000..063f16d8a
--- /dev/null
+++ b/.changeset/release-notes-multi-window-dismiss.md
@@ -0,0 +1,11 @@
+---
+"@inkeep/open-knowledge-desktop": patch
+---
+
+feat(ok-desktop): show the release-notes update notice on every open project window
+
+The "Updated to Version X" release-notes notice previously appeared on only one project window when several projects were open together, so a user looking at a different project never saw it. It now appears on every open window, and the "Relaunch now" update banner does too.
+
+Dismissing the release-notes notice on one window (or letting it auto-expire after its one-minute window) now clears it on all of them, so the same FYI no longer needs swatting once per window. A project opened shortly after an update, while the notice is still live, also shows it.
+
+When both a "new version ready to install" banner and the release-notes notice are armed at once, the single-card behavior is unchanged: the relaunch banner takes precedence and the release-notes notice waits behind it.
diff --git a/packages/app/src/components/UpdateNotices.shared.ts b/packages/app/src/components/UpdateNotices.shared.ts
index 36ae90ae5..d40f24d7e 100644
--- a/packages/app/src/components/UpdateNotices.shared.ts
+++ b/packages/app/src/components/UpdateNotices.shared.ts
@@ -34,6 +34,7 @@ export interface UpdateNotice {
body: string;
action?: { label: string; onClick: () => void };
secondaryAction?: { label: string; onClick: () => void };
+ onDismiss?: () => void;
variant?: 'info' | 'error';
priority: number;
}
@@ -112,15 +113,25 @@ export function attachUpdateSubscribers(
void bridge.shell.openExternal(releaseUrl);
},
},
+ onDismiss: () => {
+ void bridge.update.dismissWhatsNew(version);
+ },
});
const timer = setTimeout(() => {
autoDismissTimers.delete(timer);
dismissNotice(noticeId);
+ void bridge.update.dismissWhatsNew(version);
}, autoDismissMs);
autoDismissTimers.add(timer);
}),
);
+ unsubscribers.push(
+ bridge.onWhatsNewDismissed(({ version }) => {
+ dismissNotice(`whats-new-${version}`);
+ }),
+ );
+
unsubscribers.push(
bridge.onUpdateStuckHint(({ downloadUrl }) => {
addNotice({
diff --git a/packages/app/src/components/UpdateNotices.test.ts b/packages/app/src/components/UpdateNotices.test.ts
index bd3ca5d10..5d0485fd2 100644
--- a/packages/app/src/components/UpdateNotices.test.ts
+++ b/packages/app/src/components/UpdateNotices.test.ts
@@ -22,14 +22,17 @@ import {
type UpdateDownloadedCb = (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>;
onWhatsNew: ReturnType<typeof mock>;
+ onWhatsNewDismissed: ReturnType<typeof mock>;
onUpdateStuckHint: ReturnType<typeof mock>;
update: {
relaunchNow: ReturnType<typeof mock>;
+ dismissWhatsNew: ReturnType<typeof mock>;
};
state: {
query: ReturnType<typeof mock>;
@@ -38,9 +41,11 @@ interface FakeBridge {
shell: { openExternal: ReturnType<typeof mock> };
_downloaded?: UpdateDownloadedCb;
_whatsNew?: WhatsNewCb;
+ _whatsNewDismissed?: WhatsNewDismissedCb;
_stuckHint?: StuckHintCb;
_downloadedUnsub: ReturnType<typeof mock>;
_whatsNewUnsub: ReturnType<typeof mock>;
+ _whatsNewDismissedUnsub: ReturnType<typeof mock>;
_stuckHintUnsub: ReturnType<typeof mock>;
}
@@ -48,12 +53,15 @@ function makeFakeBridge(): FakeBridge {
const b: FakeBridge = {
_downloadedUnsub: mock(() => {}),
_whatsNewUnsub: mock(() => {}),
+ _whatsNewDismissedUnsub: mock(() => {}),
_stuckHintUnsub: mock(() => {}),
onUpdateDownloaded: mock(() => {}),
onWhatsNew: mock(() => {}),
+ onWhatsNewDismissed: mock(() => {}),
onUpdateStuckHint: mock(() => {}),
update: {
relaunchNow: mock(() => Promise.resolve(undefined)),
+ dismissWhatsNew: mock(() => Promise.resolve(undefined)),
},
state: {
query: mock(() => Promise.resolve({ channel: 'latest', schemaIncompatibility: null })),
@@ -69,6 +77,10 @@ function makeFakeBridge(): FakeBridge {
b._whatsNew = cb;
return b._whatsNewUnsub;
});
+ b.onWhatsNewDismissed = mock((cb: WhatsNewDismissedCb) => {
+ b._whatsNewDismissed = cb;
+ return b._whatsNewDismissedUnsub;
+ });
b.onUpdateStuckHint = mock((cb: StuckHintCb) => {
b._stuckHint = cb;
return b._stuckHintUnsub;
@@ -143,22 +155,24 @@ describe('appendErrorDetail', () => {
});
describe('attachUpdateSubscribers — registration', () => {
- test('subscribes to all three update channels on the bridge', () => {
+ test('subscribes to all four 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.onWhatsNew).toHaveBeenCalledTimes(1);
+ expect(bridge.onWhatsNewDismissed).toHaveBeenCalledTimes(1);
expect(bridge.onUpdateStuckHint).toHaveBeenCalledTimes(1);
});
- test('returns a single unsubscribe closure that detaches ALL three listeners', () => {
+ test('returns a single unsubscribe closure that detaches ALL four listeners', () => {
const bridge = makeFakeBridge();
const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
const unsubscribe = attachUpdateSubscribers(castBridge(bridge), addNotice);
unsubscribe();
expect(bridge._downloadedUnsub).toHaveBeenCalledTimes(1);
expect(bridge._whatsNewUnsub).toHaveBeenCalledTimes(1);
+ expect(bridge._whatsNewDismissedUnsub).toHaveBeenCalledTimes(1);
expect(bridge._stuckHintUnsub).toHaveBeenCalledTimes(1);
});
});
@@ -376,6 +390,36 @@ describe('Notice B — ok:update:whats-new', () => {
expect(dismissNotice).toHaveBeenCalledWith('whats-new-0.3.1');
expect(dismissNotice).toHaveBeenCalledTimes(2);
});
+
+ test('dismissing the notice (X) notifies main so every window can clear', () => {
+ const bridge = makeFakeBridge();
+ const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice);
+ bridge._whatsNew?.({ version: '0.3.1', releaseUrl: 'https://example.com/r' });
+ const notice = addNotice.mock.calls[0]?.[0] as UpdateNotice;
+ notice.onDismiss?.();
+ expect(bridge.update.dismissWhatsNew).toHaveBeenCalledWith('0.3.1');
+ });
+
+ test('auto-dismiss also notifies main so the other windows clear in lockstep', async () => {
+ const bridge = makeFakeBridge();
+ const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
+ const dismissNotice = mock<(id: string) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice, dismissNotice, 15);
+ bridge._whatsNew?.({ version: '0.3.1', releaseUrl: 'https://example.com/r' });
+ await new Promise((resolve) => setTimeout(resolve, 45));
+ expect(bridge.update.dismissWhatsNew).toHaveBeenCalledWith('0.3.1');
+ });
+
+ test('onWhatsNewDismissed echo clears the card by id without re-notifying main (no loop)', () => {
+ const bridge = makeFakeBridge();
+ const addNotice = mock<(notice: UpdateNotice) => void>(() => {});
+ const dismissNotice = mock<(id: string) => void>(() => {});
+ attachUpdateSubscribers(castBridge(bridge), addNotice, dismissNotice);
+ bridge._whatsNewDismissed?.({ version: '0.3.1' });
+ expect(dismissNotice).toHaveBeenCalledWith('whats-new-0.3.1');
+ expect(bridge.update.dismissWhatsNew).not.toHaveBeenCalled();
+ });
});
describe('Notice C — ok:update:stuck-hint', () => {
@@ -519,13 +563,14 @@ describe('pickActiveNotice', () => {
});
describe('unsubscribe semantics', () => {
- test('after unsubscribe, all three per-channel unsub closures fire', () => {
+ test('after unsubscribe, all four 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._whatsNewUnsub).toHaveBeenCalledTimes(1);
+ expect(bridge._whatsNewDismissedUnsub).toHaveBeenCalledTimes(1);
expect(bridge._stuckHintUnsub).toHaveBeenCalledTimes(1);
});
});
diff --git a/packages/app/src/components/UpdateNotices.tsx b/packages/app/src/components/UpdateNotices.tsx
index 584448e6b..ec76b364c 100644
--- a/packages/app/src/components/UpdateNotices.tsx
+++ b/packages/app/src/components/UpdateNotices.tsx
@@ -126,6 +126,7 @@ export function UpdateNotices(): ReactNode {
<NoticeCard
notice={active}
onDismiss={() => {
+ active.onDismiss?.();
dismissNotice(active.id);
}}
/>
diff --git a/packages/app/src/lib/desktop-bridge-types.ts b/packages/app/src/lib/desktop-bridge-types.ts
index a4c04961d..c74274b98 100644
--- a/packages/app/src/lib/desktop-bridge-types.ts
+++ b/packages/app/src/lib/desktop-bridge-types.ts
@@ -420,6 +420,7 @@ export interface OkDesktopBridge {
onMenuAction(cb: (action: OkMenuAction) => void): OkUnsubscribe;
onUpdateDownloaded(cb: (info: OkUpdateDownloadedInfo) => void): OkUnsubscribe;
onWhatsNew(cb: (info: OkWhatsNewInfo) => void): OkUnsubscribe;
+ onWhatsNewDismissed(cb: (info: { readonly version: string }) => void): OkUnsubscribe;
onUpdateStuckHint(cb: (info: OkUpdateStuckHintInfo) => void): OkUnsubscribe;
onDeepLink(
cb: (evt: {
@@ -580,6 +581,7 @@ export interface OkDesktopBridge {
update: {
relaunchNow(): Promise<void>;
checkNow(): Promise<void>;
+ dismissWhatsNew(version: string): Promise<void>;
};
state: {
query(): Promise<OkStateSnapshot>;
diff --git a/packages/app/tests/stress/file-tree-create.e2e.ts b/packages/app/tests/stress/file-tree-create.e2e.ts
index 549671db4..a25f65000 100644
--- a/packages/app/tests/stress/file-tree-create.e2e.ts
+++ b/packages/app/tests/stress/file-tree-create.e2e.ts
@@ -182,6 +182,7 @@ async function installDelayedDesktopSessionBridge(
onMenuAction: () => unsubscribe,
onUpdateDownloaded: () => unsubscribe,
onWhatsNew: () => unsubscribe,
+ onWhatsNewDismissed: () => unsubscribe,
onUpdateStuckHint: () => unsubscribe,
onDeepLink: () => unsubscribe,
onShareReceived: () => unsubscribe,
@@ -240,6 +241,7 @@ async function installDelayedDesktopSessionBridge(
update: {
relaunchNow: async () => {},
checkNow: async () => {},
+ dismissWhatsNew: async () => {},
},
state: {
query: async () => ({ channel: 'latest', schemaIncompatibility: null }),
diff --git a/packages/app/tests/stress/fixtures/handoff-mocks.ts b/packages/app/tests/stress/fixtures/handoff-mocks.ts
index a516f0659..c3ea41307 100644
--- a/packages/app/tests/stress/fixtures/handoff-mocks.ts
+++ b/packages/app/tests/stress/fixtures/handoff-mocks.ts
@@ -215,6 +215,7 @@ export async function installHandoffMocks(page: Page, cfg: HandoffMockConfig): P
onMenuAction: () => () => {},
onUpdateDownloaded: () => () => {},
onWhatsNew: () => () => {},
+ onWhatsNewDismissed: () => () => {},
onUpdateStuckHint: () => () => {},
onDeepLink: () => () => {},
onShareReceived: () => () => {},
@@ -292,6 +293,7 @@ export async function installHandoffMocks(page: Page, cfg: HandoffMockConfig): P
update: {
relaunchNow: async () => {},
checkNow: async () => {},
+ dismissWhatsNew: async () => {},
},
state: {
query: async () => ({
diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.ts
index 31241c4f2..eae77a22e 100644
--- a/packages/core/src/desktop-bridge.ts
+++ b/packages/core/src/desktop-bridge.ts
@@ -411,6 +411,7 @@ export interface OkDesktopBridge {
onMenuAction(cb: (action: OkMenuAction) => void): OkUnsubscribe;
onUpdateDownloaded(cb: (info: OkUpdateDownloadedInfo) => void): OkUnsubscribe;
onWhatsNew(cb: (info: OkWhatsNewInfo) => void): OkUnsubscribe;
+ onWhatsNewDismissed(cb: (info: { readonly version: string }) => void): OkUnsubscribe;
onUpdateStuckHint(cb: (info: OkUpdateStuckHintInfo) => void): OkUnsubscribe;
onDeepLink(
cb: (evt: {
@@ -578,6 +579,7 @@ export interface OkDesktopBridge {
update: {
relaunchNow(): Promise<void>;
checkNow(): Promise<void>;
+ dismissWhatsNew(version: string): Promise<void>;
};
state: {
diff --git a/packages/desktop/src/main/auto-updater.ts b/packages/desktop/src/main/auto-updater.ts
index d9f443c2d..51d0ff159 100644
--- a/packages/desktop/src/main/auto-updater.ts
+++ b/packages/desktop/src/main/auto-updater.ts
@@ -39,6 +39,7 @@ export type DispatchKind =
| 'update-downloaded-deduped'
| 'update-downloaded-empty-version'
| 'whats-new-toast-b'
+ | 'whats-new-dismiss-broadcast'
| 'stuck-hint-toast-c'
| 'check-success'
| 'error-classified'
@@ -77,6 +78,7 @@ type CheckNowResult =
export interface StartAutoUpdaterHandle {
destroy(): void;
checkForUpdatesNow(): Promise<unknown>;
+ getActiveWhatsNew(): { version: string; releaseUrl: string } | null;
}
interface Logger {
@@ -108,6 +110,8 @@ export const STUCK_HINT_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1000;
export const STUCK_HINT_DOWNLOAD_URL = 'https://inkeep.com/open-knowledge/download';
+const WHATS_NEW_LIVE_WINDOW_MS = 60_000;
+
export function releaseUrlFor(version: string): string {
return `https://github.com/inkeep/open-knowledge/releases/tag/v${encodeURIComponent(version)}`;
}
@@ -284,6 +288,8 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
let menuCheckPending = false;
+ let activeWhatsNew: { version: string; releaseUrl: string; firedAt: number } | null = null;
+
const runMenuDrivenCheck = (): Promise<unknown> => {
menuCheckPending = true;
const checkPromise = updater.checkForUpdates();
@@ -471,6 +477,19 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
return undefined;
});
+ register(
+ 'ok:update:whats-new-dismiss',
+ (_event: IpcMainInvokeEvent, payload: { version: string }): undefined => {
+ const version = typeof payload?.version === 'string' ? payload.version : '';
+ if (activeWhatsNew && activeWhatsNew.version === version) {
+ activeWhatsNew = null;
+ }
+ broadcastToAllWindows('ok:update:whats-new-dismissed', { version });
+ onDispatch?.('whats-new-dismiss-broadcast');
+ return undefined;
+ },
+ );
+
const currentVersion = getAppVersion();
let state = readState();
@@ -497,11 +516,13 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
);
if (advanced && shouldShowVersionNotice) {
const fireToastB = (): void => {
- broadcast('ok:update:whats-new', {
+ const releaseUrl = releaseUrlFor(currentVersion);
+ activeWhatsNew = { version: currentVersion, releaseUrl, firedAt: now().getTime() };
+ broadcastToAllWindows('ok:update:whats-new', {
version: currentVersion,
- releaseUrl: releaseUrlFor(currentVersion),
+ releaseUrl,
});
- logger.info('whats-new dispatched Toast B', {
+ logger.info('whats-new dispatched Toast B (all windows)', {
from: state.lastSeenVersion,
to: currentVersion,
});
@@ -560,6 +581,13 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
logger.info('check-now invoked from menu');
return runMenuDrivenCheck();
},
+ getActiveWhatsNew(): { version: string; releaseUrl: string } | null {
+ if (!activeWhatsNew) return null;
+ if (now().getTime() - activeWhatsNew.firedAt >= WHATS_NEW_LIVE_WINDOW_MS) {
+ return null;
+ }
+ return { version: activeWhatsNew.version, releaseUrl: activeWhatsNew.releaseUrl };
+ },
destroy(): void {
if (timerHandle) {
clock.clearTimeout(timerHandle);
@@ -594,6 +622,7 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa
};
removeHandlerSafely('ok:update:relaunch-now');
removeHandlerSafely('ok:update:check-now');
+ removeHandlerSafely('ok:update:whats-new-dismiss');
logger.info('destroyed');
},
};
diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.ts
index ae42e2298..a49a7a411 100644
--- a/packages/desktop/src/main/index.ts
+++ b/packages/desktop/src/main/index.ts
@@ -2212,8 +2212,13 @@ function bootPrimaryInstance(): void {
app.on('browser-window-created', (_event, win) => {
win.webContents.once('did-finish-load', () => {
const pending = appState.versionPendingInstall;
- if (!pending) return;
- sendToRenderer(win.webContents, 'ok:update:downloaded', { version: pending });
+ if (pending) {
+ sendToRenderer(win.webContents, 'ok:update:downloaded', { version: pending });
+ }
+ const whatsNew = autoUpdaterHandle?.getActiveWhatsNew();
+ if (whatsNew) {
+ sendToRenderer(win.webContents, 'ok:update:whats-new', whatsNew);
+ }
});
});
@@ -2285,6 +2290,7 @@ function bootPrimaryInstance(): void {
const all = BrowserWindow.getAllWindows();
return all[0] ?? null;
},
+ getAllWindows: () => BrowserWindow.getAllWindows(),
getAppVersion: () => app.getVersion(),
isPackaged: app.isPackaged,
forceDevBypass: process.env.OK_UPDATER_FORCE_DEV === '1',
diff --git a/packages/desktop/src/preload/index.ts b/packages/desktop/src/preload/index.ts
index 7f0c43351..31b92cae8 100644
--- a/packages/desktop/src/preload/index.ts
+++ b/packages/desktop/src/preload/index.ts
@@ -190,6 +190,13 @@ const bridge: OkDesktopBridge = {
return () => ipcRenderer.removeListener('ok:update:whats-new', listener);
},
+ onWhatsNewDismissed(cb: (info: { version: string }) => void) {
+ const listener = (_event: IpcRendererEvent, info: { version: string }) => cb(info);
+ // biome-ignore lint/plugin/no-loosely-typed-webcontents-ipc: preload-side subscription wrapper (precedent #14)
+ ipcRenderer.on('ok:update:whats-new-dismissed', listener);
+ return () => ipcRenderer.removeListener('ok:update:whats-new-dismissed', listener);
+ },
+
onUpdateStuckHint(cb: (info: OkUpdateStuckHintInfo) => void) {
const listener = (_event: IpcRendererEvent, info: OkUpdateStuckHintInfo) => cb(info);
// biome-ignore lint/plugin/no-loosely-typed-webcontents-ipc: preload-side subscription wrapper (precedent #14)
@@ -344,6 +351,7 @@ const bridge: OkDesktopBridge = {
update: {
relaunchNow: () => invoke('ok:update:relaunch-now'),
checkNow: () => invoke('ok:update:check-now'),
+ dismissWhatsNew: (version: string) => invoke('ok:update:whats-new-dismiss', { version }),
},
state: {
diff --git a/packages/desktop/src/shared/bridge-contract.ts b/packages/desktop/src/shared/bridge-contract.ts
index 98b788fc9..11196210e 100644
--- a/packages/desktop/src/shared/bridge-contract.ts
+++ b/packages/desktop/src/shared/bridge-contract.ts
@@ -397,6 +397,7 @@ export interface OkDesktopBridge {
onMenuAction(cb: (action: OkMenuAction) => void): OkUnsubscribe;
onUpdateDownloaded(cb: (info: OkUpdateDownloadedInfo) => void): OkUnsubscribe;
onWhatsNew(cb: (info: OkWhatsNewInfo) => void): OkUnsubscribe;
+ onWhatsNewDismissed(cb: (info: { readonly version: string }) => void): OkUnsubscribe;
onUpdateStuckHint(cb: (info: OkUpdateStuckHintInfo) => void): OkUnsubscribe;
onDeepLink(
cb: (evt: {
@@ -578,6 +579,7 @@ export interface OkDesktopBridge {
update: {
relaunchNow(): Promise<void>;
checkNow(): Promise<void>;
+ dismissWhatsNew(version: string): Promise<void>;
};
state: {
diff --git a/packages/desktop/src/shared/ipc-channels.ts b/packages/desktop/src/shared/ipc-channels.ts
index b17b2a5a3..bdf9cb09d 100644
--- a/packages/desktop/src/shared/ipc-channels.ts
+++ b/packages/desktop/src/shared/ipc-channels.ts
@@ -387,6 +387,7 @@ export interface RequestChannels {
'ok:navigator:open': { args: []; result: undefined };
'ok:update:relaunch-now': { args: []; result: undefined };
'ok:update:check-now': { args: []; result: undefined };
+ 'ok:update:whats-new-dismiss': { args: [{ version: string }]; result: undefined };
'ok:state:query': {
args: [];
result: {
diff --git a/packages/desktop/src/shared/ipc-events.ts b/packages/desktop/src/shared/ipc-events.ts
index e84516dc6..fa8825d0b 100644
--- a/packages/desktop/src/shared/ipc-events.ts
+++ b/packages/desktop/src/shared/ipc-events.ts
@@ -16,6 +16,7 @@ export interface EventChannels {
'ok:menu-action': { payload: OkMenuAction };
'ok:update:downloaded': { 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 } };
'ok:deep-link': {
payload: {
diff --git a/packages/desktop/tests/integration/auto-updater.test.ts b/packages/desktop/tests/integration/auto-updater.test.ts
index 3495029aa..944f31abe 100644
--- a/packages/desktop/tests/integration/auto-updater.test.ts
+++ b/packages/desktop/tests/integration/auto-updater.test.ts
@@ -815,7 +815,7 @@ describe('versionAtLeast (MMP compare)', () => {
});
});
-describe('multi-window delivery: relaunch banner everywhere, "updated to" notice on the primary only', () => {
+describe('multi-window delivery: relaunch banner and "updated to" notice both reach every window', () => {
test('ok:update:downloaded (relaunch banner) reaches every open window', () => {
const { rig } = makeRig({ extraWindowCount: 2 });
expect(rig.windows).toHaveLength(3);
@@ -836,19 +836,18 @@ describe('multi-window delivery: relaunch banner everywhere, "updated to" notice
expect(rig.windows[0]?.filter((c) => c.channel === 'ok:update:downloaded')).toHaveLength(1);
});
- test('ok:update:whats-new ("Updated to Version X") goes to the primary window only', () => {
+ test('ok:update:whats-new ("Updated to Version X") reaches every open window', () => {
const { rig } = makeRig({
lastSeenVersion: '0.3.0',
appVersion: '0.3.1',
extraWindowCount: 2,
});
expect(rig.windows).toHaveLength(3);
- const primaryWhatsNew =
- rig.windows[0]?.filter((c) => c.channel === 'ok:update:whats-new') ?? [];
- expect(primaryWhatsNew).toHaveLength(1);
- expect(primaryWhatsNew[0]?.payload).toMatchObject({ version: '0.3.1' });
- expect(rig.windows[1]?.filter((c) => c.channel === 'ok:update:whats-new')).toHaveLength(0);
- expect(rig.windows[2]?.filter((c) => c.channel === 'ok:update:whats-new')).toHaveLength(0);
+ for (const win of rig.windows) {
+ const whatsNew = win.filter((c) => c.channel === 'ok:update:whats-new');
+ expect(whatsNew).toHaveLength(1);
+ expect(whatsNew[0]?.payload).toMatchObject({ version: '0.3.1' });
+ }
expect(rig.dispatches.filter((d) => d === 'whats-new-toast-b')).toHaveLength(1);
});
@@ -863,6 +862,49 @@ describe('multi-window delivery: relaunch banner everywhere, "updated to" notice
});
});
+describe('release-notes cross-window dismiss + late-window delivery', () => {
+ test('registers the whats-new-dismiss IPC handler', () => {
+ const { rig } = makeRig();
+ expect(rig.ipc.handlers.has('ok:update:whats-new-dismiss')).toBe(true);
+ });
+
+ test('whats-new-dismiss re-broadcasts ok:update:whats-new-dismissed to every window', () => {
+ const { rig } = makeRig({ extraWindowCount: 2 });
+ rig.ipc.invoke('ok:update:whats-new-dismiss', { version: '0.3.1' });
+ for (const win of rig.windows) {
+ const dismissed = win.filter((c) => c.channel === 'ok:update:whats-new-dismissed');
+ expect(dismissed).toHaveLength(1);
+ expect(dismissed[0]?.payload).toEqual({ version: '0.3.1' });
+ }
+ expect(rig.dispatches).toContain('whats-new-dismiss-broadcast' as DispatchKind);
+ });
+
+ test('getActiveWhatsNew returns the live notice within its window', () => {
+ const { handle } = makeRig({ lastSeenVersion: '0.3.0', appVersion: '0.3.1' });
+ expect(handle.getActiveWhatsNew()).toMatchObject({ version: '0.3.1' });
+ });
+
+ test('getActiveWhatsNew returns null once the live window elapses', () => {
+ const { rig, handle } = makeRig({ lastSeenVersion: '0.3.0', appVersion: '0.3.1' });
+ expect(handle.getActiveWhatsNew()).not.toBeNull();
+ rig.now = new Date(rig.now.getTime() + 60_001);
+ expect(handle.getActiveWhatsNew()).toBeNull();
+ });
+
+ test('getActiveWhatsNew returns null after the notice is dismissed', () => {
+ const { rig, handle } = makeRig({ lastSeenVersion: '0.3.0', appVersion: '0.3.1' });
+ expect(handle.getActiveWhatsNew()).not.toBeNull();
+ rig.ipc.invoke('ok:update:whats-new-dismiss', { version: '0.3.1' });
+ expect(handle.getActiveWhatsNew()).toBeNull();
+ });
+
+ test('a stale dismiss for an older version leaves a newer live notice intact', () => {
+ const { rig, handle } = makeRig({ lastSeenVersion: '0.3.0', appVersion: '0.3.1' });
+ rig.ipc.invoke('ok:update:whats-new-dismiss', { version: '0.3.0' });
+ expect(handle.getActiveWhatsNew()).toMatchObject({ version: '0.3.1' });
+ });
+});
+
describe('periodic check singleton + jitter (AC10, D10)', () => {
test('registers exactly one timer after the first launch check resolves', async () => {
const { rig } = makeRig();
diff --git a/packages/desktop/tests/preload/update-listeners.test.ts b/packages/desktop/tests/preload/update-listeners.test.ts
index 63a487b47..670c09a35 100644
--- a/packages/desktop/tests/preload/update-listeners.test.ts
+++ b/packages/desktop/tests/preload/update-listeners.test.ts
@@ -73,10 +73,11 @@ describe('M3 update-listener subscribe/unsubscribe pattern', () => {
expect(ipc.removeListener).toHaveBeenCalledWith('ok:update:downloaded', registeredWrapper);
});
- test('all three M3 listeners follow the same pattern (channel-name parametric)', () => {
+ test('all update listeners follow the same pattern (channel-name parametric)', () => {
const channels = [
'ok:update:downloaded',
'ok:update:whats-new',
+ 'ok:update:whats-new-dismissed',
'ok:update:stuck-hint',
] as const;
for (const channel of channels) {