Skip to content

bug(computer-server): scroll command requires x,y on Android but API doesn't document this #877

@f-trycua

Description

@f-trycua

Description

The scroll command on Android requires x and y parameters, but calling it with just direction fails with a confusing error.

Steps to Reproduce

curl -X POST http://localhost:8000/cmd -H "Content-Type: application/json" \
  -d '{"command":"scroll","params":{"direction":"down"}}'

Error

{"success": false, "error": "AndroidAutomationHandler.scroll() missing 2 required positional arguments: 'x' and 'y'"}

Expected Behavior

Either:

  1. The scroll command should work with just direction (using screen center as default)
  2. Or the error message should clearly indicate that x and y are required on Android

Suggested Fix

In AndroidAutomationHandler.scroll(), provide default values for x and y:

async def scroll(self, direction: str, x: int = None, y: int = None, amount: int = 1):
    if x is None or y is None:
        # Use screen center as default
        screen_size = await self.get_screen_size()
        x = x or screen_size['width'] // 2
        y = y or screen_size['height'] // 2
    # ... rest of implementation

Environment

  • cua-computer-server: 0.3.9
  • Platform: Android 11 (emulator)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions