Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(open-knowledge): surface failed auto-update installs at next boot (PRD-7149) (#2010)
Andrew Mikofalvy4a7aac1a600d
diff --git a/.changeset/desktop-failed-install-detection.md b/.changeset/desktop-failed-install-detection.mdnew file mode 100644index 000000000..4d4083b22--- /dev/null+++ b/.changeset/desktop-failed-install-detection.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge": patch+---++Desktop: detect and surface a failed auto-update install. When a "Relaunch now" (or quit-to-install) update is committed but the app boots back on the old version — e.g. macOS Squirrel's post-quit install never ran — the next launch now shows a clear "Update to vX didn't install" notice with Retry and Download manually actions, instead of failing silently. Previously this clean-quit failure left no signal: the in-session error and no-quit watchdog only fire while the process is alive, and the pending-install record was cleared before quit. Detection uses a prerelease-aware version compare so same-version beta bumps (e.g. beta.1 → beta.3) are no longer misread as a successful install.diff --git a/packages/app/src/components/UpdateNotices.shared.ts b/packages/app/src/components/UpdateNotices.shared.tsindex 6f1a63429..ae0a47673 100644--- a/packages/app/src/components/UpdateNotices.shared.ts+++ b/packages/app/src/components/UpdateNotices.shared.ts@@ -10,6 +10,12 @@ export const TOAST_A_PROGRESS_BODY = 'Relaunching to install the update…';export const TOAST_A_ERROR_BODY = 'Relaunch failed — please restart manually';+export function installFailedBody(version: string): string {+ return `Update to ${version} didn't install.`;+}+export const INSTALL_FAILED_RETRY_ACTION = 'Retry';+export const INSTALL_FAILED_DOWNLOAD_ACTION = 'Download manually';+export const TOAST_E_ERROR_BODY = 'Recovery action failed — please try again';export function appendErrorDetail(base: string, err: unknown): string {@@ -116,7 +122,40 @@ export function attachUpdateSubscribers();unsubscribers.push(- bridge.onUpdateRelaunchFailed(({ version, message }) => {+ bridge.onUpdateRelaunchFailed(({ version, message, downloadUrl }) => {+ if (downloadUrl) {+ const failedId = `install-failed-${version}`;+ const armFailedNotice = (): void => {+ addNotice({+ id: failedId,+ body: installFailedBody(version),+ variant: 'error',+ priority: PRIORITY_RELAUNCH_ERROR,+ action: {+ label: INSTALL_FAILED_RETRY_ACTION,+ onClick: () => {+ bridge.update.relaunchNow().then(+ () => {+ dismissNotice(failedId);+ },+ (err: unknown) => {+ console.warn('[update-notice] install-failed retry rejected', err);+ armFailedNotice();+ },+ );+ },+ },+ secondaryAction: {+ label: INSTALL_FAILED_DOWNLOAD_ACTION,+ onClick: () => {+ void bridge.shell.openExternal(downloadUrl);+ },+ },+ });+ };+ armFailedNotice();+ return;+ }addNotice({id: `relaunch-error-${version}`,body: message ? `${TOAST_A_ERROR_BODY}: ${message}` : TOAST_A_ERROR_BODY,diff --git a/packages/app/src/components/UpdateNotices.test.ts b/packages/app/src/components/UpdateNotices.test.tsindex feb55818d..c2308372f 100644--- a/packages/app/src/components/UpdateNotices.test.ts+++ b/packages/app/src/components/UpdateNotices.test.ts@@ -4,6 +4,9 @@ import {addSchemaIncompatibilityNotice,appendErrorDetail,attachUpdateSubscribers,+ INSTALL_FAILED_DOWNLOAD_ACTION,+ INSTALL_FAILED_RETRY_ACTION,+ installFailedBody,pickActiveNotice,TOAST_A_ACTION,TOAST_A_ERROR_BODY,@@ -22,7 +25,7 @@ import {type UpdateDownloadedCb = (info: { version: string }) => void;type RelaunchingCb = (info: { version: string }) => void;-type RelaunchFailedCb = (info: { version: string; message?: string }) => void;+type RelaunchFailedCb = (info: { version: string; message?: string; downloadUrl?: string }) => void;type WhatsNewCb = (info: { version: string; releaseUrl: string }) => void;type WhatsNewDismissedCb = (info: { version: string }) => void;type StuckHintCb = (info: { downloadUrl: string }) => void;@@ -247,6 +250,46 @@ describe('Notice A cross-window relaunch — ok:update:relaunching', () => {expect(errorNotice.body).toBe(TOAST_A_ERROR_BODY);});+ test('boot-detected failed install (downloadUrl present) → richer two-action card', () => {+ const bridge = makeFakeBridge();+ const addNotice = mock<(notice: UpdateNotice) => void>(() => {});+ attachUpdateSubscribers(castBridge(bridge), addNotice);+ bridge._relaunchFailed?.({+ version: '0.16.0-beta.3',+ downloadUrl: 'https://inkeep.com/open-knowledge/download',+ });+ const notice = addNotice.mock.calls.at(-1)?.[0] as UpdateNotice;+ expect(notice.id).toBe('install-failed-0.16.0-beta.3');+ expect(notice.body).toBe(installFailedBody('0.16.0-beta.3'));+ expect(notice.variant).toBe('error');+ expect(notice.action?.label).toBe(INSTALL_FAILED_RETRY_ACTION);+ expect(notice.secondaryAction?.label).toBe(INSTALL_FAILED_DOWNLOAD_ACTION);+ });++ test('failed-install Retry invokes relaunchNow; Download manually opens the URL', () => {+ const bridge = makeFakeBridge();+ const addNotice = mock<(notice: UpdateNotice) => void>(() => {});+ attachUpdateSubscribers(castBridge(bridge), addNotice);+ const url = 'https://inkeep.com/open-knowledge/download';+ bridge._relaunchFailed?.({ version: '0.16.0-beta.3', downloadUrl: url });+ const notice = addNotice.mock.calls.at(-1)?.[0] as UpdateNotice;+ notice.action?.onClick();+ expect(bridge.update.relaunchNow).toHaveBeenCalledTimes(1);+ notice.secondaryAction?.onClick();+ expect(bridge.shell.openExternal).toHaveBeenCalledWith(url);+ });++ test('relaunch-failed WITHOUT downloadUrl keeps the plain error notice (no actions)', () => {+ const bridge = makeFakeBridge();+ const addNotice = mock<(notice: UpdateNotice) => void>(() => {});+ attachUpdateSubscribers(castBridge(bridge), addNotice);+ bridge._relaunchFailed?.({ version: '0.16.0-beta.3' });+ const notice = addNotice.mock.calls.at(-1)?.[0] as UpdateNotice;+ expect(notice.id).toBe('relaunch-error-0.16.0-beta.3');+ expect(notice.action).toBeUndefined();+ expect(notice.secondaryAction).toBeUndefined();+ });+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>(() => {});diff --git a/packages/app/src/components/UpdateNotices.tsx b/packages/app/src/components/UpdateNotices.tsxindex 1702299b2..b6b94cbb5 100644--- a/packages/app/src/components/UpdateNotices.tsx+++ b/packages/app/src/components/UpdateNotices.tsx@@ -12,6 +12,9 @@ export {addSchemaIncompatibilityNotice,appendErrorDetail,attachUpdateSubscribers,+ INSTALL_FAILED_DOWNLOAD_ACTION,+ INSTALL_FAILED_RETRY_ACTION,+ installFailedBody,TOAST_A_ACTION,TOAST_A_ERROR_BODY,TOAST_A_PROGRESS_BODY,diff --git a/packages/app/src/lib/desktop-bridge-types.ts b/packages/app/src/lib/desktop-bridge-types.tsindex b295cdc76..b39f4766d 100644--- a/packages/app/src/lib/desktop-bridge-types.ts+++ b/packages/app/src/lib/desktop-bridge-types.ts@@ -193,6 +193,7 @@ interface OkUpdateRelaunchingInfo {interface OkUpdateRelaunchFailedInfo {readonly version: string;readonly message?: string;+ readonly downloadUrl?: string;}interface OkWhatsNewInfo {diff --git a/packages/desktop/src/main/auto-updater.ts b/packages/desktop/src/main/auto-updater.tsindex a436a0cc5..a2af94af2 100644--- a/packages/desktop/src/main/auto-updater.ts+++ b/packages/desktop/src/main/auto-updater.ts@@ -51,6 +51,8 @@ export type DispatchKind =| 'relaunch-watchdog-fired'| 'skipped-dev-mode'| 'stale-pending-cleared'+ | 'attempted-install-reconciled'+ | 'install-failed-on-boot'| 'cross-channel-blocked';interface StartAutoUpdaterOpts {@@ -176,6 +178,39 @@ export function versionAtLeast(running: string, pending: string): boolean {return r[2] >= p[2];}+export function installReached(running: string, attempted: string): boolean {+ const parse = (v: string): { mmp: [number, number, number]; pre: string[] } | null => {+ if (typeof v !== 'string') return null;+ const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(v);+ if (!m) return null;+ return {+ mmp: [Number(m[1]), Number(m[2]), Number(m[3])],+ pre: m[4] ? m[4].split('.') : [],+ };+ };+ const r = parse(running);+ const a = parse(attempted);+ if (!r || !a) return true;+ for (let i = 0; i < 3; i++) {+ if (r.mmp[i] !== a.mmp[i]) return (r.mmp[i] as number) > (a.mmp[i] as number);+ }+ if (r.pre.length === 0 && a.pre.length === 0) return true;+ if (r.pre.length === 0) return true; // running is stable, attempted is a prerelease+ if (a.pre.length === 0) return false; // running is a prerelease, attempted is stable+ const len = Math.min(r.pre.length, a.pre.length);+ for (let i = 0; i < len; i++) {+ const ri = r.pre[i] as string;+ const ai = a.pre[i] as string;+ if (ri === ai) continue;+ const rNum = /^\d+$/.test(ri);+ const aNum = /^\d+$/.test(ai);+ if (rNum && aNum) return Number(ri) > Number(ai);+ if (rNum !== aNum) return aNum; // numeric identifiers rank below non-numeric+ return ri > ai; // both non-numeric — ASCII order+ }+ return r.pre.length >= a.pre.length;+}+export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHandle {const {updater,@@ -434,7 +469,13 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHaonDispatch?.('update-downloaded-deduped');return;}- if (!persistSafely({ ...state, versionPendingInstall: version }, 'update-downloaded')) return;+ if (+ !persistSafely(+ { ...state, versionPendingInstall: version, attemptedInstall: version },+ 'update-downloaded',+ )+ )+ return;const fireToastA = () => {broadcastToAllWindows('ok:update:downloaded', { version });logger.info('update-downloaded dispatched Toast A (all windows)', { version });@@ -559,6 +600,40 @@ export function startAutoUpdater(opts: StartAutoUpdaterOpts): StartAutoUpdaterHa}}+ if (state.attemptedInstall) {+ const attempted = state.attemptedInstall;+ if (installReached(currentVersion, attempted)) {+ const next = { ...state, attemptedInstall: null };+ if (persistSafely(next, 'attempted-install-reconciled')) {+ state = next;+ onDispatch?.('attempted-install-reconciled');+ } else {+ logger.warn('failed to persist attempted-install-reconciled', {+ attempted,+ running: currentVersion,+ });+ }+ } else {+ const next = { ...state, versionPendingInstall: attempted };+ if (persistSafely(next, 'install-failed-on-boot')) {+ state = next;+ logger.warn('attempted install did not take — surfacing failure notice', {+ attempted,+ running: currentVersion,+ });+ const fireInstallFailed = (): void => {+ broadcastToAllWindows('ok:update:relaunch-failed', {+ version: attempted,+ downloadUrl: STUCK_HINT_DOWNLOAD_URL,+ });+ };+ if (whenRendererReady) whenRendererReady(fireInstallFailed);+ else fireInstallFailed();+ onDispatch?.('install-failed-on-boot');+ }+ }+ }+const shouldShowVersionNotice =state.lastSeenVersion !== null && state.lastSeenVersion !== currentVersion;const needsStateAdvance = state.lastSeenVersion !== currentVersion;diff --git a/packages/desktop/src/main/state-store.ts b/packages/desktop/src/main/state-store.tsindex b28d6987a..ccdd29f35 100644--- a/packages/desktop/src/main/state-store.ts+++ b/packages/desktop/src/main/state-store.ts@@ -27,6 +27,7 @@ export interface AppState {recentProjects: RecentProject[];lastOpenedProject: string | null;versionPendingInstall: string | null;+ attemptedInstall: string | null;lastSeenVersion: string | null;lastSuccessfulCheckAt: string | null;stuckHintShown: boolean;@@ -45,6 +46,7 @@ export function emptyState(): AppState {recentProjects: [],lastOpenedProject: null,versionPendingInstall: null,+ attemptedInstall: null,lastSeenVersion: null,lastSuccessfulCheckAt: null,stuckHintShown: false,@@ -291,6 +293,7 @@ export function parseAppState(raw: unknown): AppState | null {typeof obj.lastOpenedProject === 'string' ? obj.lastOpenedProject : null;const versionPendingInstall =typeof obj.versionPendingInstall === 'string' ? obj.versionPendingInstall : null;+ const attemptedInstall = typeof obj.attemptedInstall === 'string' ? obj.attemptedInstall : null;const lastSeenVersion = typeof obj.lastSeenVersion === 'string' ? obj.lastSeenVersion : null;const lastSuccessfulCheckAt =typeof obj.lastSuccessfulCheckAt === 'string' ? obj.lastSuccessfulCheckAt : null;@@ -315,6 +318,7 @@ export function parseAppState(raw: unknown): AppState | null {recentProjects,lastOpenedProject,versionPendingInstall,+ attemptedInstall,lastSeenVersion,lastSuccessfulCheckAt,stuckHintShown,diff --git a/packages/desktop/src/shared/bridge-contract.ts b/packages/desktop/src/shared/bridge-contract.tsindex 52318d549..9e6b54917 100644--- a/packages/desktop/src/shared/bridge-contract.ts+++ b/packages/desktop/src/shared/bridge-contract.ts@@ -154,6 +154,7 @@ export interface OkUpdateRelaunchingInfo {export interface OkUpdateRelaunchFailedInfo {readonly version: string;readonly message?: string;+ readonly downloadUrl?: string;}export interface OkWhatsNewInfo {diff --git a/packages/desktop/src/shared/ipc-events.ts b/packages/desktop/src/shared/ipc-events.tsindex 352fd1701..447f07cbf 100644--- a/packages/desktop/src/shared/ipc-events.ts+++ b/packages/desktop/src/shared/ipc-events.ts@@ -18,7 +18,9 @@ export interface EventChannels {'ok:menu-action': { payload: OkMenuAction };'ok:update:downloaded': { payload: { version: string } };'ok:update:relaunching': { payload: { version: string } };- 'ok:update:relaunch-failed': { payload: { version: string; message?: string } };+ 'ok:update:relaunch-failed': {+ payload: { version: string; message?: string; downloadUrl?: 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.tsindex 08c4b94a4..737490ea0 100644--- a/packages/desktop/tests/integration/auto-updater.test.ts+++ b/packages/desktop/tests/integration/auto-updater.test.ts@@ -5,6 +5,7 @@ import {buildCheckNowResultFromError,type DispatchKind,type IpcMainLike,+ installReached,isClassifiedUpdaterError,RELAUNCH_WATCHDOG_MS,releaseUrlFor,@@ -777,6 +778,208 @@ describe('boot-time stale versionPendingInstall reconciliation', () => {});});+describe('boot-time failed-install detection', () => {+ test('attempted not reached (same-MMP beta) → relaunch-failed w/ downloadUrl, re-arm, stays armed', () => {+ const { rig } = makeRig({+ attemptedInstall: '0.16.0-beta.3',+ appVersion: '0.16.0-beta.1',+ });+ const failed = rig.captured.filter((c) => c.channel === 'ok:update:relaunch-failed');+ expect(failed).toHaveLength(1);+ expect(failed[0]?.payload).toEqual({+ version: '0.16.0-beta.3',+ downloadUrl: STUCK_HINT_DOWNLOAD_URL,+ });+ expect(rig.state.attemptedInstall).toBe('0.16.0-beta.3');+ expect(rig.state.versionPendingInstall).toBe('0.16.0-beta.3');+ expect(rig.dispatches).toContain('install-failed-on-boot' as DispatchKind);+ expect(rig.dispatches).not.toContain('attempted-install-reconciled' as DispatchKind);+ });++ test('persistent failure across reboots keeps re-surfacing (attemptedInstall not consumed)', () => {+ const state: AppState = {+ ...emptyState(),+ lastSeenVersion: '0.16.0-beta.1',+ attemptedInstall: '0.16.0-beta.3',+ };+ const boot = () => {+ const captured: CapturedSend[] = [];+ const dispatches: DispatchKind[] = [];+ startAutoUpdater({+ updater: new FakeUpdater(),+ ipcMain: makeFakeIpc(),+ readState: () => state,+ writeState: (next) => {+ Object.assign(state, next);+ },+ getPrimaryWindow: () => makeFakeWindow(captured),+ getAppVersion: () => '0.16.0-beta.1',+ isPackaged: true,+ clock: makeFakeClock(),+ now: () => new Date(),+ onDispatch: (k) => dispatches.push(k),+ logger: {+ info: mock(() => {}),+ warn: mock(() => {}),+ error: mock(() => {}),+ debug: mock(() => {}),+ },+ });+ return { captured, dispatches };+ };+ const first = boot();+ expect(first.dispatches).toContain('install-failed-on-boot' as DispatchKind);+ const second = boot();+ expect(second.captured.filter((c) => c.channel === 'ok:update:relaunch-failed')).toHaveLength(+ 1,+ );+ expect(second.dispatches).toContain('install-failed-on-boot' as DispatchKind);+ });++ test('attempted reached (running == attempted) → silently cleared, no failure notice', () => {+ const { rig } = makeRig({+ attemptedInstall: '0.16.0-beta.3',+ appVersion: '0.16.0-beta.3',+ });+ const failed = rig.captured.filter((c) => c.channel === 'ok:update:relaunch-failed');+ expect(failed).toHaveLength(0);+ expect(rig.state.attemptedInstall).toBeNull();+ expect(rig.dispatches).toContain('attempted-install-reconciled' as DispatchKind);+ expect(rig.dispatches).not.toContain('install-failed-on-boot' as DispatchKind);+ });++ test('attempted reached (running past attempted, stable over beta) → silently cleared', () => {+ const { rig } = makeRig({+ attemptedInstall: '0.16.0-beta.3',+ appVersion: '0.16.0',+ });+ expect(rig.captured.filter((c) => c.channel === 'ok:update:relaunch-failed')).toHaveLength(0);+ expect(rig.state.attemptedInstall).toBeNull();+ expect(rig.dispatches).toContain('attempted-install-reconciled' as DispatchKind);+ });++ test('no attemptedInstall → no-op (nothing to reconcile)', () => {+ const { rig } = makeRig({ attemptedInstall: null, appVersion: '0.16.0-beta.1' });+ expect(rig.captured.filter((c) => c.channel === 'ok:update:relaunch-failed')).toHaveLength(0);+ expect(rig.dispatches).not.toContain('install-failed-on-boot' as DispatchKind);+ expect(rig.dispatches).not.toContain('attempted-install-reconciled' as DispatchKind);+ });++ test('update-downloaded arms attemptedInstall alongside versionPendingInstall', () => {+ const { rig } = makeRig();+ rig.updater.emit('update-downloaded', { version: '0.16.0-beta.3' });+ expect(rig.state.versionPendingInstall).toBe('0.16.0-beta.3');+ expect(rig.state.attemptedInstall).toBe('0.16.0-beta.3');+ });++ test('persist failure on the failure branch → no broadcast, no dispatch', () => {+ const updater = new FakeUpdater();+ const ipc = makeFakeIpc();+ const clock = makeFakeClock();+ const captured: CapturedSend[] = [];+ const primaryWindow = makeFakeWindow(captured);+ const state: AppState = {+ ...emptyState(),+ lastSeenVersion: '0.16.0-beta.1',+ attemptedInstall: '0.16.0-beta.3',+ };+ const dispatches: DispatchKind[] = [];+ startAutoUpdater({+ updater,+ ipcMain: ipc,+ readState: () => state,+ writeState: () => {+ throw new Error('EACCES');+ },+ getPrimaryWindow: () => primaryWindow,+ getAppVersion: () => '0.16.0-beta.1',+ isPackaged: true,+ clock,+ now: () => new Date(),+ onDispatch: (k) => dispatches.push(k),+ logger: {+ info: mock(() => {}),+ warn: mock(() => {}),+ error: mock(() => {}),+ debug: mock(() => {}),+ },+ });+ expect(captured.filter((c) => c.channel === 'ok:update:relaunch-failed')).toHaveLength(0);+ expect(dispatches).not.toContain('install-failed-on-boot' as DispatchKind);+ expect(state.attemptedInstall).toBe('0.16.0-beta.3');+ });++ test('persist failure on the success branch → attemptedInstall stays armed, no dispatch', () => {+ const state: AppState = {+ ...emptyState(),+ lastSeenVersion: '0.16.0-beta.3',+ attemptedInstall: '0.16.0-beta.3',+ };+ const dispatches: DispatchKind[] = [];+ startAutoUpdater({+ updater: new FakeUpdater(),+ ipcMain: makeFakeIpc(),+ readState: () => state,+ writeState: () => {+ throw new Error('EACCES');+ },+ getPrimaryWindow: () => makeFakeWindow([]),+ getAppVersion: () => '0.16.0-beta.3',+ isPackaged: true,+ clock: makeFakeClock(),+ now: () => new Date(),+ onDispatch: (k) => dispatches.push(k),+ logger: {+ info: mock(() => {}),+ warn: mock(() => {}),+ error: mock(() => {}),+ debug: mock(() => {}),+ },+ });+ expect(state.attemptedInstall).toBe('0.16.0-beta.3');+ expect(dispatches).not.toContain('attempted-install-reconciled' as DispatchKind);+ });+});++describe('installReached (prerelease-aware compare)', () => {+ test('equal versions → true', () => {+ expect(installReached('0.16.0-beta.3', '0.16.0-beta.3')).toBe(true);+ expect(installReached('1.2.3', '1.2.3')).toBe(true);+ });+ test('same MMP, running beta is behind attempted beta → false (the PRD-7149 case)', () => {+ expect(installReached('0.16.0-beta.1', '0.16.0-beta.3')).toBe(false);+ expect(installReached('0.16.0-beta.2', '0.16.0-beta.10')).toBe(false);+ });+ test('same MMP, running beta is ahead → true', () => {+ expect(installReached('0.16.0-beta.5', '0.16.0-beta.3')).toBe(true);+ });+ test('stable outranks a prerelease of the same MMP', () => {+ expect(installReached('0.16.0', '0.16.0-beta.3')).toBe(true);+ expect(installReached('0.16.0-beta.3', '0.16.0')).toBe(false);+ });+ test('MMP dominates prerelease', () => {+ expect(installReached('0.17.0-beta.1', '0.16.0-beta.3')).toBe(true);+ expect(installReached('0.15.9', '0.16.0-beta.1')).toBe(false);+ expect(installReached('1.0.0', '0.16.0')).toBe(true);+ });+ test('unparseable input → true (conservative: assume success, never cry wolf)', () => {+ expect(installReached('garbage', '0.16.0-beta.3')).toBe(true);+ expect(installReached('0.16.0-beta.3', 'garbage')).toBe(true);+ });+ test('non-numeric prerelease identifiers compare in ASCII order', () => {+ expect(installReached('1.0.0-beta', '1.0.0-alpha')).toBe(true);+ expect(installReached('1.0.0-alpha', '1.0.0-beta')).toBe(false);+ });+ test('a numeric identifier ranks below a non-numeric one (semver §11.4.3)', () => {+ expect(installReached('1.0.0-alpha', '1.0.0-1')).toBe(true);+ expect(installReached('1.0.0-1', '1.0.0-alpha')).toBe(false);+ });+ test('length tie-break: more identifiers outrank fewer when all preceding are equal', () => {+ expect(installReached('1.0.0-beta.1', '1.0.0-beta')).toBe(true);+ expect(installReached('1.0.0-beta', '1.0.0-beta.1')).toBe(false);+ });+});+describe('versionAtLeast (MMP compare)', () => {test('equal versions → true', () => {expect(versionAtLeast('0.4.1', '0.4.1')).toBe(true);diff --git a/packages/desktop/tests/unit/state-store-m3-fields.test.ts b/packages/desktop/tests/unit/state-store-m3-fields.test.tsindex 42c895dda..21c869770 100644--- a/packages/desktop/tests/unit/state-store-m3-fields.test.ts+++ b/packages/desktop/tests/unit/state-store-m3-fields.test.ts@@ -29,6 +29,16 @@ describe('parseAppState M3 fields — coercion', () => {expect(parsed?.stuckHintShown).toBe(true);});+ test('attemptedInstall: round-trips a string, coerces non-string + absent to null', () => {+ expect(+ parseAppState({ recentProjects: [], attemptedInstall: '0.16.0-beta.3' })?.attemptedInstall,+ ).toBe('0.16.0-beta.3');+ expect(+ parseAppState({ recentProjects: [], attemptedInstall: 42 })?.attemptedInstall,+ ).toBeNull();+ expect(parseAppState({ recentProjects: [] })?.attemptedInstall).toBeNull();+ });+test('M1-forward-compat: pre-M3 blob without M3 keys returns valid state with defaults', () => {const raw = {recentProjects: [