Repository navigation
Insert: paste into a WKWebView page field, confirmed by its value (#5) - #251
Merged
Merged
Conversation
desktop_insert's paste route into a web <input>, <textarea> or contenteditable in a background WKWebView app was refused before sending: the window wasn't key, so the app reported no focused window, and a WKWebView app names no AXFocusedUIElement, so the field's text couldn't be read back. pasteText now makes an inactive app's window key first (prepareKeys, as typing does), and the receiver read accepts the page field that reports AXFocused itself. Why: native2/Sources/DesktopMac/Paste.swift | a WKWebView app names no AXFocusedUIElement and its window must be key before the page field reports focus; prepare the window, then find the field through focusedWebElement, before reading the baseline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the remaining item of #5:
desktop_insertwithroute: "paste"(or the default route when a field is focused) into a web<input>was refused before anything was sent.Cause
Two problems, both in
Mac.pasteText:paste. Typing already prepares the window first (prepareKeys, Keys to a list in a non-key window return completed but never reach it #226/Keys reach a SwiftUI List and a WebKit page in the background; web terminals are typed into, never pasted #240).ReceiverState.read) required the app'sAXFocusedUIElementto be the field. A WKWebView app names none. The page field reportsAXFocuseditself, whichrequireKeyboardFocusalready handles throughfocusedWebElement(Keys reach a SwiftUI List and a WebKit page in the background; web terminals are typed into, never pasted #240).Change
pasteTextnow callsprepareKeysbefore checking focus.prepareKeysmakes the window key without moving focus between windows. The receiver read accepts the app's focused element, or else the focused page field in its focused window. The paste is then confirmed by the field's value and selection, as for native fields, and the clipboard is restored after it shows.Checked
On the WKWebView fixture (
native2/fixture/webfix.swift), through the standalone host built from this branch, relaunching the fixture each time so its window starts out not key:<input>,<textarea>and contenteditable composer: 9/9completed,consumption: observed,clipboard_cleanup: restored. The page logged exactly one paste and one input per field.route) into the<input>: completed, and the page logged the paste.swift test --package-path native2passes.One attempt right after my first edit was still refused with the focus message. I couldn't reproduce it in the cold runs above. If it recurs, the likely cause is
prepareKeys' 0.5 s wait for the page to give focus back to the field after the window becomes key. Safari wasn't touched.🤖 Generated with Claude Code