From 89c83efc4f2443b67ff5bc7fc311038c533d2dd2 Mon Sep 17 00:00:00 2001 From: caost <12491051+caost@users.noreply.github.com> Date: Fri, 31 Jul 2026 15:39:04 +0900 Subject: [PATCH] Fix: macOS tray manager showed a Dock icon The tray manager creates the shared NSApplication so that pystray can attach its status item to it, but it never sets an activation policy. The default is NSApplicationActivationPolicyRegular, which makes the process a regular app: a Python icon appears in the Dock and in the app switcher even though the tray manager has no windows. Set NSApplicationActivationPolicyAccessory instead, which is the policy intended for menu-bar-only agents. Only the status item remains visible. Co-Authored-By: Claude Opus 5 (1M context) --- CHANGELOG.md | 2 ++ src/serena/dashboard.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ee9de6f..53712e8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ Status of the `main` branch. Changes prior to the next official version change w * Dashboard: - Fix: Serena PyPI version check triggered by callback on main thread could delay agent startup #1774 + - Fix: on macOS, the `tray_manager` interface put an icon in the Dock and in the app switcher + (should only use menu bar icon) * Hooks: - Add `serena-hooks --client=grok`, including Grok-native PreToolUse allow/deny output. diff --git a/src/serena/dashboard.py b/src/serena/dashboard.py index 852d0c1b..c9873608 100644 --- a/src/serena/dashboard.py +++ b/src/serena/dashboard.py @@ -1195,9 +1195,12 @@ class SerenaDashboardTrayManager: # set up tray icon with a dynamic menu (callable returns items on each open) kwargs: dict[str, Any] = {} if sys.platform == "darwin": - from AppKit import NSApplication + from AppKit import NSApplication, NSApplicationActivationPolicyAccessory - kwargs["darwin_nsapplication"] = NSApplication.sharedApplication() + nsapp = NSApplication.sharedApplication() + # run as an accessory app so that only the menu bar icon is shown (no Dock icon) + nsapp.setActivationPolicy_(NSApplicationActivationPolicyAccessory) + kwargs["darwin_nsapplication"] = nsapp self._tray_icon = pystray.Icon( "serena_tray_manager",