Skip to content

macOS engine: refuse a shared pointer while another app is in front of a key-focus-only target (#538) - #547

Merged
SSFSKIM merged 7 commits into
mainfrom
fix/538-key-focus-refuse
Nov 23, 2026
Merged

SSFSKIM merged 7 commits into
mainfrom
fix/538-key-focus-refuse

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Closes #538.

What

The problem state ("S"): the target app holds keyboard focus, another app is frontmost, and no activation is standing. A shared-mode pointer click or drag in S used to post its events with no #200 guard, so it could bring the target's window over the person's. Now it is refused with PointerRefused(keyFocusOnly:), and the request takes #282's path: the element's own action, or a refusal. Nothing is posted.

Rule (c), rulings 1173 and 1174

  • Where the check runs. In FakeActivation.deliver(), with no activation standing, frontmostIsTarget is re-read as the last step before posting, after deliver's AX lookups. It judges the pointer's own bound app (ranBy), joiners included.
  • Outcomes.
    • Another app frontmost → refused.
    • No app frontmost, or the target frontmost → posted as on main.
  • Unchanged. Dedicated mode, paste, and every path with an activation standing (repair, watch, events) are byte-identical to main.
  • The refusal sentence.
    • It names the bound app.
    • It describes the front as read, and says "while holds keyboard focus" only when that is true.
    • It names what works: element actions, keys, or asking the person to bring the app forward. It never says "try again".
  • _meta.pointerRefusal is {reason: keyFocusOnly, frontmostPid, keyFocusPid, keyFocusIsTarget}. It is carried through the service and through set_value and select_text's focusing fallback.
  • The agent cursor is announced only on the posting path, so a refused pointer doesn't move it.

Declared gaps (all ticketed)

Proof

  • KeyFocusOnlyTests, 12 tests through the real carriers (strict descendant, coordinate, drag, right and middle click). They cover:
    • refusal in S and posting when no app or the target is frontmost;
    • a cross-app joiner on a shared serving pid in both front orders;
    • a never-activated joiner that is never told to retry;
    • no cursor announcement on refusal;
    • dedicated mode and paste pins.
  • ValueSettingTests: set_value's real focusing chain in S keeps pointerRefusal and is carried by the press.
  • Red evidence:
    • The S scenes are red on 6baf3e3.
    • The fix-round scenes are red on dfd9303: 5 of 11 tests and 15 assertions, plus the focusing chain.
  • swift test: 1771 tests, 1 skipped, 0 failures. The Xcode 27.2 release build passes.

Review

  • An adversarial review of design (b) found four P1s. Design withdrew (b) and chose (c) (ruling 1173).
  • reviewer-high on 6baf3e3..dfd9303 found one P1 (the joiner was judged by the standing entry's app pid), three P2s and one P3. All five were fixed in one round (ruling 1174).
  • The scoped re-review of dfd9303..831bfd3 found the change correct, with no findings.

Plugin 0.29.15.

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

… main (refs #538)

GuardSeam gains a settable key focus and mouse-down kinds beyond the left.
KeyFocusOnlyTests drives S (another app frontmost, the target holding key
focus, so route 3's activation exits early) through deliverClick and
deliverPointer. On 6baf3e3, 4 of its 9 tests fail with 47 assertions: a
click, double click, right click, drag and web-area click in S, the front
changing before the events, and a pointer joining a never-activated hold
are all posted with no hold, leaving the target's window above. The 5 pins
(no app frontmost, target frontmost, dedicated mode, the paste's event, and
the guarded click and drag with an activation standing) pass on main.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…le another app is in front (refs #538)

Ruling 1173, option (c). In the key-focus-only state (the target holds
window-server key focus, another app is frontmost) activate() exits early
and deliver() posted the pointer's events with no hold, repair or watch.
Now deliver(), for a pointer with no activation standing, reads the front
with frontmostIsTarget as its last step before the events: another app in
front throws PointerRefused carrying the readings, and deliverPointer
gives the never-run lease back and runs #282's path (the element route
where one exists, else keyFocusOnlyRefused). No app frontmost, or the
target's, posts alone as before. The meta's pointerRefusal carries reason
keyFocusOnly with the frontmost and key-focus pids; the service passes it
as cua/pointerRefusal. A joiner of a never-activated entry is refused the
same way. Dedicated mode, the paste route (deliver now throws, the paste
only adds try), every delivery with an activation standing and #258's
carrier are unchanged.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…Interfaces' pointerRefusal (refs #538)

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

A cross-app joiner on a shared serving process in both front orders, zero
cursor announcements on a refused pointer and on its element route, the
front-lost and key-focus-left sentences with no "try again", and set_value's
focus fallback carried by the press through focusFieldIfNeeded,
focusFallbackClick, focusingClick and deliverClick keeping pointerRefusal.
On dfd9303, 5 of the 11 KeyFocusOnlyTests fail with 15 assertions (1 an
unexpected throw: B frontmost is wrongly refused), and the focusing chain
loses the record.

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

- P1: deliver() judges the front and key focus for the pointer's own bound
  app (ranBy's appPid), not the shared entry's, since HeldActivations shares
  entries by serving process alone.
- P2: the agent cursor is announced inside the posting closure, after the
  refusal, so a refused pointer moves no cursor and an element route after
  it announces once.
- P2: focusingClick copies pointerRefusal back into set_value's and
  select_text's meta.
- P2: the refusal describes the front as read and names what works; it
  never asks for a retry, which a held never-activated entry would refuse
  again.
- P3: every pointer target its callers build names the bound app
  (PointerTarget.acceptingFirstMouse(in:)), so a right or middle click's
  refusal no longer says "the app".

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

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

chatgpt-codex-connector Bot commented Nov 23, 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-23T21:27:00.988344Z 831bfd3 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.

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

Labels

None yet

Projects

None yet

1 participant