diff --git a/main.py b/main.py index 905b746..c491f45 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ +import webbrowser from os_computer_use.streaming import Sandbox, DisplayClient -from os_computer_use.browser import Browser from os_computer_use.sandbox_agent import SandboxAgent from os_computer_use.logging import Logger import asyncio @@ -39,8 +39,7 @@ async def start(user_input=None, output_dir=None): vnc_url = sandbox.stream.get_url() print("Starting the VNC client...") - browser = Browser() - browser.open(vnc_url) + webbrowser.open(vnc_url) while True: # Ask for user input, and exit if the user presses ctl-c @@ -82,12 +81,6 @@ async def start(user_input=None, output_dir=None): # except Exception as e: # print(f"Error saving stream: {str(e)}") - print("Stopping the VNC client...") - try: - browser.close() - except Exception as e: - print(f"Error stopping VNC client: {str(e)}") - def initialize_output_directory(directory_format): run_id = 1 diff --git a/os_computer_use/browser.py b/os_computer_use/browser.py deleted file mode 100644 index f044366..0000000 --- a/os_computer_use/browser.py +++ /dev/null @@ -1,77 +0,0 @@ -import time -import threading -from multiprocessing import Process, Queue -import webview - - -class Browser: - def __init__(self): - self.width = 1024 - self.height = 768 - self.window_frame_height = 29 # Additional px for window border - self.command_queue = Queue() - self.webview_process = None - self.is_running = False - - def open(self, url, width=None, height=None): - """ - Open a browser window with the given URL - - Args: - url (str): The URL to open - width (int, optional): Window width - height (int, optional): Window height - """ - if self.is_running: - print("Browser window is already running") - return - - self.width = width or self.width - self.height = height or self.height - - print(f"URL: {url}") - - # Start webview in separate process - self.webview_process = Process( - target=self._create_window, - args=(url, self.width, self.height, self.command_queue), - ) - self.webview_process.start() - self.is_running = True - - def close(self): - """Close the browser window""" - if not self.is_running: - print("No browser window is running") - return - - self.command_queue.put("close") - if self.webview_process: - self.webview_process.join() - self.webview_process = None - self.is_running = False - - @staticmethod - def _create_window(url, width, height, command_queue): - """Create a webview window in a separate process""" - - def check_queue(): - while True: - if not command_queue.empty(): - command = command_queue.get() - if command == "close": - window.destroy() - break - time.sleep(1) # Check every second - - window_frame_height = 29 - window = webview.create_window( - "Browser Window", url, width=width, height=height + window_frame_height - ) - - # Start queue checking in a separate thread - t = threading.Thread(target=check_queue) - t.daemon = True - t.start() - - webview.start()