From 63d30720a88d31fd9d249efe36126ea0fa5ad0bf Mon Sep 17 00:00:00 2001 From: MasterAcnolo <68693319+MasterAcnolo@users.noreply.github.com> Date: Fri, 14 Aug 2026 22:11:56 +0200 Subject: [PATCH] fix(tray): dynamically create/destroy tray icon on setting toggle Previously, toggling the system tray in the settings updated the configuration but did not instantiate or destroy the tray immediately. This caused a desynchronization bug where the application could minimize to a non-existent tray, creating a ghost instance. The `set-feature` IPC handler now intercepts the `systemTray` key to apply the state at runtime before persisting the config. --- app/ipcHandlers.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/ipcHandlers.js b/app/ipcHandlers.js index c83dd24..2a0c0ac 100644 --- a/app/ipcHandlers.js +++ b/app/ipcHandlers.js @@ -18,6 +18,7 @@ const { getThemes, reloadThemes } = require("./themeManager"); const config = require("../config"); const { validateDownloadPath, getDefaultDownloadPath } = require("./pathValidator"); const { userThemesPath } = require("../server/helpers/path.helpers"); +const { createSystemTray, destroyTray } = require("./tray"); /** * Security whitelist for feature flags that can be modified at runtime. @@ -214,6 +215,21 @@ function registerIpcHandlers(getMainWindow) { return true; } + /** + * Dynamically intercepts and applies System Tray state changes at runtime. + * Instantiates or destroys the tray icon immediately to prevent window + * lifecycle desynchronization (e.g., minimizing a window to a non-existent tray). + */ + if (key === "systemTray") { + if (value === true) { + logger.info("System Tray enabled dynamically."); + createSystemTray(getMainWindow(), config.devMode); + } else { + logger.info("System Tray disabled dynamically."); + destroyTray(); + } + } + configFeatures[key] = value; fs.writeFileSync(