Skip to content

Commit 3122789

Browse files
committed
fix(macos): attach to a running app instead of launching a duplicate on open
A macOS app started directly — by a supervisor or a dev script — is not listed by LaunchServices until half a second or so after it spawns. During that window `open -b` sees no instance and starts a second copy with no arguments, which the session then drives instead of the copy the caller owns (#3406). The bundle open now reads the same view `open -b` consults and, when it lists nothing while a process of that bundle is running, waits until LaunchServices names the running copy before running `open` unchanged. An already-listed bundle and a bundle with nothing running reach `open` on the first read; the wait, every read, and the process scan share one budget, and anything the probe cannot answer fails open so an open is never withheld.
1 parent e8f24cd commit 3122789

5 files changed

Lines changed: 858 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
## Unreleased
44

5+
- Opening a macOS app by bundle identifier no longer starts a second copy of an app that is already running but not yet registered with LaunchServices, which happened when the app had been started directly by a supervisor or dev script. The open waits for the registration of the running copy — a bounded wait, and only while that copy is genuinely unlisted — and then attaches to it, so the session drives the app the caller started, with its arguments. Launching an app that is not running costs one extra process-table read and one bundle-identifier read.
56
- Limrun iOS snapshots no longer fail when the instance reports a numeric or boolean accessibility value (the system photo picker's tabs report `1`/`0`): the provider seam normalizes variant scalars to text, the way the Apple tree does. Limrun nodes now also publish `selected: true` for nodes carrying the `Selected` trait, so snapshot output and `selected:` selectors can tell a picked photo from an unpicked one.
67
- Carry provider keyboard facts through snapshots. Appium captures, including wait polls and fill pre-captures, add one sequential keyboard visibility probe with a 500 ms timeout. Probe results preserve tap-time docked-tree checks; unavailable probes leave visibility unknown.

‎packages/platform-apple/src/core/__tests__/tool-provider.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ test('local Apple tool provider exposes macOS host operations as semantic method
177177
const calls: Array<[string, string[], string | undefined]> = [];
178178
const provider = createLocalAppleToolProvider({
179179
runCommand: async (cmd, args, options) => {
180+
// The bundle open's LaunchServices registration probe is the seam's own read, asserted in
181+
// host-provider-open.test.ts; this routing test only reports it as listing the bundle.
182+
if (cmd === '/usr/bin/lsappinfo') {
183+
return { exitCode: 0, stdout: 'ASN:0x0-0x1234-"Demo":\n', stderr: '' };
184+
}
180185
calls.push([cmd, args, typeof options?.stdin === 'string' ? options.stdin : undefined]);
181186
if (cmd === 'pbpaste') {
182187
return { exitCode: 0, stdout: 'copied\r\n', stderr: '' };

0 commit comments

Comments
 (0)