Skip to content

refactor: Clean up browser action handling and fix linting issues#60

Open
breeznik wants to merge 1 commit intogoogle-gemini:mainfrom
breeznik:refactor/browser-actions
Open

refactor: Clean up browser action handling and fix linting issues#60
breeznik wants to merge 1 commit intogoogle-gemini:mainfrom
breeznik:refactor/browser-actions

Conversation

@breeznik
Copy link

@breeznik breeznik commented Oct 8, 2025

PR Summary
This PR cleans up the browser action handling code and fixes some linting warnings.

Changes

  • Refactored browser actions into a dictionary-based mapping for clearer structure and easier extensibility.
  • Split action handling into separate functions to follow better coding practices and improve maintainability.
  • Fixed unnecessary f-strings that didn’t have placeholders and printed Catched errors, resolving linter warnings.

Why

  • Follows better practices for code organization and readability.
  • Makes it easier to extend and maintain the code in the future.

Testing Results
All existing tests pass:

=========================== test session starts ============================
platform win32 -- Python 3.13.5, pytest-8.4.2, pluggy-1.6.0 -- C:\projects\personal\computer-use-preview\.venv\Scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\projects\personal\computer-use-preview
plugins: anyio-4.11.0
collected 11 items                                                          

test_agent.py::TestBrowserAgent::test_denormalize_x PASSED            [  9%]
test_agent.py::TestBrowserAgent::test_denormalize_y PASSED            [ 18%]
test_agent.py::TestBrowserAgent::test_handle_action_click_at PASSED   [ 27%]
test_agent.py::TestBrowserAgent::test_handle_action_navigate PASSED   [ 36%]
test_agent.py::TestBrowserAgent::test_handle_action_open_web_browser PASSED                                                            [ 45%]
test_agent.py::TestBrowserAgent::test_handle_action_scroll_document PASSED                                                             [ 54%]
test_agent.py::TestBrowserAgent::test_handle_action_type_text_at PASSED                                                                [ 63%]
test_agent.py::TestBrowserAgent::test_handle_action_unknown_function PASSED                                                            [ 72%]
test_agent.py::TestBrowserAgent::test_multiply_numbers PASSED                                                                          [ 81%]
test_agent.py::TestBrowserAgent::test_run_one_iteration_no_function_calls PASSED                                                       [ 90%]
test_agent.py::TestBrowserAgent::test_run_one_iteration_with_function_call PASSED                                                      [100%]

============================================================ 11 passed in 12.25s ============================================================ 

@google-cla
Copy link

google-cla bot commented Oct 8, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@breeznik breeznik force-pushed the refactor/browser-actions branch from 70dbac5 to 799c0b2 Compare October 8, 2025 02:37
- Refactored browser actions into dictionary-based mapping for better organization
- Modularized action handling functions for improved maintainability
- Fixed f-string where safety['decision'] variable wasn't inside curly braces
@breeznik breeznik force-pushed the refactor/browser-actions branch from 6b7a169 to b762c23 Compare October 9, 2025 04:54
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