Repository navigation
fix(macos): open a running app by its own path instead of its bundle id - #3889
Conversation
open -b opens the copy LaunchServices resolves the bundle id to. When several builds of one bundle are registered, such as successive dev builds at different paths, that can be a stale build that is not running, so the open launched it with no arguments beside the running copy the caller owns. The bundle open now finds the one running copy LaunchServices lists and opens its own path, or hands a link to it with open -a. With no running copy, an unlisted copy after the wait, or copies running from more than one path, the open keeps open -b.
A relative or dash-led argv[0] names no bundle on this host, so such a copy leaves the open to open -b. Trims the comments the change added.
There was a problem hiding this comment.
🔵 Needs a closer look
The supplied evidence does not establish completed current-head coverage and native smoke validation for the macOS launch behavior.
No open issues 🎉
What changed in this PR
This PR addresses the macOS duplicate-launch issue by opening an eligible running app at its own bundle path instead of letting LaunchServices select a potentially stale registered build.
Changes:
- Resolve a unique running bundle path while preserving the bounded registration wait and bundle-ID fallback.
- Use path-based opening for both app activation and link delivery.
- Update regression tests and command documentation.
| File | Description |
|---|---|
| website/docs/docs/commands.md | Documents path-based attachment and fallback cases. |
| packages/platform-apple/src/os/macos/launch-services-registration.ts | Resolves running bundle paths with case-insensitive ID matching and absolute-path validation. |
| packages/platform-apple/src/os/macos/launch-services-registration.test.ts | Covers path selection, link delivery, and fallback behavior. |
| packages/platform-apple/src/os/macos/host-provider.ts | Opens the resolved app path when available. |
| packages/platform-apple/src/core/__tests__/tool-provider.test.ts | Updates the host mock for the process-table probe. |
Review effort: Balanced
|
This PR is ready. I reviewed 583b866 and found nothing that needs to change before merge. All 17 checks pass, and the unit tests and the tool-provider test cover the macOS Not blocking, and you can take or leave these: I did not run the tests myself. I could not read 3b17a4b73, so the live macOS stale-build run is your report and I did not repeat it. I also did not check |
Summary
open <bundleId> --platform macoscould start a second, argument-less copy of a running app.open -bopens the registered copy LaunchServices resolves the bundle id to. When an earlier build of the bundle is still registered at another path, such as a previous dev build,open -blaunched that stale copy beside the running one, and the session drove it.When exactly one listed copy runs, the open now runs
open [-g] <its path>(-a <path> <url>for a link). It keepsopen -bwhen:macAppBundlePathis the only producer of the path).5 files, including
website/docs/docs/commands.md. Related: #3406.Validation
Head
583b866df, basec8b944ca0.pnpm check:affected --base upstream/main --head 583b866df --run: all runnable checks passed,exactCommit: true. (One earlier run hit load timeouts in unrelated provider-integration files; rerun clean.) Coverage and macOS smoke run on GitHub.3b17a4b73, macOS 27, a running app at path B with an older build registered at path A:openand for a copy spawned directly and opened 0 to 3 s later.3b17a4b73.psand oneplutilread, inside the 2.5 s probe budget.