Skip to content

fix: bring window to front when opening .md file via Finder on macOS#213

Merged
LarryZhu-dev merged 1 commit intoAuto-Plugin:mainfrom
dongyccc:fix/macos-open-file-window-focus
May 6, 2026
Merged

fix: bring window to front when opening .md file via Finder on macOS#213
LarryZhu-dev merged 1 commit intoAuto-Plugin:mainfrom
dongyccc:fix/macos-open-file-window-focus

Conversation

@dongyccc
Copy link
Copy Markdown
Contributor

@dongyccc dongyccc commented May 3, 2026

Summary

Fixed a bug where double-clicking a .md file in Finder on macOS loads the file content silently without bringing the milkup window to the foreground. Users have to manually click the app icon in the Dock to see the window.

Root Cause

The open-file event handler (src/main/index.ts:292) calls sendFileToRenderer() which sends file data to the renderer via IPC, but never calls focus() / show() / restore() on the window.

In contrast, the second-instance handler (line 280) and activate handler (line 320) both correctly activate the window before processing.

Fix

Added 3 lines in sendFileToRenderer's sendFile closure to mirror the window activation logic already present in second-instance:

if (targetWin.isMinimized()) targetWin.restore();
if (!targetWin.isVisible()) targetWin.show();
targetWin.focus();

Affected Scenarios

Scenario Before After
Cold launch (double-click .md, app not running) Window may stay behind ✅ Window comes to front
App running, window hidden (red close button on macOS) Content loaded, window stays hidden ✅ Window shown + focused
App running, window minimized Content loaded, stays minimized ✅ Window restored + focused
App in foreground, double-click another .md Works fine ✅ No change

Tested

  • macOS arm64 (Apple Silicon) with macOS 26
  • Built and installed locally, verified fix resolves the issue

The `open-file` event handler sent file data to the renderer via IPC
but never called focus()/show()/restore() on the window. This caused
double-clicking a .md file in Finder to load the file content silently
without bringing the app window to the foreground.

Fixed by adding window activation calls in sendFileToRenderer's sendFile
closure, aligning with the existing second-instance handler behavior.
@LarryZhu-dev
Copy link
Copy Markdown
Contributor

@dongyccc 感谢贡献

@LarryZhu-dev LarryZhu-dev merged commit 3e0ff0a into Auto-Plugin:main May 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

🎉 Thank you for your contribution! If you have not yet joined our community group, please feel free to join us (when joining, please provide the link to this PR).

🎉 感谢您的贡献!如果您对此项目非常感兴趣,请扫描下方二维码加入我们(加群时请提供此 PR 链接)。

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.

2 participants