Skip to content

fix(macos): show window when dock icon clicked with StartHidden:true#5252

Draft
leaanthony wants to merge 1 commit intomasterfrom
v2-bugfix/4583-dock-icon-show-starthidden
Draft

fix(macos): show window when dock icon clicked with StartHidden:true#5252
leaanthony wants to merge 1 commit intomasterfrom
v2-bugfix/4583-dock-icon-show-starthidden

Conversation

@leaanthony
Copy link
Copy Markdown
Member

Description

Fixes #4583

When StartHidden: true is set in a Wails v2 app, the window is never ordered in via makeKeyAndOrderFront: during applicationWillFinishLaunching:. macOS's default applicationShouldHandleReopen:hasVisibleWindows: behavior does not surface windows that were never shown, so clicking the dock icon does nothing.

Root Cause

The AppDelegate class did not implement applicationShouldHandleReopen:hasVisibleWindows:. When a window was hidden via StartHidden: true (never shown), clicking the dock icon had no effect because macOS only restores windows that were previously visible.

This is inconsistent with runtime.Hide() followed by a dock click, which works because the window was shown at least once before being hidden with orderOut:.

Changes

  • Added applicationShouldHandleReopen:hasVisibleWindows: to AppDelegate.m
  • When hasVisibleWindows is NO (no visible windows), calls makeKeyAndOrderFront: to show the main window
  • Returns YES to let macOS also perform its default activation behavior

Testing

  • Added test in v2/test/4583/dock_icon_test.go verifying:
    • The method is present in AppDelegate.m with the correct selector
    • It calls makeKeyAndOrderFront: to show the window
    • Logic verification for both visible/non-visible window states

Note: This fix needs testing on macOS to verify the dock click behavior works as expected.

When StartHidden:true is set, the window is never ordered in via
makeKeyAndOrderFront:. macOS's default applicationShouldHandleReopen:
behavior does not surface windows that were never shown. Adding an
explicit handler that calls makeKeyAndOrderFront: when there are no
visible windows fixes this, matching the behavior of runtime.Hide()
followed by a dock click.

Fixes #4583
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5377dc68-13f2-476f-90ce-3a55faff9fed

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v2-bugfix/4583-dock-icon-show-starthidden

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant