Skip to content

macOS engine: keys never reach remote-view panels (Open/Save): keyboardTarget uses public AXUIElementGetPid; vendor posts to the actual pid #582

Done

Description

@SSFSKIM

Problem. When an Open or Save panel is focused in an app, cua's macOS engine posts keyboard events to the app's pid, and the panel never receives them. A model can't dismiss the panel with Escape or type a file name into it. The panel is a remote view drawn by com.apple.appkit.xpc.openAndSavePanelService. Other remote-view UI (share sheets, print panels and the like) is likely affected the same way; that is unverified. #212's save sheet came from the owner's own use. This blocks the default-engine flip (#506).

Evidence, live (C-3, run 45339840861 at f239a7b, hosted, the read-only key-route diagnostic of ruling 1198; artifacts in ~/.local/share/cua-m5-pilot/c-3/sitting/key-route/):

engine Escape posted to (CGEvent field 40) seen by panel closed
vendor openAndSavePanelService (activation policy prohibited) the panel service's tap yes
cua TextEdit TextEdit's tap no
  • AX ancestors of the focused element. At depths 0–5 (AXList up to AXSplitGroup), AXUIElementGetPid returns TextEdit's pid while the private _AXUIElementGetActualPid returns the panel service's. At depth 6 (AXWindow) and depth 7 (AXApplication), both return TextEdit's.
  • cua's keyboardTarget (native/engine Input.swift:1014) takes the focused element's public GetPid, which is TextEdit.

The vendor's route (static reading of the pinned SkyComputerUseService, confirmed by the run above):

  • ApplicationUIElement.targetForKeyboardEvent() (0x1006f645c) calls outOfProcessTarget(for:appPID:).
  • That walks the focused element's AXParent chain, reading each element's owner with _AXUIElementGetActualPid, which is soft-linked.
  • It switches to that pid when the pid differs from the app's and the owner's activationPolicy is prohibited.
  • It then posts with CGEventPostToPid (postToPid 0x100249f24).
  • Ruled out: the HID or session tap, AXUIElementPostKeyboardEvent, and SLEventPostToPid.
  • Details: F-helper-logic.md §5–6 and §11; ~/.local/share/cua-m5-pilot/skyre/.

Public routes probed (both lanes):

  • Only NSRunningApplication by bundle id (com.apple.appkit.xpc.openAndSavePanelService) reaches the service's pid.
  • These all return TextEdit: CGWindowList owner at the panel frame, top window at the panel centre, frontmost window owner, the app's focused window, the system-wide focused element and application, and frontmostApplication.
  • The AXWindow's GetPid read "none".

Design decision (ruling 1202, design session). Take the vendor's route: resolve the owner with the private _AXUIElementGetActualPid, soft-linked through dlsym, and not a public heuristic.

  • A heuristic that guesses wrong posts keys to the wrong process, which is worse than today's no-op.
  • The private call answers the question directly, and it matches the vendor we are replacing.
  • cua's engine is signed by the owner's identity and never goes through App Store review.
  • If the symbol doesn't resolve (a future macOS), the engine behaves as today, posting to the app's pid, and says so: cua doctor gets an engine row naming _AXUIElementGetActualPid unavailable, and the engine's capability report carries it. It is never silent and never a guess.

Fix.

Check.

  • On a hosted C, the judged cells openPanel/frontmost/pressKey.escape, openPanel/frontmost/typeText.search, savePanel/frontmost/pressKey.escape and savePanel/frontmost/typeText.name pass on cua as on the vendor.
  • The key-route diagnostic shows cua posting to the panel service.

Activity

  1. added
    bug
    status:ready-for-implementer
    priority:P1
    on Nov 24, 2026
  2. added
    status:in-progress
    and removed
    status:ready-for-implementer
    on Nov 24, 2026
  3. SSFSKIM commented on Nov 24, 2026

    @SSFSKIM
    OwnerAuthor

    [board] in-progress: Taken by cursor235 (ruling 1202)

  4. added
    status:in-review
    and removed
    status:in-progress
    on Nov 24, 2026
  5. removed
    status:in-review
    on Nov 24, 2026
  6. SSFSKIM commented on Nov 24, 2026

    @SSFSKIM
    OwnerAuthor

    [board] done: Landed via PR #584 (cua 0.29.22)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:P1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions