chore(electron): drop openAsHidden/wasOpenedAsHidden, removed in Electron 44 (#12554)

CI verde: 18 checks passando (4 shards de unit, Vitest, CodeQL, Fast Quality Gates, No new ESLint warnings, semgrep). Local: 8/8 no teste atualizado e 165/165 nos 16 arquivos tests/unit/electron-*.test.ts.
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-09-03 08:32:22 -03:00
committed by GitHub
parent e2e330a058
commit 7d0b264eda
4 changed files with 26 additions and 10 deletions

View File

@@ -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))

View File

@@ -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 }) {

View File

@@ -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;

View File

@@ -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", () => {