Skip to content

Commit f993f5c

Browse files
authored
Merge pull request #20 from nandatheguntupalli/main
2 parents ca0b158 + 85d0364 commit f993f5c

File tree

9 files changed

+692
-358
lines changed

9 files changed

+692
-358
lines changed

.github/workflows/ruff.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Ruff Lint
2+
3+
on:
4+
push:
5+
branches: ["main", "master"]
6+
pull_request:
7+
branches: ["main", "master"]
8+
9+
jobs:
10+
ruff:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Run Ruff
17+
uses: astral-sh/ruff-action@v3

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.11.9
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
args: [ --fix, --exit-zero ]
9+
# Run the formatter.
10+
- id: ruff-format

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ requires = ["setuptools"]
2727
build-backend = "setuptools.build_meta"
2828

2929
[tool.setuptools.package-data]
30-
webEvalAgent = ["templates/**", "src/agent_overlay.js", "src/**"]
30+
webEvalAgent = ["templates/**", "src/agent_overlay.js", "src/**"]

webEvalAgent/src/browser_manager.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ async def open_url(self, url: str) -> str:
196196
send_log(f"Failed to start CDP screencast: {e}", "❌", log_type='status')
197197
self.screencast_task_running = False
198198
if self.cdp_session:
199-
try: await self.cdp_session.detach()
200-
except: pass
201-
self.cdp_session = None
199+
try:
200+
await self.cdp_session.detach()
201+
except Exception:
202+
pass
203+
self.cdp_session = None
202204
return f"Opened {url}, but failed to start screen streaming."
203205

204206
return f"Opened {url} successfully in headless mode. Streaming view to dashboard."
@@ -289,8 +291,10 @@ async def _handle_screencast_frame(self, params: Dict) -> None:
289291
if "Target closed" in str(e) or "Session closed" in str(e) or "Connection closed" in str(e):
290292
self.screencast_task_running = False # Mark as stopped
291293
if self.cdp_session:
292-
try: await self.cdp_session.detach()
293-
except: pass
294+
try:
295+
await self.cdp_session.detach()
296+
except Exception:
297+
pass
294298
self.cdp_session = None
295299

296300

@@ -433,17 +437,21 @@ async def handle_browser_input(self, event_type: str, details: Dict) -> None:
433437
send_log("CDP session closed, stopping input handling", "⚠️", log_type='status')
434438
self.screencast_task_running = False # Mark as stopped
435439
if self.cdp_session:
436-
try:
440+
try:
437441
await self.cdp_session.detach()
438-
except:
442+
except Exception:
439443
pass
440444
self.cdp_session = None
441445

442446
def _map_modifiers(self, details: Dict) -> int:
443447
"""Maps modifier keys from frontend details to CDP modifier bitmask."""
444448
modifiers = 0
445-
if details.get('altKey'): modifiers |= 1
446-
if details.get('ctrlKey'): modifiers |= 2
447-
if details.get('metaKey'): modifiers |= 4 # Command key on Mac
448-
if details.get('shiftKey'): modifiers |= 8
449+
if details.get('altKey'):
450+
modifiers |= 1
451+
if details.get('ctrlKey'):
452+
modifiers |= 2
453+
if details.get('metaKey'):
454+
modifiers |= 4 # Command key on Mac
455+
if details.get('shiftKey'):
456+
modifiers |= 8
449457
return modifiers

0 commit comments

Comments
 (0)