Repository navigation
Description
Aktar launches as a menu-bar-only app (LSUIElement = YES), which is what I want. Right after launch there is no Dock icon.
But after I click the menu bar icon a second time, the Dock icon appears. Closing windows with the X button does not remove it. The only way to get rid of it is to quit and relaunch Aktar, and it can come back.
There is also no setting anywhere in the app to keep the Dock icon hidden while Aktar is running.
Expected behavior
- Closing the last real window (Library, Settings, Welcome, QR Code, Request Files, Share) with the X button should return the app to menu-bar-only mode and hide the Dock icon.
- A preference such as Settings → General → "Show Dock icon" (or "Always hide Dock icon") so users can keep Aktar menu-bar-only while it runs, even when windows are open.
Steps to reproduce
- Launch Aktar. There is no Dock icon.
- Click the menu bar icon to open the panel, then click again to close it. Repeat once or twice.
- The Dock icon appears.
- Open Library or Settings, then close it with the X button.
- The Dock icon is still there.
Environment
- Mac: MacBook Pro, Apple M4 Pro
- macOS: 26.6.2
- Aktar: 0.21.0 (replace with the installed version if different)
- Install method: DMG / Homebrew (delete one)
Suspected cause (from reading the source, not yet confirmed by debugging)
The Dock icon is controlled only by two calls in Sources/Aktar/AppDelegate.swift:
windowDidBecomeKeycallsNSApp.setActivationPolicy(.regular), which shows the Dock icon, for any window whereisTrackedWindowis true.windowWillClosecallsNSApp.setActivationPolicy(.accessory), which hides it, but only if no other tracked window is still visible:
private func isTrackedWindow(_ window: NSWindow) -> Bool {
!(window is MenuBarPanel) && !(window is NSOpenPanel) && !(window is NSSavePanel)
}let hasOtherTrackedWindows = NSApp.windows.contains { candidate in
candidate !== closingWindow && candidate.isVisible && self.isTrackedWindow(candidate)
}
if !hasOtherTrackedWindows {
NSApp.setActivationPolicy(.accessory)
}isTrackedWindow is a deny-list: every window that is not MenuBarPanel, NSOpenPanel or NSSavePanel counts as an app window. That likely includes windows that are not user-facing, for example:
- the status item's own
NSStatusBarWindow, which is always visible - SwiftUI or AppKit helper windows
Two consequences:
- Icon appears on menu bar interaction. If one of those windows becomes key when the menu bar icon is clicked,
windowDidBecomeKeypromotes the app to.regular. This matches the icon appearing after clicking the menu bar icon, without opening any real window. - Icon never goes away. If one of those windows stays visible,
hasOtherTrackedWindowsis alwaystrue, so the app never goes back to.accessory.
Other paths where the icon can get stuck
- Minimize or hide. Minimizing a window (yellow button) or hiding the app (⌘H) sends no close notification, so nothing demotes the app.
- Hand-built windows.
RequestFilesView.swift,QRCodeView.swiftandShareDestinationView.swiftcreate plainNSWindowinstances that go through the same track-and-demote logic, so they share the same problem. - Race on close. The demotion check runs in
DispatchQueue.main.asyncafter the close notification and reads window state at that moment, which is fragile.
How to confirm
Log the windows at the moment the Dock icon appears, and again after closing a window:
NSApp.windows.forEach {
print(type(of: $0), $0.title, $0.isVisible, $0.identifier?.rawValue ?? "-")
}Suggested fix
- Use an allow-list instead of a deny-list. Only treat Aktar's own windows (
library,settings,onboarding, and the QR Code, Request Files and Share windows) as windows that justify showing the Dock icon, for example by checking the window identifier or title. Never countNSStatusBarWindowor other system or helper windows. - Re-evaluate on more events. Also handle minimize (
didMiniaturizeNotification) and app hide, not only close. - Add a preference, such as "Show Dock icon" (on or off), stored in
UserDefaults. When off, never callsetActivationPolicy(.regular). The tradeoff is that Aktar will not appear in ⌘-Tab while windows are open, which is why this should be a choice and not forced.
Additional context
Aktar is otherwise great as a menu bar tool. The Dock icon getting stuck defeats the point of a menu-bar-only app, and the only workaround is quitting and relaunching.
Activity