Skip to content
This repository was archived by the owner on Mar 25, 2026. It is now read-only.

Commit 3961e3d

Browse files
authored
Handle unsupported macOS versions better (#2552)
1 parent b0a3b9e commit 3961e3d

6 files changed

Lines changed: 57 additions & 7 deletions

File tree

src/electron-main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ app.on("ready", async () => {
424424
if (argv["update"] === false) {
425425
console.log("Auto update disabled via command line flag");
426426
} else if (global.vectorConfig["update_base_url"]) {
427-
console.log(`Starting auto update with base URL: ${global.vectorConfig["update_base_url"]}`);
428427
void updater.start(global.vectorConfig["update_base_url"]);
429428
} else {
430429
console.log("No update_base_url is defined: auto update is disabled");

src/i18n/strings/en_EN.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
"speech_start_speaking": "Start Speaking",
3333
"speech_stop_speaking": "Stop Speaking"
3434
},
35+
"eol": {
36+
"no_more_updates": "You are running an unsupported version of macOS. Please upgrade to receive %(brand)s updates.",
37+
"title": "System unsupported",
38+
"warning": "You are running an unsupported version of macOS. Please upgrade to ensure %(brand)s keeps working."
39+
},
3540
"file_menu": {
3641
"label": "File"
3742
},

src/ipc.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,10 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) {
218218
});
219219

220220
ipcMain.handle("getConfig", () => global.vectorConfig);
221+
222+
const initialisePromiseWithResolvers = Promise.withResolvers<void>();
223+
export const initialisePromise = initialisePromiseWithResolvers.promise;
224+
225+
ipcMain.once("initialise", () => {
226+
initialisePromiseWithResolvers.resolve();
227+
});

src/preload.cts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ contextBridge.exposeInMainWorld("electron", {
6060
*/
6161
supportsBadgeOverlay: boolean;
6262
}> {
63+
ipcRenderer.emit("initialise");
6364
const [{ protocol, sessionId }, config, supportedSettings] = await Promise.all([
6465
ipcRenderer.invoke("getProtocol"),
6566
ipcRenderer.invoke("getConfig"),

src/updater.ts

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ Please see LICENSE files in the repository root for full details.
77

88
import { app, autoUpdater, ipcMain } from "electron";
99
import fs from "node:fs/promises";
10+
import os from "node:os";
1011

1112
import { getSquirrelExecutable } from "./squirrelhooks.js";
13+
import { _t } from "./language-helper.js";
14+
import { initialisePromise } from "./ipc.js";
1215

1316
const UPDATE_POLL_INTERVAL_MS = 60 * 60 * 1000;
1417
const INITIAL_UPDATE_DELAY_MS = 30 * 1000;
@@ -69,7 +72,8 @@ async function pollForUpdates(): Promise<void> {
6972
}
7073

7174
export async function start(updateBaseUrl: string): Promise<void> {
72-
if (!(await available(updateBaseUrl))) return;
75+
if (!(await available())) return;
76+
console.log(`Starting auto update with base URL: ${updateBaseUrl}`);
7377
if (!updateBaseUrl.endsWith("/")) {
7478
updateBaseUrl = updateBaseUrl + "/";
7579
}
@@ -111,24 +115,58 @@ export async function start(updateBaseUrl: string): Promise<void> {
111115
}
112116
}
113117

114-
async function available(updateBaseUrl?: string): Promise<boolean> {
118+
/**
119+
* Check if auto update is available on this platform.
120+
* Has a side effect of firing showToast on EOL platforms so must only be called once!
121+
* @returns True if auto update is available
122+
*/
123+
async function available(): Promise<boolean> {
115124
if (process.platform === "linux") {
116125
// Auto update is not supported on Linux
117-
console.log("Auto update not supported on this platform");
126+
console.warn("Auto update not supported on this platform");
118127
return false;
119128
}
120129

121130
if (process.platform === "win32") {
122131
try {
123132
await fs.access(getSquirrelExecutable());
124133
} catch {
125-
console.log("Squirrel not found, auto update not supported");
134+
console.warn("Squirrel not found, auto update not supported");
126135
return false;
127136
}
128137
}
129138

130139
// Otherwise we're either on macOS or Windows with Squirrel
131-
return !!updateBaseUrl;
140+
if (process.platform === "darwin") {
141+
// OS release returns the Darwin kernel version, not the macOS version, see
142+
// https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history to interpret it
143+
const release = os.release();
144+
const major = parseInt(release.split(".")[0], 10);
145+
146+
if (major < 21) {
147+
// If the macOS version is too old for modern Electron support then disable auto update to prevent the app updating and bricking itself.
148+
// The oldest macOS version supported by Chromium/Electron 38 is Monterey (12.x) which started with Darwin 21.0
149+
initialisePromise.then(() => {
150+
ipcMain.emit("showToast", {
151+
title: _t("eol|title"),
152+
description: _t("eol|no_more_updates", { brand: global.trayConfig.brand }),
153+
});
154+
});
155+
console.warn("Auto update not supported, macOS version too old");
156+
return false;
157+
} else if (major < 22) {
158+
// If the macOS version is EOL then show a warning message.
159+
// The oldest macOS version still supported by Apple is Ventura (13.x) which started with Darwin 22.0
160+
initialisePromise.then(() => {
161+
ipcMain.emit("showToast", {
162+
title: _t("eol|title"),
163+
description: _t("eol|warning", { brand: global.trayConfig.brand }),
164+
});
165+
});
166+
}
167+
}
168+
169+
return true;
132170
}
133171

134172
ipcMain.on("install_update", installUpdate);

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"rootDir": "./src",
1212
"declaration": true,
1313
"typeRoots": ["src/@types", "node_modules/@types"],
14-
"lib": ["es2022"],
14+
"lib": ["es2022", "es2024.promise"],
1515
"types": ["node"],
1616
"strict": true
1717
},

0 commit comments

Comments
 (0)