diff --git a/changelog.d/maintenance/12554-electron-44.md b/changelog.d/maintenance/12554-electron-44.md new file mode 100644 index 0000000000..41b5e50f53 --- /dev/null +++ b/changelog.d/maintenance/12554-electron-44.md @@ -0,0 +1 @@ +- **chore(electron):** upgrade the desktop app to Electron 44 (Chromium 152, Node 24.18.1) ([#12217](https://github.com/diegosouzapw/OmniRoute/pull/12217)). **Requires macOS 13 (Ventura) or later** — Chromium dropped macOS 12 (Monterey), so Monterey users must stay on an earlier OmniRoute desktop build. Windows and Linux are unaffected; the app already shipped only x64/arm64, so Electron 44 dropping 32-bit builds changes nothing. Removes the `openAsHidden`/`wasOpenedAsHidden` login-item fields deleted in Electron 44 — hidden autostart continues to work through the `--hidden` argument registered with the login item ([#12554](https://github.com/diegosouzapw/OmniRoute/pull/12554)) diff --git a/electron/lib/windowLifecycle.js b/electron/lib/windowLifecycle.js index 8a75a4a18d..cea524ab37 100644 --- a/electron/lib/windowLifecycle.js +++ b/electron/lib/windowLifecycle.js @@ -1,11 +1,11 @@ /** Pure helpers for deciding and driving the Electron dashboard window lifecycle. */ -function shouldStartHidden({ argv = [], loginItemSettings = {} } = {}) { - return ( - argv.includes("--hidden") || - argv.includes("--minimized") || - loginItemSettings.wasOpenedAsHidden === true - ); +// Electron 44 removed `openAsHidden`/`wasOpenedAsHidden` from +// `app.set/getLoginItemSettings()` (they only ever worked on macOS 12 and below, which +// Electron 44 no longer supports). The hidden-autostart contract is now carried solely by +// the `--hidden` argument registered with the login item. +function shouldStartHidden({ argv = [] } = {}) { + return argv.includes("--hidden") || argv.includes("--minimized"); } function showOrCreateWindow({ appReady, getWindow, createWindow }) { diff --git a/electron/main.js b/electron/main.js index 19f232226b..2010fe5683 100644 --- a/electron/main.js +++ b/electron/main.js @@ -1113,7 +1113,6 @@ function setupIpcHandlers() { try { app.setLoginItemSettings({ openAtLogin: true, - openAsHidden: true, args: ["--hidden"], }); return true; @@ -1153,7 +1152,6 @@ app.whenReady().then(async () => { !isHeadless && shouldStartHidden({ argv: process.argv, - loginItemSettings: app.getLoginItemSettings(), }); keepAliveWithoutWindows = startHidden; diff --git a/tests/unit/electron-lazy-window.test.ts b/tests/unit/electron-lazy-window.test.ts index f9d3f97677..08515bd570 100644 --- a/tests/unit/electron-lazy-window.test.ts +++ b/tests/unit/electron-lazy-window.test.ts @@ -8,14 +8,31 @@ const require = createRequire(import.meta.url); const { shouldStartHidden, showOrCreateWindow } = require("../../electron/lib/windowLifecycle"); describe("Electron hidden-start window lifecycle", () => { - it("detects explicit hidden flags and OS login-item hidden launches", () => { + it("detects explicit hidden flags", () => { assert.equal(shouldStartHidden({ argv: ["electron", "--hidden"] }), true); assert.equal(shouldStartHidden({ argv: ["electron", "--minimized"] }), true); + assert.equal(shouldStartHidden({ argv: ["electron"] }), false); + assert.equal(shouldStartHidden(), false); + }); + + // Electron 44 removed `wasOpenedAsHidden` from `app.getLoginItemSettings()`, so a hidden + // autostart is signalled ONLY by the `--hidden` argument the login item registers. Guards + // against re-introducing a dependency on the removed field. + it("ignores login-item settings entirely", () => { assert.equal( shouldStartHidden({ argv: ["electron"], loginItemSettings: { wasOpenedAsHidden: true } }), + false + ); + assert.equal( + shouldStartHidden({ argv: ["electron", "--hidden"], loginItemSettings: {} }), true ); - assert.equal(shouldStartHidden({ argv: ["electron"], loginItemSettings: {} }), false); + }); + + it("keeps the --hidden argument registered with the login item", () => { + const mainJs = readFileSync(join(import.meta.dirname, "../../electron/main.js"), "utf8"); + assert.match(mainJs, /openAtLogin: true,\s*\n\s*args: \["--hidden"\],/); + assert.doesNotMatch(mainJs, /openAsHidden/); }); it("creates the dashboard only when an explicit open action has no live window", () => {