macOS: drive a local app without activating it or moving the real pointer
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- swift, typescript
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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 macosactivates the app: the fixture loggeddidBecomeActive active=true key=trueandfrontmostApplicationchanged from the previously front app to the fixture. The macOS open path runsopen -b <bundleId>(buildMacOpenArgsinpackages/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) fromAXUIElementCopyElementAtPositionon 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.swiftcallstarget.activate()unless the target is already.runningForeground, so each runner command on an inactive app activates it.screenshotwith an app bundle id callstargetApp.activate()inRunnerTests+CommandExecution.swift. - Helper:
MouseClickDelivery.swiftposts clicks withCGEvent.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
open: do not activate the app unless--foregroundis passed (open -g, orNSWorkspace.OpenConfiguration.activates = false). An app that is already running is attached to, not raised.--foregroundkeeps today's behavior.- Native backend: keep acting through accessibility actions (
AXPress,AXSetValue, scroll) addressed by element ref. For raw coordinates and keys, useCGEvent.postToPidwith the window fields from #3213 item 13 instead of.cghidEventTap. In my fixtures,postToPidwith 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, SwiftUIonTapGesture) were dropped, so those need an explicit activation step (--foreground, or afocuscommand). - XCTest runner on macOS: skip
target.activate()unless--foreground. screenshotof an app: capture the target window (ScreenCaptureKit window capture) instead of activating the app first.- 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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 4.9k
- Forks
- 328
- Merge medio
- 12 h 13 min
- PR fusionados (30 d)
- 541
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de callstack/agent-device
-
settings clear-app-state fails with ENOENT … scandir '(null)' for iOS system apps such as SettingsPosiblemente ocupada @thymikee la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
callstack/agent-device#3305 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
callstack/agent-device#1869 ·
Los mantenedores suelen responder en 1 día
-
install and reinstall from another session in the same daemon replace the app on a claimed deviceAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
callstack/agent-device#3345 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
callstack/agent-device#3344 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
callstack/agent-device#3342 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de callstack/agent-device
Issues similares
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
core
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
vectorize-io/hindsight#5457 ·
Los mantenedores suelen responder en 1 día
-
beginner friendly community contributions-welcome good first issue hacktoberfest help wanted testing up-for-grabs
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
lukilabs/beautiful-mermaid#160 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
rescript-lang/rescript-lang.org#1420 ·
Los mantenedores suelen responder en 2 días