@@ -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