From e624c8a2966be074eac65e784ee6c5bcbf121e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Tak=C3=A1cs-Tolnai?= Date: Thu, 16 Apr 2026 22:05:14 +0200 Subject: [PATCH] fix(desktop): rebuild tray menu in place instead of recreating the Tray The old setupTray() called tray.destroy() before creating a new Tray. On Linux with KDE Plasma 6 Wayland, tray.destroy() does not actually remove the icon from plasmashell (electron/electron#49517), so the new Tray registers a fresh dbusmenu while plasmashell keeps talking to the orphaned one. Menu items still render (cached layout) but every com.canonical.dbusmenu.Event("clicked", ...) method call from plasmashell hits the destroyed handler and is dropped, so menu-item click callbacks stop firing after the frontend triggers a rebuild on login. Move the one-time Tray construction (icon, tooltip, click handler) behind a !tray guard and keep setContextMenu in the always-run path. The desktop:update-quick-entry-shortcut IPC handler keeps calling setupTray() and the accelerator label updates without touching the native Tray. --- desktop/main.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/desktop/main.js b/desktop/main.js index f86edb49d..da36e8d45 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -332,12 +332,20 @@ function toggleQuickEntry() { // ─── System tray ───────────────────────────────────────────────────── function setupTray() { - if (tray) { - tray.destroy() + if (!tray) { + const iconPath = path.join(__dirname, 'build', 'icon.png') + const icon = nativeImage.createFromPath(iconPath).resize({width: 16, height: 16}) + tray = new Tray(icon) + tray.setToolTip('Vikunja') + tray.on('click', () => { + if (mainWindow) { + mainWindow.show() + mainWindow.focus() + } else { + createMainWindow() + } + }) } - const iconPath = path.join(__dirname, 'build', 'icon.png') - const icon = nativeImage.createFromPath(iconPath).resize({width: 16, height: 16}) - tray = new Tray(icon) const contextMenu = Menu.buildFromTemplate([ { @@ -366,17 +374,7 @@ function setupTray() { }, ]) - tray.setToolTip('Vikunja') tray.setContextMenu(contextMenu) - - tray.on('click', () => { - if (mainWindow) { - mainWindow.show() - mainWindow.focus() - } else { - createMainWindow() - } - }) } // ─── IPC handlers ────────────────────────────────────────────────────