fix(cua-driver): state the macOS drag delivery contract in its schema - #2646
Open
hqhq1025 wants to merge 1 commit into
Open
fix(cua-driver): state the macOS drag delivery contract in its schema#2646hqhq1025 wants to merge 1 commit into
hqhq1025 wants to merge 1 commit into
Conversation
drag advertises delivery_mode with a "background" default, and macOS refuses that default unconditionally in window scope, so a caller using the documented defaults fails every time with background_unavailable. Nothing in the description, the delivery_mode blurb, or the generated reference said so. Name the requirement in the tool description and in a drag-specific delivery_mode blurb, and point the refusal message at the window_id the foreground rung needs. The background/foreground enum is unchanged, so the cross-platform delivery_mode contract still holds. No behavior change.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
dragadvertisesdelivery_modewith a"background"default, and the shared blurb describes that default as "inject without fronting or raising the target — no focus steal". On macOS, window-scopedragrefuses"background"unconditionally (platform-macos/src/tools/drag.rs:169-176), so a caller invoking the tool with its documented defaults fails 100% of the time withbackground_unavailable. Neither the tool description, thedelivery_modeblurb, normcp-tools.mdxsays so — the precondition is only discoverable by hitting the error.What I checked before writing anything
I looked for an implementation gap first and did not find one, so this PR does not change behavior.
input/mouse.rs:475drag_at_xyis a complete background press-drag-release built onpost_mouse_event(mouse.rs:901) — the same helper backing backgroundclick,right_click,double_click, andscroll, with the same window-local stamp, pid filter and window routing. Its own doc comment says it "uses the SkyLight path for backgrounded-target delivery".768f0650dscoped the refusal to web content ("Background drag is unavailable for web-content windows on macOS", gated onis_electron || is_wk_web_view_app). That commit is not onmain.1d0ff7cc3(fix(cua-driver): macOS e2e convergence (conv2 3/7) #2183) replaced the same pre-image with the unconditional form now onmain. The matrix expectations that appear to justify it —cross_platform_behavior_test.rs:1196andharness_appkit_test.rs:711— were added in that same commit, so they record the decision rather than an independent observation.Whatever the reason for the current refusal, a schema whose documented default always fails is a defect on its own. That is all this PR fixes.
Change
delivery_mode:"foreground"pluswindow_id, that the"background"default is refused withbackground_unavailable, and thatscope:"desktop"is exempt.delivery_modemoves from the shareddelivery_mode_schema()blurb to a drag-specific one viadelivery_mode_schema_with. Thebackground/foregroundenum is unchanged, soprotocol_schema_test's delivery-mode contract still holds.window_idthe foreground rung needs.mcp-tools.mdxregenerated from the docs generator; the diff is confined to thedragsection.The runtime default stays
"background".DeliveryMode::parseis shared, and defaulting macOS drag to foreground would front a window on an omitted argument — the opposite of the no-foreground contract. Documenting the refusal is the right fix here, not flipping the default.One thing I left alone
delivery_mode:"foreground"withoutwindow_idstill falls through to the pid-routed background primitive (drag.rs:316:fg = delivery_mode.is_foreground() && window_id.is_some()), so the driver does perform a background drag on that path while refusing every other caller. I did not touch it — it is a behavior change on a path I cannot exercise from here — but it is worth your eyes, since it suggests the blanket claim is broader than what macOS actually forbids.There is also a plausible reason the one macOS row that demonstrates the refusal may be measuring the fixture rather than the platform:
NSView.acceptsFirstMousedefaults to false, and the AppKit fixture overrides it totrueonly onClickTargetButton, not on theNSSliderthe background-drag row targets.Validation
cargo clippyis unavailable on this toolchain ('cargo-clippy' is not installed for '1.97.1-aarch64-apple-darwin'), so I did not run it. Behavior is unchanged, so the existingslider_drag_px_backgroundrefusal row is unaffected; I did not re-run the live macOS harness.