Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

macOS: drive a local app without activating it or moving the real pointer

オープン
#3,254 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@janicduplessis がすでに取り組んでいます。

2026年10月8日 から。

  • #3323 @janicduplessis による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
swift, typescript
領域
desktop, testing

調査の方向性

Start with buildMacOpenArgs in packages/platform-apple/src/os/macos/host-provider.ts, then read RunnerTests+Lifecycle.swift, RunnerTests+CommandExecution.swift, and MouseClickDelivery.swift for the activation and click paths. Check the related #3213 item 13 for window-field context. Done means the proposed opt-in foreground behavior, background interaction and app-window screenshot behavior are implemented and tested, with the remaining activation limits documented.

索引モデルが issue の本文から書いたものです。

説明

Problem

Driving a local macOS app with agent-device takes the app to the front and moves the user's real pointer, even when the app could be driven in the background. For an agent running on the user's own Mac this interrupts whatever the user is doing in another app. The opt-in native backend (AGENT_DEVICE_MACOS_APP_BACKEND=native, ADR 0031, #3213) already acts through accessibility actions without XCTest and without the "Automation Running" overlay, but open, the XCTest runner and the coordinate click path still bring the target app forward or use real pointer events. This issue is about those remaining activation points. It is related to #3213 (item 13, pointer events with window fields) and #3106 (non-activating observations), and does not replace either.

Measured behavior

Fixture: a small AppKit app launched in the background (it logs NSApp.isActive itself and the test records NSWorkspace.frontmostApplication). agent-device 0.21.12, with 0.21.20 checked for the points below.

  • agent-device open <bundleId> --platform macos activates the app: the fixture logged didBecomeActive active=true key=true and frontmostApplication changed from the previously front app to the fixture. The macOS open path runs open -b <bundleId> (buildMacOpenArgs in packages/platform-apple/src/os/macos/host-provider.ts), without -g.
  • Without the native backend, every macOS command goes through the XCTest runner, which shows the "Automation Running" overlay.
  • Intermittent AXError -25204 (cannotComplete) from AXUIElementCopyElementAtPosition on the first call after the app has been idle in the background. A retry succeeds.

Read from the source on main, not measured:

  • Runner: RunnerTests+Lifecycle.swift calls target.activate() unless the target is already .runningForeground, so each runner command on an inactive app activates it. screenshot with an app bundle id calls targetApp.activate() in RunnerTests+CommandExecution.swift.
  • Helper: MouseClickDelivery.swift posts clicks with CGEvent.post(tap: .cghidEventTap) at screen coordinates. That moves the real pointer, lands on whatever window is topmost at that point, and the system activates the clicked app. It is not delivered to the target process.

Related measurement from #3213: CGEventPostToPid with the window number set delivers clicks to a background app, while a bare post delivers nothing.

Proposal

  1. open: do not activate the app unless --foreground is passed (open -g, or NSWorkspace.OpenConfiguration.activates = false). An app that is already running is attached to, not raised. --foreground keeps today's behavior.
  2. Native backend: keep acting through accessibility actions (AXPress, AXSetValue, scroll) addressed by element ref. For raw coordinates and keys, use CGEvent.postToPid with the window fields from #3213 item 13 instead of .cghidEventTap. In my fixtures, postToPid with the window set delivered clicks on buttons, text fields and table rows, text, Backspace and Tab, Command shortcuts and scroll while the app was inactive. Clicks on views that reject the first mouse (custom views, SwiftUI onTapGesture) were dropped, so those need an explicit activation step (--foreground, or a focus command).
  3. XCTest runner on macOS: skip target.activate() unless --foreground.
  4. screenshot of an app: capture the target window (ScreenCaptureKit window capture) instead of activating the app first.
  5. Document the native backend variable and which commands can still activate the app.

Not in scope

Drags and WKWebView button clicks, which #3213 measured as needing the private focus-without-raise call.

主要言語
TypeScript
スター
4.9k
フォーク
328
平均マージ
12時間 13分
マージ済み PR(30日)
541

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

callstack/agent-device のほかの issue

callstack/agent-device の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。