diff --git a/.lane/memory/native2/Sources/DesktopMac/Paste.swift/01M5D5AB34JDWZ565DVTAB86HD-the-receiver-check-comes-bef.md b/.lane/attic/native2/Sources/DesktopMac/Paste.swift/01M5D5AB34JDWZ565DVTAB86HD-the-receiver-check-comes-bef.md similarity index 100% rename from .lane/memory/native2/Sources/DesktopMac/Paste.swift/01M5D5AB34JDWZ565DVTAB86HD-the-receiver-check-comes-bef.md rename to .lane/attic/native2/Sources/DesktopMac/Paste.swift/01M5D5AB34JDWZ565DVTAB86HD-the-receiver-check-comes-bef.md diff --git a/.lane/memory/native2/Sources/DesktopMac/Paste.swift/01M78N6R3R77484F4KP21TYPXX-pasteattachment-the-receiver.md b/.lane/memory/native2/Sources/DesktopMac/Paste.swift/01M78N6R3R77484F4KP21TYPXX-pasteattachment-the-receiver.md new file mode 100644 index 0000000..5cd8d7c --- /dev/null +++ b/.lane/memory/native2/Sources/DesktopMac/Paste.swift/01M78N6R3R77484F4KP21TYPXX-pasteattachment-the-receiver.md @@ -0,0 +1,13 @@ +--- +id: 01M78N6R3R77484F4KP21TYPXX +anchor: '@file' +created: 2026-11-12T19:54:24Z +norm: '1' +sig: 27abcba5e975f16e +body_hash: d23058b9832794d1 +raw_hash: cf982114ea9b7925 +lines: 1-595 +supersedes: 01M5D5AB34JDWZ565DVTAB86HD +--- + +pasteAttachment: the receiver check comes before requireKeyboardFocus so a background web field gets PASTE_UNVERIFIABLE_RECEIVER, as on Node, not a focus refusal. pasteText instead prepares the window first, since a web field's text paste can be read back (#5) diff --git a/native2/Sources/DesktopMac/Paste.swift b/native2/Sources/DesktopMac/Paste.swift index 17572c7..5fe265a 100644 --- a/native2/Sources/DesktopMac/Paste.swift +++ b/native2/Sources/DesktopMac/Paste.swift @@ -217,8 +217,11 @@ private struct ReceiverState { func focusedValue() -> String? { let app = AXUIElementCreateApplication(window.pid) AXUIElementSetMessagingTimeout(app, 0.2) + // A WKWebView app names no focused element; its page field reports AXFocused itself (#5). guard Mac.generation(window.pid) == window.generation, - let focused = AX.element(AX.value(app, kAXFocusedUIElementAttribute)), CFEqual(focused, element), + let focused = AX.element(AX.value(app, kAXFocusedUIElementAttribute)) + ?? AX.element(AX.value(app, kAXFocusedWindowAttribute)).flatMap(Mac.focusedWebElement), + CFEqual(focused, element), let frame = AX.frame(element), window.bounds.contains(CGPoint(x: frame.midX, y: frame.midY)) else { return nil } return AX.string(element, kAXValueAttribute) @@ -307,6 +310,9 @@ extension Mac { throw pasteRefusal("Literal insertion requires 1–8192 UTF-16 units and an exact focused receiver.") } return try ClipboardGate.exclusive { transaction in + // An inactive app's window must be key before its focus can be checked and the paste read back, as typing + // does (#226): a WKWebView window that isn't key reports no focused field (#5). + _ = try prepareKeys(target) let focused = try requireKeyboardFocus(target) if secureFocus(focused) { throw secureFocusRefusal } guard let baseline = ReceiverState.read(focused, target: target),