Skip to content

Conversation

@rgarcia
Copy link
Contributor

@rgarcia rgarcia commented Nov 5, 2025

using --sync was ill-advised, it doesn't seem to detect when no mouse movements are necessary to achieve a mousemove, so getting rid of it for now


Note

Removes the --sync flag from all xdotool mousemove calls to prevent hanging during mouse operations.

  • Backend (computer controls) in server/cmd/api/api/computer.go:
    • Remove --sync from xdotool mousemove in:
      • MoveMouse
      • ClickMouse
      • Scroll
      • DragMouse (initial move to start point)

Written by Cursor Bugbot for commit 429cec9. This will update automatically on new commits. Configure here.

@rgarcia rgarcia requested a review from Sayan- November 5, 2025 14:47
@mesa-dot-dev
Copy link

mesa-dot-dev bot commented Nov 5, 2025

Mesa Description

using --sync was ill-advised, it doesn't seem to detect when no mouse movements are necessary to achieve a mousemove, so getting rid of it for now

Description generated by Mesa. Update settings

@rgarcia
Copy link
Contributor Author

rgarcia commented Nov 5, 2025

tested with this, which randomly hangs for 15s prior to the change

#!/bin/bash
# Test script for scroll down endpoint - runs 10 times with timing

BASE_URL="http://localhost:444"

echo "=== Testing /computer/scroll (vertical down) - 10 iterations ==="
echo ""

total_time=0
times=()

for i in {1..10}; do
  start_time=$(date +%s.%N)
  
  curl -X POST "${BASE_URL}/computer/scroll" \
    -H "Content-Type: application/json" \
    -d '{
      "x": 500,
      "y": 500,
      "delta_y": 3
    }' \
    -s -o /dev/null
  
  end_time=$(date +%s.%N)
  elapsed=$(awk "BEGIN {printf \"%.4f\", $end_time - $start_time}")
  times+=($elapsed)
  total_time=$(awk "BEGIN {printf \"%.4f\", $total_time + $elapsed}")
  
  echo "Iteration $i: ${elapsed}s"
done

echo ""
echo "=== Results ==="
echo "Total time: ${total_time}s"
avg_time=$(awk "BEGIN {printf \"%.4f\", $total_time / 10}")
echo "Average time: ${avg_time}s"

@rgarcia rgarcia merged commit bb066c5 into main Nov 5, 2025
5 of 6 checks passed
@rgarcia rgarcia deleted the computer-controls-hang branch November 5, 2025 14:49
Copy link

@mesa-dot-dev mesa-dot-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performed full review of ce46982...429cec9

Analysis

  1. Removing the --sync flag from xdotool mousemove commands eliminates hanging issues but introduces potential race conditions where subsequent mouse actions (clicks, drags) may occur before the cursor reaches its intended position.

  2. The implementation lacks any alternative synchronization mechanism to ensure cursor positioning completes before dependent operations execute, which could lead to clicks, drags, and scrolls happening at incorrect coordinates.

  3. No specific testing has been implemented to verify operations work correctly at boundary conditions, such as when the cursor needs to move significant distances versus when it's already at the target position.

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

1 files reviewed | 0 comments | Edit Agent SettingsRead Docs

Copy link

@mesa-dot-dev mesa-dot-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performed full review of ce46982...429cec9

Analysis

  1. Removing --sync trades synchronization guarantees for performance, potentially introducing race conditions if any calling code assumes mouse operations complete before the function returns.

  2. No tests were added to prevent regression or verify that mouse operations no longer hang, leaving the fix vulnerable to future changes.

  3. The PR lacks documentation updates explaining the new asynchronous behavior of mouse operations, which could lead to incorrect usage by other developers.

  4. No consideration of adding alternative verification logic or retry mechanisms for critical operations where position accuracy is essential.

  5. Inconsistent approach to synchronization across the codebase - some mouse operations already didn't use --sync, suggesting this problem was partially understood before.

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

1 files reviewed | 0 comments | Edit Agent SettingsRead Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants