fix(agent): handle zero coordinates in predict_click#1495
Conversation
The truthiness check on action.get('x') and action.get('y') falsely
rejected x=0 or y=0 since 0 is falsy in Python. Changed to explicit
is not None check so that valid zero coordinates are accepted.
Closes trycua#1400
|
@xronocode is attempting to deploy a commit to the Cua Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes a coordinate validation bug in ChangesZero-coordinate validation fix and tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
Summary
Small fix for #1400 —
predict_clicksilently returnedNonewhen eitherxorywas0, since the existing truthiness check treated0as falsy.Before:
if action.get("x") and action.get("y")After:
if action.get("x") is not None and action.get("y") is not NoneChanges
libs/python/agent/cua_agent/loops/anthropic.py— one-line fix at the coordinate validation checklibs/python/agent/tests/test_predict_click.py— 5 regression tests covering(0, y),(x, 0),(0, 0), normal coordinates, and no-click responseTesting
All 29 tests pass (24 existing + 5 new):
test_predict_click_x_zero— click at (0, 300) returns(0, 300), notNonetest_predict_click_y_zero— click at (500, 0) returns(500, 0), notNonetest_predict_click_both_zero— click at (0, 0) returns(0, 0), notNonetest_predict_click_normal_coordinates— click at (512, 384) works as beforetest_predict_click_no_click_action— text-only response returnsNoneHappy to adjust anything — thanks for the great project!
Summary by CodeRabbit
Bug Fixes
(0, 0)or withx=0/y=0).Tests