| 129 | return False |
| 130 | |
| 131 | def open_browser_when_ready(): |
| 132 | print("Waiting for web UI to be ready...") |
| 133 | for line in iter(self.ui_process.stdout.readline, ""): |
| 134 | if not line: |
| 135 | break |
| 136 | print(line.strip()) |
| 137 | if any(msg in line for msg in [ |
| 138 | "Running on", "127.0.0.1:5005", "0.0.0.0:5005", |
| 139 | "Password set", "Server starting" |
| 140 | ]): |
| 141 | print("Web UI is ready! Opening browser...") |
| 142 | time.sleep(1) |
| 143 | try: |
| 144 | if sys.platform == "darwin": |
| 145 | subprocess.run(["open", "http://127.0.0.1:5005"], check=False) |
| 146 | elif sys.platform == "win32": |
| 147 | subprocess.run(["start", "http://127.0.0.1:5005"], shell=True, check=False) |
| 148 | else: |
| 149 | subprocess.run(["xdg-open", "http://127.0.0.1:5005"], check=False) |
| 150 | except Exception as e: |
| 151 | print(f"Note: Could not open browser automatically: {e}") |
| 152 | print("Please open http://127.0.0.1:5005 in your browser") |
| 153 | break |
| 154 | |
| 155 | threading.Thread(target=open_browser_when_ready, daemon=True).start() |
| 156 | return True |