Skip to content

macOS engine: keys reach remote-view panels (Open/Save) through the vendor's owner walk (#582) - #584

Merged
SSFSKIM merged 13 commits into
mainfrom
fix/582-remote-view-keys
Nov 24, 2026
Merged

SSFSKIM merged 13 commits into
mainfrom
fix/582-remote-view-keys

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Closes #582.

What changes

cua's macOS engine now delivers keys to remote-view panels (the Open and Save panels drawn by openAndSavePanelService), as the vendor's engine does. Before this change, press_key, type_text and paste posted to the public owner of the focused element (AXUIElementGetPid), which for a panel is the host app. The keys landed in the document, not the panel. C-3's key-route diagnostic showed this live (run 45339840861): the vendor's Escape closed the Open panel and cua's did nothing.

The engine now follows the vendor's route, which ruling 1202 adopted and which was decoded from the pinned SkyComputerUseService:

  • Walk from the focused element up its AXParent chain, bounded at the element plus 300 parents.
  • At each element, read the pid with the private _AXUIElementGetActualPid, resolved through dlsym. An unread or unknown owner is skipped. The first owner that classifies ends the walk.
  • Switch to that owner only if its activationPolicy is prohibited and it differs from the app. Keys are posted with CGEventPostToPid.
  • Activation, route choice, input-source checks and the paste's guards stay bound to the app. Only the pid the keys are posted to moves.

Ordering, safety and budget (review rounds 2 and 3)

  • Two reads. An early read refuses a forbidden owner before anything is touched, and registers its process with the intervention detector. A final read comes after activation, immediately before the first key. That matches the vendor, which reads targetForKeyboardEvent after its focus enforcer. The final read decides the pid the keys go to, is checked against the forbidden list, and is registered too. In paste it runs inside the paste lock.
  • Walk budget: 250 ms, or the request's deadline if that comes sooner. A real chain is a few dozen sub-millisecond reads and usually ends at the focused element, so a hung AX provider can delay keys by about 300 ms at most. Before, it could be 300 reads at 1 s each. Each parent read's messaging timeout is the time left.
  • Deadline. Every key route refuses a request past its deadline before the first key (timeoutReached). Paste also checks again at its first ⌘V or Return, after the clipboard snapshot, the baseline and the pasteboard write. There it refuses with keysDeadlinePassed and restores the pasteboard.
  • A walk cut off at its budget still posts by ordinary routing to the focused element's public owner, or to the app. This includes a parent read whose timeout fired once the budget was spent. Once keys were posted, the reply a model reads leads with: "The check for an Open or Save panel timed out, so the keys went to by ordinary routing and may not have reached such a panel." <destination> is the app's name when the owner is the app; otherwise the owner process's localized name, its bundle id, or process <pid>. The notice comes before the method's own note, so a cut at the service's 500-character limit falls on that note, not on the notice. It also follows an error raised after the post (e.g. typeUnconfirmed), and never accompanies a refusal before any key. The meta carries cua/keyTargetCutOff.

Fallback when the private symbol is missing

If _AXUIElementGetActualPid doesn't resolve, no walk is made and keys post exactly as before. The engine status carries actualPid: true|false. cua doctor's engine row says keys reach remote-view panels when it is true, and warns when it is false. Tests force the symbol to be missing.

#538 and #258

Only the pid the keys are posted to moves. #538's frontmost refusal applies to pointer events only, and #258's frontmost carrier to clicks only. Neither is touched. The panel service is never activated: its prohibited policy rules that out, and the vendor never tries. A paste test pins this down: the keys go to the service and the activation's events to the app.

Versions

engineVersion 0.2.0 → 0.2.1; plugin 0.29.22 (ruling 1208: the Linux engine's 0.4.5 PR takes 0.29.21).

Verification

  • Swift engine suite: 1801 tests, 2 skipped (main's existing one, plus the presence canary, which runs only when RUNNER_ENVIRONMENT=github-hosted), 0 failures. New: KeyTargetTests, including a timed-out parent read flagged as cut off with the target unchanged, the notice's destination naming, and the 500-character limit with the real password-field note, plus paste-activation tests for both directions of owner change, a forbidden owner on either read, the deadline expiring during activation and during the baseline, and an early-registered service catching a user's key.
  • Node: doctor-engine and services-engine-service, 67/67.
  • ci-gate GREEN on 34dc5e6 (run 45355518460), all seven gates. 2d48871 adds only a tech-debt line.
  • Live proof (ruling 1205): this merges only after feat/117-m5's sitting C-4 runs on this engine. The four judged panel cells (openPanel and savePanel pressKey.escape, openPanel typeText.search, savePanel typeText.name) must pass on cua, and the key-route diagnostic must show cua posting to openAndSavePanelService. C-4 results: pending.
  • Nothing GUI or live AX ran on the MacBook. press_key and keyed type_text can't be driven in a unit test. For those two the ordering is checked by where the code sits, and finalKeyTarget itself is tested.

Reviews

reviewer-high, three rounds:

  1. 0d4c599..4b48955: incorrect. The target was read before activation (P1); the walk had no time bound (P2); the canary wasn't portable (P3). Fixed under ruling 1206.
  2. 4b48955..fe8912c: incorrect. The fix had dropped the early intervention registration (P1); paste's deadline came before setup (P2); typed paste did three lookups, and the canary was keyed on GITHUB_ACTIONS (P3). Fixed under ruling 1207.
  3. fe8912c..69bdbfa: no P1. The notice wasn't flagged when a parent read timed out, was lost on errors after a post, was cut at 500 characters, and named an unverified destination (P2/P3), all fixed under ruling 1210. Also a P2: paste's first-key deadline check runs before a shared activation's delivery read. It's logged in tech-debt-tracker: rare, and that path never checked the deadline before this PR.
  4. 69bdbfa..34dc5e6: resolved, and ruling 1210 holds (no change to the walk's answer, the final read or the post pid). A P3 remains: a destination name of hundreds of characters could still overflow the notice. Logged in tech-debt-tracker as contrived.

Unresolved Review Findings

  • macOS engine: a person's key into a panel the activation itself focused goes unseen until the keys are posted #583 (P3, declared limit). If the activation itself moves focus into a remote-view panel, the final owner differs from every process registered at the early read. A key the person types into that panel between the two reads then goes unseen. A narrow race can do the same when one walk is cut short and the other isn't. With focus unchanged across activation, the usual case, both reads name the same service and the key is seen.
  • Logged in tech-debt-tracker: the shared-activation ⌘V deadline (P2, rare) and the long destination name (P3, contrived).
  • Other remote-view UI (share sheets, print panels) is unverified either way.

Sminos-Session: cursor235#b93055dd (cua on macbook)

…tualPid, engine 0.2.1 (refs #582)

keyboardTarget walked nothing: it posted to the focused element's public AXUIElementGetPid,
which inside an Open or Save panel (openAndSavePanelService) is the app's pid, so the panel
never got press_key's, type_text's or paste's keys. Ruling 1202 takes the vendor's route
(targetForKeyboardEvent -> outOfProcessTarget -> ProcessType.containingElement): from the
focused element up its AXParent chain (the element and 300 parents), each element's actual
pid is read with the private _AXUIElementGetActualPid, resolved with dlsym; unread pids and
processes with no finished-launching running application are passed over; the first that
classifies ends the walk, and its pid becomes the keys' target only when its activation
policy is prohibited and it is not the app's. Otherwise the target is main's.

Without the symbol no walk is made and status.actualPid reads false. The engine reads
through KeyTargetReads, which the tests replace (a fake tree, the symbol forced missing).
Activation and refusal stay the bound app's; only the posted pid moves.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…d warns when _AXUIElementGetActualPid is unavailable (refs #582)

Reads the engine's status.actualPid: true adds that keys reach Open and Save panels, false
warns that they go to the app and do nothing there; an engine older than the field, or one
that is not the approved bundle, adds nothing. The report carries actualPid.

Sminos-Session: cursor235#b93055dd (cua on macbook)
… §5.7's decoded walk (refs #582)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…refs #582)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…alk has a 250 ms budget, late keys are refused (refs #582)

Ruling 1206 on the review of 0d4c599..4b48955. (P1) press_key, type_text and paste read the
keys' process before their activation, which can move focus between a document and its Open
or Save panel. Each now reads twice: the early read only refuses a forbidden process before
anything is touched; finalKeyTarget, after the activation and as the last step before the
poster (inside the paste lock, after the paste's activation, before the pasteboard), names
the process the keys go to, is refused when forbidden and is driven by the detector. The
activation stays the app's. The vendor reads once, after its activation (performKeyboardAction
awaits the enforcer, then calls targetForKeyboardEvent at 0x100077934).

(P2) The walk stops before a parent read once keyTargetWalkBudgetMs (250 ms) or the request's
deadline is spent, gives each read the time left as its messaging timeout, and never reads a
parent it would not inspect. Every key route refuses a request past its deadline just before
its first key (timeoutReached, nothing sent).

(P3) Resolution is tested through an injected function; the live reads are checked against
dlsym, present or absent; the presence canary runs only on GitHub's hosted runner.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…rder and the walk's budget (refs #582)

Sminos-Session: cursor235#b93055dd (cua on macbook)
… the deadline at its first key, a cut-off walk adds a notice (refs #582)

Ruling 1207 on the re-review of 4b48955..fe8912c.
- P1: earlyKeyTarget drives the early owner again, so a person's key into the panel during
  the paste lock's wait or the activation stops the action; the final read drives its own,
  and only it gets the keys.
- P2: runPaste runs beforeFirstKey just before its first key event, after the snapshot,
  baseline, write and key-focus read: past the deadline it refuses and restores the
  pasteboard.
- P3: type_text's paste route reuses the early read's pid; the symbol canary keys on
  RUNNER_ENVIRONMENT=github-hosted.
- The design's request: a final read whose walk stopped at its 250 ms budget marks
  keyTargetCutOff, and press_key, type_text and paste append a notice to the reply's note.
  The service now passes press_key's note into the tool result's text.

Sminos-Session: cursor235#b93055dd (cua on macbook)
… cut-off notice (refs #582)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…refs #582)

Ruling 1208: the Linux engine's 0.4.5 pull request takes 0.29.21 and lands first.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…e and reaches errors after a post (refs #582)

Ruling 1210 on the re-review of fe8912c..69bdbfa. No routing changes: the pid the walk
answers, the final read and the post's pid are as on 69bdbfa.
- A parent read that answers nothing once the walk's time is spent is told as a cut-off,
  not the chain's end.
- The notice names the public owner the keys went to: the app by name, else the owner's
  localized name, bundle id or pid. It is short (134 characters for TextEdit) and comes
  before the method's note, so the password field's note and the notice fit the service's
  500 whole.
- The notice is given only once keys were posted: in a success's note, and after the
  sentence of an error after the post. The meta carries keyTargetCutOff {pid}, and the
  service passes it as cua/keyTargetCutOff.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…he paste's deliver read past the deadline (refs #582)

Sminos-Session: cursor235#b93055dd (cua on macbook)
Sminos-Session: cursor235#b93055dd (cua on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T08:41:04.380690Z 2d48871 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sminos-Session: cursor235#b93055dd (cua on macbook)

# Conflicts:
#	.claude-plugin/marketplace.json
#	.claude-plugin/plugin.json
#	tech-debt-tracker.md
@SSFSKIM
SSFSKIM merged commit e54eab4 into main Nov 24, 2026
10 checks passed
@SSFSKIM
SSFSKIM deleted the fix/582-remote-view-keys branch November 24, 2026 09:46
SSFSKIM added a commit that referenced this pull request Nov 24, 2026
…o feat/117-m5 (refs #506)

Sminos-Session: cursor235#b93055dd (cua on macbook)
SSFSKIM added a commit that referenced this pull request Nov 24, 2026
…walk is unchanged (refs #506)

e54eab4's rounds touched only the cut-off flag, notice and error paths, not the pid the walk answers.

Sminos-Session: cursor235#b93055dd (cua on macbook)
SSFSKIM added a commit that referenced this pull request Nov 24, 2026
…d 0.30.0 has its name

The version takes T1's 0.30.0 over main's 0.29.22 (#584); the coordinator allocates the final number at merge.

Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant