Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
8cd57af
feat: read an effect witness around a click or a select
lahfir Nov 16, 2026
c32a43c
refactor: route a refused Escape through one core state machine
lahfir Nov 16, 2026
de00c01
feat(macos): read the effect witness and let the press check use it
lahfir Nov 16, 2026
5f0aa3b
docs: describe the effect of a click and the Escape close in the cont…
lahfir Nov 16, 2026
f22d066
perf: read the effect witness once after the dispatch, with no wait
lahfir Nov 16, 2026
44f07e2
feat(windows): read the effect witness, and close a refused Escape's …
lahfir Nov 16, 2026
699b06c
feat(linux): read the effect witness, and close a refused Escape's po…
lahfir Nov 16, 2026
b13abc5
fix(windows): read an unreadable expand state as unknown in the effec…
lahfir Nov 17, 2026
274353d
fix(macos): count focus that arrives from no focus as an effect
lahfir Nov 17, 2026
bdb7c55
fix(macos): report no focus only when the application answers no value
lahfir Nov 17, 2026
096acb0
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
b5c7c33
fix: count a change of the target's value as weak evidence of a click
lahfir Nov 20, 2026
dd4ce9a
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
ab0a1b1
fix(macos): verify a press only by a change the application cannot ma…
lahfir Nov 20, 2026
ad093e9
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
fe6a2e5
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
f2e9c20
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
7720c26
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
5c04ca9
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
a7b0d15
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
0aa056d
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
d7bd8ca
fix(linux): leave the popup count unknown when a menu or the walk was…
lahfir Nov 20, 2026
1092977
fix(macos): leave the surface count unknown when a menu or a child ca…
lahfir Nov 20, 2026
55c80a4
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
ef06898
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 20, 2026
a1ae376
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 21, 2026
07ea396
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 21, 2026
ea47ee6
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 23, 2026
b31c6a6
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 23, 2026
1ba68d3
fix(core): count focus into the target only when it arrived from outside
lahfir Nov 23, 2026
7929e45
fix(macos): close the open transient surface after a refused escape
lahfir Nov 23, 2026
24e74b7
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 23, 2026
a56ad19
fix: fall back to the app's open surface when escape is scoped to a w…
lahfir Nov 24, 2026
1d3d035
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 24, 2026
74f77a6
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 24, 2026
d0fe897
fix(linux): skip window activation for headed actions on wayland
lahfir Nov 25, 2026
9fb60d7
fix(linux): select a selectable tab by the verb it names
lahfir Nov 25, 2026
044f0cb
fix: report a verified effect as success when the platform answer was…
lahfir Nov 25, 2026
2793d25
refactor(linux): move the headed focus rule out of the adapter file
lahfir Nov 25, 2026
2d130bd
test: pin that a refusal that sent nothing stays an error under the e…
lahfir Nov 25, 2026
18e1439
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
bb2598c
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
f1d9d7b
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
0ad2ba0
fix: read the effect witness after the lease is released and cap it a…
lahfir Nov 25, 2026
b891a93
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
2110cee
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
7a8e875
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
e9bac0d
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
607922a
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
3f93476
refactor: move the linux action capability impl into the actions layer
lahfir Nov 25, 2026
09d9ddd
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
e8e0e14
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
0cf73cb
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
86e9182
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
87b1e8b
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
7d601f4
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
b5539fd
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 25, 2026
233a5d1
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 26, 2026
b26f393
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 26, 2026
800343e
test: freeze clock in witnessed_action uncertain-without-wait test
lahfir Nov 26, 2026
42d7755
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 26, 2026
63a8d26
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
70f4a78
docs: align delivery_uncertain effect-witness outcome with implementa…
lahfir Nov 27, 2026
57ef906
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
45e9b0c
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
af75e11
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
e2862b9
fix(core,linux,windows): require non-retryable StaleRef for TargetGon…
lahfir Nov 27, 2026
6003f72
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
8344c6a
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
7b98ca6
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
8a1559d
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
25beb95
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
8dca230
Merge branch 'laf/reliability-15-hard-surfaces' into laf/reliability-…
lahfir Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions crates/core/src/actions/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ impl Action {
matches!(self, Self::Hover | Self::Drag(_))
}

/// Whether the action's effect lands outside the target's own state, so an
/// effect witness is read around it.
pub fn witnesses_effect(&self) -> bool {
matches!(
self,
Self::Click
| Self::DoubleClick
| Self::RightClick
| Self::TripleClick
| Self::Select(_)
)
}

pub fn requires_hit_test(&self) -> bool {
matches!(
self,
Expand Down
11 changes: 11 additions & 0 deletions crates/core/src/actions/action_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ pub struct ActionResult {
pub surfaces: Vec<crate::SurfaceInfo>,
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<serde_json::Value>,
/// What the effect witness saw around the action; absent when the action
/// has no witness or the platform could not read one.
#[serde(skip_serializing_if = "Option::is_none", default)]
pub effect: Option<crate::actions::observed_effect::ObservedEffect>,
#[serde(deserialize_with = "deserialize_action_disposition")]
disposition: DeliverySemantics,
}
Expand Down Expand Up @@ -49,6 +53,7 @@ impl ActionResult {
steps: Vec::new(),
surfaces: Vec::new(),
details: None,
effect: None,
disposition: DeliverySemantics::not_delivered(),
}
}
Expand All @@ -60,10 +65,16 @@ impl ActionResult {
steps: Vec::new(),
surfaces: Vec::new(),
details: None,
effect: None,
disposition: default_action_disposition(),
}
}

pub fn with_effect(mut self, effect: crate::actions::observed_effect::ObservedEffect) -> Self {
self.effect = Some(effect);
self
}

pub fn with_state(mut self, state: ElementState) -> Self {
self.post_state = Some(state);
self
Expand Down
101 changes: 101 additions & 0 deletions crates/core/src/actions/effect_witness.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
use serde::{Deserialize, Serialize};

use crate::actions::{
focus_witness::FocusWitness, observed_effect::ObservedEffect, target_witness::TargetWitness,
window_witness::WindowWitness, witness_change::WitnessChange,
};

/// What an adapter reads around an action whose effect lands outside the
/// target's own state: a click, a select. A field the platform could not read
/// is `None` and never counts as a change.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct EffectWitness {
pub target: TargetWitness,
pub focus: FocusWitness,
pub window: WindowWitness,
}

impl EffectWitness {
/// The changes from `before` to `self`. A change counts only when both
/// reads have the field. A selection or a surface counts only when it
/// appears, because one that goes away says nothing about this action.
/// Focus counts as arriving in the target only when the earlier read saw it
/// outside the target; focus that was already inside and moved to another
/// child is a move within the window, and an unread earlier focus never
/// becomes an arrival.
pub fn changes_since(&self, before: &Self) -> Vec<WitnessChange> {
let (now, then) = (self, before);
let focus_moved = differs(&then.focus.element, &now.focus.element);
let focus_arrived =
then.focus.inside_target == Some(false) && now.focus.inside_target == Some(true);
[
(
then.target.selected == Some(false) && now.target.selected == Some(true),
WitnessChange::TargetSelected,
),
(
differs(&then.target.value, &now.target.value),
WitnessChange::TargetValue,
),
(
grew(then.target.surfaces, now.target.surfaces),
WitnessChange::SurfaceOpened,
),
(focus_arrived, WitnessChange::FocusIntoTarget),
(
focus_moved && !focus_arrived && now.focus.in_target_window == Some(true),
WitnessChange::FocusMovedInWindow,
),
(
!focus_moved
&& now.focus.in_target_window == Some(true)
&& differs(&then.focus.value, &now.focus.value),
WitnessChange::FocusedValue,
),
(
then.window.present == Some(true) && now.window.present == Some(false),
WitnessChange::WindowClosed,
),
(
differs(&then.window.title, &now.window.title),
WitnessChange::WindowTitle,
),
(
differs(&then.window.content, &now.window.content),
WitnessChange::WindowContent,
),
(
differs(&then.window.windows, &now.window.windows),
WitnessChange::WindowCount,
),
]
.into_iter()
.filter_map(|(changed, change)| changed.then_some(change))
.collect()
}
}

/// The verdict of a list of changes: any strong change is an observed
/// effect, weak changes alone are indeterminate, and no change is not
/// observed.
pub(crate) fn verdict(changes: &[WitnessChange]) -> ObservedEffect {
if changes.iter().any(|change| change.is_strong()) {
ObservedEffect::Observed
} else if changes.is_empty() {
ObservedEffect::NotObserved
} else {
ObservedEffect::Indeterminate
}
}

fn differs<T: PartialEq>(before: &Option<T>, after: &Option<T>) -> bool {
matches!((before, after), (Some(before), Some(after)) if before != after)
}

fn grew(before: Option<u32>, after: Option<u32>) -> bool {
matches!((before, after), (Some(before), Some(after)) if after > before)
}

#[cfg(test)]
#[path = "effect_witness_tests.rs"]
mod tests;
160 changes: 160 additions & 0 deletions crates/core/src/actions/effect_witness_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
use super::{EffectWitness, verdict};
use crate::actions::focus_witness::FocusWitness;
use crate::actions::{observed_effect::ObservedEffect, witness_change::WitnessChange};

fn read() -> EffectWitness {
let mut witness = EffectWitness::default();
witness.target.selected = Some(false);
witness.target.value = Some("0".into());
witness.target.surfaces = Some(0);
witness.focus.element = Some("list".into());
witness.focus.inside_target = Some(false);
witness.focus.in_target_window = Some(true);
witness.focus.value = Some("a".into());
witness.window.title = Some("Downloads".into());
witness.window.content = Some(7);
witness.window.windows = Some(1);
witness.window.present = Some(true);
witness
}

#[test]
fn no_change_is_not_observed() {
let before = read();
assert!(read().changes_since(&before).is_empty());
assert_eq!(verdict(&[]), ObservedEffect::NotObserved);
}

#[test]
fn a_change_on_or_under_the_target_is_an_observed_effect() {
let before = read();
for (change, expected) in [
(
(|w: &mut EffectWitness| w.target.selected = Some(true)) as fn(&mut EffectWitness),
WitnessChange::TargetSelected,
),
(
|w| w.target.surfaces = Some(1),
WitnessChange::SurfaceOpened,
),
(
|w| w.window.present = Some(false),
WitnessChange::WindowClosed,
),
(
|w| {
w.focus.element = Some("target".into());
w.focus.inside_target = Some(true);
},
WitnessChange::FocusIntoTarget,
),
] {
let mut after = read();
change(&mut after);
let changes = after.changes_since(&before);
assert_eq!(changes, [expected]);
assert_eq!(verdict(&changes), ObservedEffect::Observed);
}
}

#[test]
fn a_change_the_application_can_make_by_itself_is_indeterminate() {
let before = read();
for (change, expected) in [
(
(|w: &mut EffectWitness| w.window.title = Some("Recents".into()))
as fn(&mut EffectWitness),
WitnessChange::WindowTitle,
),
(|w| w.window.content = Some(8), WitnessChange::WindowContent),
(
|w| w.target.value = Some("00:02".into()),
WitnessChange::TargetValue,
),
(|w| w.window.windows = Some(2), WitnessChange::WindowCount),
(
|w| w.focus.element = Some("field".into()),
WitnessChange::FocusMovedInWindow,
),
(
|w| w.focus.value = Some("b".into()),
WitnessChange::FocusedValue,
),
] {
let mut after = read();
change(&mut after);
let changes = after.changes_since(&before);
assert_eq!(changes, [expected]);
assert_eq!(verdict(&changes), ObservedEffect::Indeterminate);
}
}

#[test]
fn a_field_read_only_once_and_a_state_that_goes_away_are_no_evidence() {
let before = read();
let mut after = read();
after.window.title = None;
after.focus.element = None;
assert!(after.changes_since(&before).is_empty());

let mut selected = read();
selected.target.selected = Some(true);
selected.target.surfaces = Some(1);
let mut gone = selected.clone();
gone.target.selected = Some(false);
gone.target.surfaces = Some(0);
assert!(gone.changes_since(&selected).is_empty());
}

#[test]
fn focus_that_arrives_in_the_target_from_no_focus_is_a_change() {
let mut before = read();
before.focus = FocusWitness::nothing_focused();
let mut now = read();
now.focus.element = Some("target".into());
now.focus.inside_target = Some(true);

let changes = now.changes_since(&before);
assert_eq!(changes, [WitnessChange::FocusIntoTarget]);
assert_eq!(verdict(&changes), ObservedEffect::Observed);
}

#[test]
fn focus_that_arrives_in_the_target_from_outside_is_a_change() {
let before = read();
let mut now = read();
now.focus.element = Some("target".into());
now.focus.inside_target = Some(true);

let changes = now.changes_since(&before);
assert_eq!(changes, [WitnessChange::FocusIntoTarget]);
assert_eq!(verdict(&changes), ObservedEffect::Observed);
}

#[test]
fn focus_that_moves_between_children_inside_the_target_is_not_an_arrival() {
let mut before = read();
before.focus.element = Some("row-one".into());
before.focus.inside_target = Some(true);
let mut now = before.clone();
now.focus.element = Some("row-two".into());

let changes = now.changes_since(&before);
assert!(!changes.contains(&WitnessChange::FocusIntoTarget));
assert_eq!(changes, [WitnessChange::FocusMovedInWindow]);
assert_eq!(verdict(&changes), ObservedEffect::Indeterminate);
}

#[test]
fn focus_that_was_not_read_before_is_never_an_arrival() {
let mut before = read();
before.focus = FocusWitness::default();
let mut now = read();
now.focus.element = Some("target".into());
now.focus.inside_target = Some(true);

let changes = now.changes_since(&before);
assert!(!changes.contains(&WitnessChange::FocusIntoTarget));
assert!(changes.is_empty());
assert_eq!(verdict(&changes), ObservedEffect::NotObserved);
}
29 changes: 29 additions & 0 deletions crates/core/src/actions/focus_witness.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use serde::{Deserialize, Serialize};

/// The application's focused element, as an action's witness reads it.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct FocusWitness {
/// A stable identity of the focused element; `None` when the platform
/// cannot name it, which leaves focus evidence unread.
pub element: Option<String>,
/// Whether the focused element is the target or lies inside it.
pub inside_target: Option<bool>,
/// Whether the focused element lies in the target's window.
pub in_target_window: Option<bool>,
pub value: Option<String>,
}

impl FocusWitness {
/// The application answered that nothing has focus. Unlike `default()`,
/// which is a focus that was not read, this is a read, so focus that
/// arrives later counts as moved. Use it only for that answer: a read the
/// application did not answer stays `default()`.
pub fn nothing_focused() -> Self {
Self {
element: Some(String::new()),
inside_target: Some(false),
in_target_window: Some(false),
value: None,
}
}
}
7 changes: 7 additions & 0 deletions crates/core/src/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ pub mod delivery_observation;
pub mod delivery_outcome;
pub(crate) mod delivery_semantics;
pub mod effect;
pub mod effect_witness;
pub mod focus_witness;
pub(crate) mod headed_focus;
pub mod interaction_policy;
pub mod observed_effect;
pub(crate) mod post_action;
pub mod step_mechanism;
pub mod target_witness;
pub mod window_witness;
pub mod witness_change;
pub(crate) mod witnessed_action;
18 changes: 18 additions & 0 deletions crates/core/src/actions/observed_effect.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use serde::{Deserialize, Serialize};

/// What a before-and-after read of an action's witness showed.
///
/// `NotObserved` with a delivered disposition does not mean that nothing
/// happened: an effect can come later, or in another process.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ObservedEffect {
/// A change that only the action explains: on the target, under it, or
/// focus moving into it.
Observed,
/// No change in anything the witness could read.
NotObserved,
/// Only a change that the application could also make by itself, such as
/// a new window title.
Indeterminate,
}
Loading
Loading