Repository navigation
Native windows: right-click menu downloads save, "in New Window" items tell the truth - #1374
Merged
Merged
Conversation
…s tell the truth WebKit's default context menu in a native window is a browser's. Two of its items silently did nothing: - "Download Image" / "Download Linked File" / "Download Media": context-menu downloads bypass the public didBecomeDownload hooks and arrive through the private `_webView:contextMenuDidCreateDownload:`. Nobody adopted the WKDownload, so it had no delegate to pick a destination. Now adopted like a link download: ~/Downloads, Finder-style unique name, Dock bounce. - "Open Image/Link/Media in New Window": goes through the popup delegate. An external http(s) URL went to the default browser (works, label lied); a blob:/data: URL — a generated image — had nowhere to go. The proposed menu is now curated through `_webView:getContextMenuFromProposedMenu:…`: external → retitled "… in Browser", app URL → kept, anything else → dropped (Copy Image and Download Image remain). Decisions live in `window_policy.context_menu_item`; the menu is left untouched when WebKit offers no hit-test URLs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A raise inside the curation would leave the right-click with no menu at all. The debug log of (identifier, title) pairs makes a missed identifier a one-line fix read off Show Logs — the names come from WebKit source, the SDK ships no WKMenuItemIdentifiersPrivate.h. Co-Authored-By: Claude Fable 5.1 <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.
What
In a native window (macOS) the right-click menu is WebKit's default — a browser's. Two of its items silently did nothing:
didBecomeDownloadhooks and arrive through the private_webView:contextMenuDidCreateDownload:. Nobody adopted theWKDownload, so it had no delegate to pick a destination. Now adopted like a link download:~/Downloads, Finder-style unique name, Dock bounce.blob:/data:URL (a generated image) had nowhere to go. The proposed menu is now curated through_webView:getContextMenuFromProposedMenu:forElement:userInfo:completionHandler::blob:,data:) → dropped; Copy Image and Download Image remainDecisions are pure Python in
window_policy.context_menu_item;mac_window.pyenacts them. The menu is left exactly as proposed when WebKit offers no hit-test URLs (never curate blind).Notes
mac_window.py; DMG build, not App Store.WKMenuItemIdentifierOpenImageInNewWindowetc.) come fromWKMenuItemIdentifiersPrivate.h, which the SDK doesn't ship — verify live that the retitle/drop lands on the image item.mainwindow.py) in a sibling PR.Verify
~/Downloads.https://image or link: item reads "Open Image in Browser" / "Open Link in Browser" and opens the default browser.http://127.0.0.1:<port>/…): item still reads "Open Image in New Window" and opens a native window.🤖 Generated with Claude Code
Note
Medium Risk
Relies on undocumented WebKit selectors and menu item identifiers that may shift across OS versions; failures degrade to the default menu rather than crashing.
Overview
Native macOS windows now fix broken WebKit right-click behavior by hooking private delegate selectors (same pattern as pointer lock / geolocation).
Context-menu downloads (
Download Image, linked file, media) are adopted via_webView:contextMenuDidCreateDownload:and routed through the existing~/Downloads+ unique-name path, instead of silently doing nothing.“Open … in New Window” items are curated via
_webView:getContextMenuFromProposedMenu:…using hit-test URLs and pure policy inwindow_policy.context_menu_item: loopback app URLs stay as-is; external http(s) labels become “… in Browser”;blob:/data:items are removed. If hit-test data is missing or curation throws, WebKit’s proposed menu is shown unchanged.Reviewed by Cursor Bugbot for commit a665f39. Bugbot is set up for automated code reviews on this repo. Configure here.