Skip to content

native2: selecting web text focuses the page, so Edit > Copy copies it (#188) - #189

Merged
iamnbutler merged 5 commits into
mainfrom
web-copy
Oct 20, 2026
Merged

iamnbutler merged 5 commits into
mainfrom
web-copy

Conversation

@iamnbutler

Copy link
Copy Markdown
Contributor

Closes #188.

Cause: Safari opens a page in the background with its address field focused. Copying after a marker selection therefore took the page URL, even after desktop_activate. In the background, Safari's Copy is disabled, and background Command-C is refused because Safari's keyboard focus isn't in its window.

Fix:

  • desktop_select on web text sets the web area's AXFocused first, as a click in the page would, then selects and reads back.
  • The tool description, docs/tools.md and live-check feat: select text in web pages through WebKit text markers #88 now give the working route: desktop_activate Safari, then desktop_menu Edit > Copy, as for Preview. The old guidance said to press Command-C, which never copied from a background Safari on either stack.
  • CHANGELOG: an Unreleased entry for the fix.

Live on the dev app (main plus this change):

Steps Without the focus change With it
Select, then background Edit > Copy refused (disabled) refused (disabled)
Select, then background Command-C refused refused
Select, desktop_activate, Edit > Copy copies the page URL copies brown fox jumps

live-check --only 88: both checks pass. Node tests 104/104, native2 tests 45/45, and the contract is regenerated.

#188)

Why: native2/Sources/DesktopMac/WebText.swift | Safari focuses its address field when it opens a page in the background, so Copy after a marker selection copied the URL; focus the web area before selecting, since focusing can move the selection
Why: scripts/live-check.mjs | Safari disables Copy and has no in-window keyboard focus while inactive, so the #88 copy runs Edit > Copy after desktop_activate; background Command-C and Edit > Copy are refused
@iamnbutler
iamnbutler merged commit abc346b into main Oct 20, 2026
2 checks passed
@iamnbutler iamnbutler mentioned this pull request Oct 20, 2026
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.

native2: Command-C after a web text selection in Safari copies nothing

1 participant