Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#3,406 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
45/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
cli, mobile-dev

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
5k
Forks
334
Merge médio
12h 29min
PRs com merge (30d)
663

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de callstack/agent-device

Todas as issues de callstack/agent-device

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.