Repository navigation
Sheets: confirm clicks that open or close a sheet, route agents to the parent window (#243, #245) - #247
Merged
Conversation
…o the parent window (#243, #245) A press that opens or closes a sheet now reads back the window's sheets when the app answers cannotComplete, and reports completed with sheet opened/closed instead of unknown. desktop_windows marks a sheet's own window attached_sheet with sheet_of_window_id and a hint to inspect the parent; inspecting the sheet's window refuses at once with ATTACHED_SHEET naming the parent; the parent's screenshot draws its attached sheets; desktop_dialog reads SwiftUI alert buttons (titled by description) and names the parent when given the sheet's window. An action's follow-up observation retries once when the tree is mid-change. Adds the sheetfix fixture (beginSheet, NSAlert sheet, SwiftUI .alert). Why: native2/Sources/DesktopMac/Pointer.swift | AppKit and SwiftUI answer an AXPress that opens or closes a sheet with cannotComplete although the press took effect, so an indeterminate press is confirmed by the window's sheet count changing Why: native2/Sources/DesktopMac/AX.swift | AppKit windows don't support AXSheets: sheets are AXSheet children of the window, and a SwiftUI alert's window adds a transparent margin around the AXSheet frame, so match by containment and center, not exact bounds Why: native2/Sources/DesktopMac/Capture.swift | a sheet is its own window server window, so a capture of its parent omits it; attached sheets are drawn into the parent's image so it matches the parent's elements 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.
Fixes #243. Fixes #245. Also covers the sheet part of #244 (an incomplete tree right after a sheet appears).
Reproduced with a new fixture,
native2/fixture/sheetfix.swift: an AppKit window with abeginSheetsheet and anNSAlertsheet, and a second window hosting a SwiftUI.alert.What was wrong
AXPressthat opens or closes a sheet withkAXErrorCannotComplete(-25204, after about 250 ms, so it isn't a timeout), although the press worked. A standalone AX probe sometimes gets success, so it's racy, but the host hit it every time.AXSheets. Sheets areAXSheetchildren of the parent window. The window server lists each sheet as its own untitled window, which matched no AX window, so it was listed aspixels_only/no_matching_accessibility_window. A SwiftUI alert's window also adds a transparent margin around theAXSheetframe (410×288 window, 260×138 sheet, same center). The parent's capture usedincludeChildWindows = false, so the sheet was missing from its screenshot.desktop_dialoglisted a SwiftUI alert's buttons as[], because SwiftUI puts the title inAXDescription.Changes
Pointer.swift: when a press comes back indeterminate, it rereads the window's sheet count for up to 1 s. If the count changed, the result iscompleted(confirmed_change,sheet: "opened"|"closed"). Indeterminate results now carryax_error.AX.swift: sheets are read fromAXSheetsand fromAXSheetchildren. A sheet's window is matched by its window ID, or by containing the sheet's frame with the same center.desktop_windows: a sheet's own window getsobservation_reason: attached_sheetandsheet_of_window_id. Its availability isunavailable/attached_sheetwithparent_window_idand a hint: inspect the parent window, click there, and usedesktop_dialogon the parent.desktop_inspecton a sheet's own window (either mode) now returnsATTACHED_SHEETright away and names the parent, with no 1 s retry and no "use pixels mode" advice. The check only runs for untitled windows.AXSheetelements listed.desktop_dialog/desktop_dialog_answer: button titles fall back toAXDescription. A sheet's own window target is refused with a message naming the parent.src/tools.ts: thedesktop_windowsdescription namesattached_sheetandsheet_of_window_id. The contract is regenerated.Checked
swift test --package-path native2: 54 + 33 passed.npm run checkis clean.completedwithsheet: opened/closed. Before this change, Open Sheet returnedunknown/unsafe, as the release app still does.completed, each with a fresh observation.desktop_windowslists both sheet windows asattached_sheetwith the right parent.desktop_dialogon each parent lists the buttons, including the SwiftUI ones. On a sheet's own window it names the parent.Not changed: Xcode's own sheets weren't retested (the brief said to use the fixture).
🤖 Generated with Claude Code