fix: prefer verified headed disclosure clicks

This commit is contained in:
Lahfir 2026-07-12 18:12:57 -07:00
parent 88e42f02a0
commit ef5c90cec9
3 changed files with 8 additions and 9 deletions

View file

@ -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,

View file

@ -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 { .. })
));
}

View file

@ -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,