Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

macOS: open can start a second copy of an app that was just launched

未关闭
#3,406 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
cli, mobile-dev

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

bug ready-for-agent

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

  1. Launch an app yourself (e.g. a dev build started by a supervisor process with custom launch arguments).
  2. Within ~0.5–0.75 s, run agent-device open <bundleId> --platform macos.
  3. ps shows 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 or lsappinfo) 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.

主要语言
TypeScript
星标
5k
派生
334
平均合并
12 小时 2 分钟
30 天内合并 PR
706

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

callstack/agent-device 的其他 Issue

查看 callstack/agent-device 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。