Skip to content

Conversation

@wehos
Copy link
Contributor

@wehos wehos commented Nov 29, 2025

Agent S3 seems to miss importing deps for some linux platform:

if self.platform == "linux":
return f"import pyautogui; pyautogui.hotkey('win'); time.sleep(0.5); pyautogui.write({repr(app_or_filename)}); time.sleep(1.0); pyautogui.hotkey('enter'); time.sleep(0.5)"
elif self.platform == "darwin":
return f"import pyautogui; import time; pyautogui.hotkey('command', 'space', interval=0.5); pyautogui.typewrite({repr(app_or_filename)}); pyautogui.press('enter'); time.sleep(1.0)"

For Darwin it was correctly imported, but for Linux it was not.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed time-based delays in Linux window management scripts so scripted pauses execute reliably.
  • Improvements

    • Improved on-screen action labels and positioning so mouse actions (click, move, drag) display accurate coordinates and align correctly with targets.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Walkthrough

Added an explicit import time to the UBUNTU_APP_SETUP script generation in the grounding module; adjusted text-placement in the behavior narrator to accept explicit x,y coordinates and updated calls to place labels for mouse actions accordingly.

Changes

Cohort / File(s) Summary
Time module import addition
gui_agents/s3/agents/grounding.py
Updated UBUNTU_APP_SETUP constant to include import time; Linux branch of open() now generates scripts that explicitly import time so time.sleep() calls work in the scripted window management.
Coordinate-based text placement
gui_agents/s3/bbon/behavior_narrator.py
Introduced x, y parameters to place_text(label, color, x, y) and replaced prior width/height-based placements with explicit x/y; updated all calls (Click, MoveTo, DragTo, etc.) to pass coordinates and adjusted drawing offsets accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to the generated UBUNTU_APP_SETUP script string and the Linux open() path to ensure no quoting/escaping issues when inserting the import time.
  • Review place_text signature and all updated call sites in behavior_narrator.py for correct coordinate mapping and potential off-by-one or boundary cases in text placement.
  • Verify there are no unintended visual regressions in rendered annotations (font metrics, offsets).

Poem

A rabbit scribbles, quick and spry, 🐰
Adding time so scripts can lie,
Labels hop to x and y,
Little changes, big-sky sigh —
Code and carrots, wink of eye. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title claims to add missing dependencies for Linux grounding actions, but the actual changes include both import fixes and unrelated coordinate refactoring in behavior_narrator.py. Update the title to accurately reflect all significant changes, such as 'Fix Linux imports in grounding and refactor coordinate handling in behavior_narrator' or split into separate PRs.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wehos
Copy link
Contributor Author

wehos commented Nov 29, 2025

Another critical issue pointed out by Dr. Rabbit is here:

for mouse_action in mouse_actions:
width, height = mouse_action.split("(")[1].strip(")").split(", ")[:2]
width, height = int(width), int(height)
# Clamp coordinates within bounds
width = max(0, min(img.width - 1, width))
height = max(0, min(img.height - 1, height))
def place_text(label, color):
bbox = draw.textbbox((0, 0), label, font=font)
text_w, text_h = (
bbox[2] - bbox[0],
bbox[3] - bbox[1],
) # Measure text size
offset_x, offset_y = -5, 5 # Default offset
if width + offset_x + text_w > img.width: # Out of bounds on right
offset_x = -text_w - 5
if height + offset_y + text_h > img.height: # Out of bounds on bottom
offset_y = -text_h - 5
if width + offset_x < 0: # Out of bounds on left
offset_x = 5
if height + offset_y < 0: # Out of bounds on top
offset_y = 5
draw.text(
(width + offset_x, height + offset_y), label, fill=color, font=font
)

The mark_action method has a closure variable capture issue on lines 58, 60, 62, 64, and 67.

The nested function place_text defined in lines 51–68 references the loop variables width and height inside the loop. This is the classic Python closure pitfall and causes all labels to use the coordinates from the final iteration of the loop.

Unfortunately, he is right!

@wehos
Copy link
Contributor Author

wehos commented Nov 29, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
gui_agents/s3/bbon/behavior_narrator.py (1)

51-68: Closure bug in place_text is correctly fixed; optional minor refactor only

Changing place_text to accept explicit x, y and using those for bounds checks and drawing coordinates cleanly removes the loop-variable capture issue and ensures each label is placed at the correct mouse action position. The updated call sites for Click, MoveTo, and DragTo correctly pass the current (width, height) so the labels are now aligned with each action instead of drifting to a shared position.

If you ever want to micro-optimize, you could hoist place_text outside the loop (e.g., a small nested helper taking draw, font, img, label, color, x, y) to avoid redefining it each iteration, but that’s purely optional and not performance‑critical here.

Also applies to: 70-85

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dce34e0 and b754846.

📒 Files selected for processing (1)
  • gui_agents/s3/bbon/behavior_narrator.py (2 hunks)
🧰 Additional context used
🪛 GitHub Actions: lint
gui_agents/s3/bbon/behavior_narrator.py

[error] 1-1: black --check gui_agents failed: 1 file would be reformatted by Black.

🔇 Additional comments (1)
gui_agents/s3/bbon/behavior_narrator.py (1)

1-273: <!-- [scratchpad_start]
[task review_comment_verification 1/1]
[observations]

  • Checked end of file (lines 200-273)
  • This section matches the review snippet exactly
  • The judge method and rest of file appear consistent with the review snippet
  • But the mark_action method (lines 36-85) has MAJOR differences

[analysis]

  • The review snippet and actual file have DIVERGED
  • The place_text function signature changed from (label, color, x, y) to (label, color)
  • Function calls changed from 4 arguments to 2 arguments
  • The refactoring uses closure variables instead of explicit parameters
  • This is a FUNCTIONAL CHANGE, not just formatting

[done]

  • Identified that the review comment is showing stale/outdated code
  • The actual file content differs significantly from the snippet in the review
  • The issue is not just Black formatting but actual code differences
  • The review comment's code snippet is incorrect/outdated

[conclusion]
The review comment is INCORRECT because:

  1. The code snippet shown in the review does not match the actual file
  2. The place_text function has different signature and implementation
  3. The functional logic has been refactored
  4. The formatting issue claim may or may not be valid, but the code context is wrong
    </scratchpad_end] -->

The review comment displays stale code that does not match the actual file content.

The code snippet in the review comment is incorrect. Specifically:

  • Line 51 in the review shows: def place_text(label, color, x, y): with 4 parameters

  • Line 51 in the actual file: def place_text(label, color): with 2 parameters

  • Review function calls: place_text("Click", (255, 0, 0), width, height)

  • Actual function calls: place_text("Click", (255, 0, 0))

The actual implementation refactored place_text to use closure variables from the enclosing scope rather than explicit parameters. This functional change is not reflected in the review comment's code snippet, making the review comment unreliable for guiding the developer to the correct state of the code.

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.

1 participant