macOS: Finder file-open silently lost when a second app copy launches (single-instance forwards argv only)
Describe the bug
On macOS, double-clicking a markdown file can silently do nothing — no window, no error — when a second copy of Markpad ends up launching while another copy is already running. The file-open event is lost entirely.
This happens whenever two copies of the app exist (e.g. the user once ran Markpad straight from the DMG or ~/Downloads, and also has a copy in /Applications) — or in any dev/test setup running a locally built bundle alongside the installed one.
Mechanism
macOS delivers Finder file-opens as an Apple Event (odoc) — the file path is never in argv. The sequence that eats it:
- LaunchServices resolves the
.mdhandler to a specific bundle path (say/Applications/Markpad.app). The running copy has a different bundle path, so LS considers the handler "not running" and launches a new process, addressing the Apple Event to it. - The new process starts and
tauri-plugin-single-instanceruns immediately: it detects the primary instance (same bundle identifier), forwards its argv — which contains no file path on macOS — and exits. - The Apple Event arrives for a process that is already dead. It is dropped; the primary instance only gets an argv-only ping (it focuses the window, opens nothing).
Single Instance Args: ["/Applications/Markpad.app/Contents/MacOS/Markpad"] in the logs confirms the forwarded argv carries no file.
To Reproduce
- Have two copies of Markpad (e.g. one in
/Applications, one anywhere else) sharing the bundle id. - Launch copy B and leave it running.
- Double-click any
.mdfile in Finder (LS targets copy A). - Copy A flashes into existence, forwards, exits; the file never opens anywhere.
Expected behavior
The file opens in the running instance (or the second instance keeps ownership long enough to receive and forward the actual file paths).
Suggested fix
In the single-instance handling on macOS, don't exit before the open-documents Apple Event has been received: capture the opened paths (Tauri's RunEvent::Opened) and forward those to the primary instance instead of raw argv — or delay the exit until the first event-loop turn so Opened can fire. (Upstream, this is arguably a tauri-plugin-single-instance limitation: argv-forwarding is complete on Windows/Linux but loses Finder opens on macOS.)
Device
- OS: macOS (Darwin 25.x)
- App Version: v2.6.11 (also reproduced against current master builds)
🤖 Generated with Claude Code
The direct multi-document part is now separately tracked by #299 / #300: current source ignored every RunEvent::Opened URL after the first. #300 preserves and opens all paths, but it does not resolve the separate second-copy tauri-plugin-single-instance Apple Event loss described here.
Closing this issue as part of the current triage. The directly actionable multi-document open-event regression was addressed by #300. The separate second-copy Apple Event behavior depends on the single-instance handoff and can be reopened or filed again with fresh reproduction data if it remains reproducible.