diff --git a/apps/desktop/build/trayTemplate.png b/apps/desktop/build/trayTemplate.png new file mode 100644 index 00000000..3b86d3d5 Binary files /dev/null and b/apps/desktop/build/trayTemplate.png differ diff --git a/apps/desktop/build/trayTemplate@2x.png b/apps/desktop/build/trayTemplate@2x.png new file mode 100644 index 00000000..dfb64239 Binary files /dev/null and b/apps/desktop/build/trayTemplate@2x.png differ diff --git a/apps/desktop/electron-builder.json5 b/apps/desktop/electron-builder.json5 index 2acbbfbe..753424e2 100644 --- a/apps/desktop/electron-builder.json5 +++ b/apps/desktop/electron-builder.json5 @@ -10,6 +10,7 @@ }, "files": [ "out", + "build/trayTemplate*.png", "!**/.vscode/*", "!src/*", "!electron.vite.config.{js,ts,mjs,cjs}", diff --git a/apps/desktop/src/main/tray.ts b/apps/desktop/src/main/tray.ts index a0e2d47b..90436ce2 100644 --- a/apps/desktop/src/main/tray.ts +++ b/apps/desktop/src/main/tray.ts @@ -18,20 +18,15 @@ let statusInterval: ReturnType | null = null export function createTray(window: BrowserWindow): void { mainWindowRef = window - const iconPath = path.join(process.env.APP_ROOT!, 'build', 'icon.png') + // Use dedicated tray icon (asterisk shape matching MulticaIcon). + // On macOS, Electron auto-picks trayTemplate.png / trayTemplate@2x.png + // and treats "Template" suffix as a template image (adapts to dark/light menu bar). + const iconPath = path.join(process.env.APP_ROOT!, 'build', 'trayTemplate.png') const icon = nativeImage.createFromPath(iconPath) - const trayIcon = icon.resize({ width: 16, height: 16 }) - if (process.platform === 'darwin') { - trayIcon.setTemplateImage(true) - } - - tray = new Tray(trayIcon) + tray = new Tray(icon) tray.setToolTip('Multica') - // Click to toggle window visibility - tray.on('click', toggleWindowVisibility) - // Initial menu updateTrayMenu() @@ -54,15 +49,10 @@ export function destroyTray(): void { mainWindowRef = null } -function toggleWindowVisibility(): void { +function showMainWindow(): void { if (!mainWindowRef || mainWindowRef.isDestroyed()) return - - if (mainWindowRef.isVisible()) { - mainWindowRef.hide() - } else { - mainWindowRef.show() - mainWindowRef.focus() - } + mainWindowRef.show() + mainWindowRef.focus() } function updateTrayMenu(): void { @@ -90,15 +80,13 @@ function updateTrayMenu(): void { tray.setToolTip(`Multica - Agent: ${agentStatus}`) - const windowVisible = mainWindowRef && !mainWindowRef.isDestroyed() && mainWindowRef.isVisible() - const menu = Menu.buildFromTemplate([ { label: `Agent: ${agentStatus}`, enabled: false }, { label: `Hub: ${hubStatus}`, enabled: false }, { type: 'separator' }, { - label: windowVisible ? 'Hide Window' : 'Show Window', - click: toggleWindowVisibility, + label: 'Show Main Window', + click: showMainWindow, }, { type: 'separator' }, {