Files
Netcatty/electron/bridges/systemTheme.cjs
T
陈大猫andHHXXYY123 2e3dc687cb fix(theme): continue Windows system-theme fix with registrar coverage (#4108)
* fix(theme): broadcast native system theme updates to renderers

nativeTheme.updated only fires for listeners in the main process, so a renderer sitting in system mode never learned that Windows changed the application theme. Forward the resolved preference to every window and let the settings hook re-apply it.

* fix(theme): keep terminal chrome separate from native system policy

refreshActiveChromeThemeSurfaces called setTheme(light|dark), which the main process writes into nativeTheme.themeSource. The stored preference stayed 'system' while Electron was pinned to a fixed color, so Windows application theme changes were ignored.

Only paint the surfaces here. Also re-assert a fixed independent terminal theme when the OS preference changes: the fingerprint short-circuit skipped the refresh, and the hook effect never re-ran while the terminal props stayed stable.

* test(theme): bound the new jsdom chrome tests

A hanging jsdom/React render should fail the test with its name instead of consuming the CI job budget.

* test(theme): provide native theme in bridge registrar fixtures

* test(theme): provide nativeTheme in child-process registrar fixture

The worker tests introduced in #4127 omitted nativeTheme after the system-theme listener registration became part of the production registrar. Provide a real EventEmitter, matching the transfer-limit fixture, so registrar setup succeeds without weakening production behavior.

* ci: retrigger lint-and-test after runner shutdown

The previous ubuntu-latest lint-and-test run was canceled during plugin
contract verification (annotation: "The operation was canceled."). Lint
had already passed; tests never started. Tree is unchanged.

---------

Co-authored-by: HHXXYY123 <117068187+HHXXYY123@users.noreply.github.com>
2026-11-05 23:13:41 +08:00

17 lines
615 B
JavaScript

"use strict";
// Keep system-theme delivery independent of optional plugin menu contributions.
function registerSystemThemeListener({ nativeTheme, getWindows }) {
const onUpdated = () => {
const payload = { isDark: nativeTheme.shouldUseDarkColors === true };
for (const win of getWindows()) {
if (win.isDestroyed() || win.webContents.isDestroyed()) continue;
win.webContents.send("netcatty:system-theme-changed", payload);
}
};
nativeTheme.on("updated", onUpdated);
return () => nativeTheme.removeListener("updated", onUpdated);
}
module.exports = { registerSystemThemeListener };