Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 7 additions & 8 deletions crates/computer_use/src/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ pub enum PointerEventKind {
}

/// Returns true if a `UseComputer` action batch contains at least one real
/// interaction — any non-`Wait` action (keyboard, typing, pointer, or scroll).
/// A wait-only or zero-duration no-op batch (for example a screenshot-only
/// call, which emits a single `Wait(0)`) is not a qualifying action group and is
/// not committed to the recording timeline. A pointer-only batch still
/// qualifies (with empty labels) so its on-screen effects are retained.
/// interaction — any non-`Wait` action (keyboard, typing, pointer, or scroll)
/// or an explicit non-zero wait, whose settling time should be kept in the
/// recording. Only batches made entirely of `Wait(0)` no-ops (for example a
/// screenshot-only call) fail to qualify and are not committed to the
/// recording timeline. A pointer-only batch still qualifies (with empty
/// labels) so its on-screen effects are retained.
pub fn is_meaningful_action_group(actions: &[TargetedAction]) -> bool {
actions
.iter()
.any(|targeted| !matches!(targeted.action, Action::Wait(_)))
actions.iter().any(|targeted| !targeted.action.is_no_op())
}

enum LabelCandidate {
Expand Down
4 changes: 2 additions & 2 deletions crates/computer_use/src/overlay_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ fn is_meaningful_action_group_true_for_real_interactions() {
}

#[test]
fn is_meaningful_action_group_false_for_wait_only_or_empty() {
fn is_meaningful_action_group_keeps_nonzero_waits_but_not_no_ops() {
let zero_wait = [screen(Action::Wait(Duration::ZERO))];
assert!(!is_meaningful_action_group(&zero_wait));

let nonzero_wait = [screen(Action::Wait(Duration::from_millis(500)))];
assert!(!is_meaningful_action_group(&nonzero_wait));
assert!(is_meaningful_action_group(&nonzero_wait));

assert!(!is_meaningful_action_group(&[]));
}
Expand Down
Loading