macOS: open can start a second copy of an app that was just launched
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- cli, mobile-dev
Research direction
Start by tracing the macOS open command and its helper that selects an NSRunningApplication; the issue does not name their file paths or tests. Reproduce the quick relaunch case, then inspect how the command launches by bundle ID and how the helper chooses a process. Done means an already running app can be targeted without starting a duplicate or confusing two copies with the same bundle ID.
Written by the indexing model from the issue text.
Description
Summary
On macOS, agent-device open <bundleId> --platform macos can start a second copy of an app that is already running, then drive whichever copy NSRunningApplication.runningApplications(withBundleIdentifier:).first returns.
Repro
- Launch an app yourself (e.g. a dev build started by a supervisor process with custom launch arguments).
- Within ~0.5–0.75 s, run
agent-device open <bundleId> --platform macos. psshows two processes for the bundle: the original (with its arguments) and a new one with ppid 1 and no arguments.
Cause: open runs /usr/bin/open [-g] -b <bundleId> without first checking for a running instance. A process that was just spawned isn't listed by LaunchServices yet (lsappinfo lists it ~0.5–0.75 s later), so open -b launches a new copy. If you wait until lsappinfo find bundleid=<id> pid=<pid> returns the process, open attaches and only one copy remains (3/3 runs).
Proposal
- Before calling
open -b, check for a running instance of the bundle (NSRunningApplication orlsappinfo) and attach to it instead of launching. - Offer an explicit target, e.g.
--pid <pid>or an app path, so a caller that launched the app itself can attach to that exact process. - In the macOS helper, resolve the target by pid when one is known, rather than
.first, so two copies with the same bundle id can't be confused.
Context: Stim's stim macos launches dev builds this way; we're adding a LaunchServices wait on our side, but the attach behavior would make open safe for any caller.
- Dominant language
- TypeScript
- Stars
- 5k
- Forks
- 334
- Avg merge
- 12h 2m
- Merged PRs (30d)
- 678
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from callstack/agent-device
-
`devices` reports a phantom Android emulator named after the emulator's crashdata INFO bannerPossibly taken @airowe claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
callstack/agent-device#3716 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
callstack/agent-device#1869 ·
Maintainers usually reply within 1 day
-
backlog refactor
Difficulty 5/5 Over a week Newbie friendliness 8/100
callstack/agent-device#3759 ·
Maintainers usually reply within 1 day
-
backlog enhancement needs-triage
Difficulty 5/5 Over a week Newbie friendliness 8/100
callstack/agent-device#3758 ·
Maintainers usually reply within 1 day
-
enhancement ready-for-agent
Difficulty 5/5 Over a week Newbie friendliness 15/100
callstack/agent-device#3757 ·
Maintainers usually reply within 1 day
All issues in callstack/agent-device
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
agilepathway/label-checker#739 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
CopilotKit/OpenBot#800 ·
Maintainers usually reply within 1 day
-
Endpoint links in the tag operations list are below the 24px target sizePossibly taken @AdzerKI claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
ehmpathy/rhachet-roles-bhuild#471 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day