From ef5c90cec96dffc253d8a6ca1efe59e251e92626 Mon Sep 17 00:00:00 2001 From: Lahfir Date: Sun, 12 Jul 2026 18:12:57 -0700 Subject: [PATCH] fix: prefer verified headed disclosure clicks --- crates/macos/src/actions/chain.rs | 6 +----- crates/macos/src/actions/chain_defs.rs | 8 ++++---- crates/macos/src/actions/chain_step_exec.rs | 3 +++ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/macos/src/actions/chain.rs b/crates/macos/src/actions/chain.rs index 738e584..b476af0 100644 --- a/crates/macos/src/actions/chain.rs +++ b/crates/macos/src/actions/chain.rs @@ -32,11 +32,7 @@ mod imp { for (i, step) in def.steps.iter().enumerate() { ctx.ensure_budget()?; - if matches!( - step, - ChainStep::CGClick { .. } | ChainStep::CGDisclosureClick { .. } - ) && !physical_click_permitted(policy) - { + if matches!(step, ChainStep::CGClick { .. }) && !physical_click_permitted(policy) { return Err(AdapterError::policy_denied_for_policy( "Physical click fallback is disabled by the current interaction policy", policy, diff --git a/crates/macos/src/actions/chain_defs.rs b/crates/macos/src/actions/chain_defs.rs index f9ec5c2..1af6302 100644 --- a/crates/macos/src/actions/chain_defs.rs +++ b/crates/macos/src/actions/chain_defs.rs @@ -51,11 +51,11 @@ mod imp { pub(crate) static EXPAND_CHAIN: ChainDef = ChainDef { steps: &[ + ChainStep::CGDisclosureClick { expanded: true }, ChainStep::CustomWithDeadline { label: "expand_verified", func: chain_disclosure_steps::press_to_expand, }, - ChainStep::CGDisclosureClick { expanded: true }, ], suggestion: "Target a control with a readable expandable state.", continue_after_unverified_delivery: false, @@ -63,11 +63,11 @@ mod imp { pub(crate) static COLLAPSE_CHAIN: ChainDef = ChainDef { steps: &[ + ChainStep::CGDisclosureClick { expanded: false }, ChainStep::CustomWithDeadline { label: "collapse_verified", func: chain_disclosure_steps::press_to_collapse, }, - ChainStep::CGDisclosureClick { expanded: false }, ], suggestion: "Target a control with a readable expandable state.", continue_after_unverified_delivery: false, @@ -154,10 +154,10 @@ mod imp { use crate::actions::chain_step::ChainStep; #[test] - fn disclosure_chains_end_with_a_headed_physical_fallback() { + fn disclosure_chains_begin_with_a_headed_physical_fallback() { for chain in [&EXPAND_CHAIN, &COLLAPSE_CHAIN] { assert!(matches!( - chain.steps.last(), + chain.steps.first(), Some(ChainStep::CGDisclosureClick { .. }) )); } diff --git a/crates/macos/src/actions/chain_step_exec.rs b/crates/macos/src/actions/chain_step_exec.rs index ce09e13..386cfa6 100644 --- a/crates/macos/src/actions/chain_step_exec.rs +++ b/crates/macos/src/actions/chain_step_exec.rs @@ -84,6 +84,9 @@ mod imp { Ok(DeliveryOutcome::DeliveredUnverified) } ChainStep::CGDisclosureClick { expanded } => { + if !policy.allow_focus_steal || !policy.allow_cursor_move { + return Ok(DeliveryOutcome::NotDelivered); + } if !crate::actions::chain_disclosure_steps::physical_fallback_allowed( el, *expanded,