Skip to content

fix: honor hide-from-dock when launching at login without window (#396)#398

Open
postoso wants to merge 1 commit into
altic-dev:mainfrom
postoso:fix/396-hide-dock-login
Open

fix: honor hide-from-dock when launching at login without window (#396)#398
postoso wants to merge 1 commit into
altic-dev:mainfrom
postoso:fix/396-hide-dock-login

Conversation

@postoso

@postoso postoso commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #396.

Edge case in the login-launch feature from #379. With "Launch at startup" on, "Show window when launched at login" off, and "Hide from dock" on, 1.6.0 launches silently at login but the Dock icon still shows even though hide-from-dock is enabled. The window is correctly hidden, so the lone Dock icon is the only visible symptom.

Root cause

On login launches the SwiftUI main window often is not ready during the early reveal retries in openMainWindowOnLaunch, so it falls back to a LaunchServices reopen (NSWorkspace.openApplication) to create it. Because the app bundle ships LSUIElement=false, that reopen restores the bundle default activation policy (.regular) even when reopened with activates=false. Hide-from-dock is applied at runtime via setActivationPolicy(.accessory), and nothing re-applies it after the reopen, so the Dock icon comes back.

I confirmed the reopen behavior with a small standalone AppKit probe: an LSUIElement=false bundle set .accessory, reopened itself with activates=false, and came back as .regular. Re-asserting .accessory in the reopen completion put it back and it stuck. Ordering the window front (orderFrontRegardless) and NSApp.activate on their own did not change the policy.

Fix

Re-apply the configured activation policy (showInDock ? .regular : .accessory) in the reopen completion handler so the setting is honored on login launches. The completion runs off the main thread, so the policy update hops back to main before touching NSApp. The existing policy call is factored into a small applyDockVisibilityPolicy() helper and reused. This also covers login + show-window, which can hit the same reopen fallback.

Testing

  • swiftlint --strict --config .swiftlint.yml: 0 violations
  • xcodebuild build -project Fluid.xcodeproj -scheme Fluid -destination 'platform=macOS,arch=arm64': BUILD SUCCEEDED

I could not reproduce a real login-item launch end to end since it only happens at actual login. On-device check: set launch-at-startup on, show-at-login off, hide-from-dock on, reboot, log in, confirm no Dock icon. The FLUID_SIMULATE_LOGIN_LAUNCH=1 hook from #379 exercises the same branch.

No regression test: the failure lives in LaunchServices reopen plus process-activation glue with no clean unit-testable seam in the current test target. A showInDock to policy mapping test would only assert a one-line ternary that was never the broken part, so it would not catch this.

…ic-dev#396)

On login launches the SwiftUI main window is often not ready during the
early reveal retries, so openMainWindowOnLaunch falls back to a
LaunchServices reopen (NSWorkspace.openApplication) to create it. On a
bundled app with LSUIElement=false, that reopen restores the bundle
default activation policy (.regular) even when reopened without
activation, so the Dock icon comes back even though the user enabled
"Hide from dock". The window stays hidden, so the only visible symptom is
the unexpected Dock icon.

Re-apply the configured activation policy (showInDock ? .regular :
.accessory) in the reopen completion so the setting is honored on login
launches. The completion runs off the main thread, so the policy update
hops back to main before touching NSApp. The existing line-145 policy
call is factored into applyDockVisibilityPolicy() and reused.

Edge case in the altic-dev#379 login-launch feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐞 BUG] "Hide from dock" not working when "Show window when launched at login" is disabled

1 participant