π OpenHands: AI-Driven Development
Fix for app/worker urls (#9980)
Tim O'Farrell2c36e2447c89
diff --git a/openhands/runtime/impl/local/local_runtime.py b/openhands/runtime/impl/local/local_runtime.pyindex e31016fbbe..54c3289c4a 100644--- a/openhands/runtime/impl/local/local_runtime.py+++ b/openhands/runtime/impl/local/local_runtime.py@@ -575,25 +575,30 @@ class LocalRuntime(ActionExecutionClient):# Fallback to localhostreturn self.config.sandbox.local_runtime_url- @property- def vscode_url(self) -> str | None:- token = super().get_vscode_token()- if not token:- return None+ def _create_url(self, prefix: str, port: int) -> str:runtime_url = self.runtime_urlif 'localhost' in runtime_url:- vscode_url = f'{self.runtime_url}:{self._vscode_port}'+ url = f'{self.runtime_url}:{self._vscode_port}'else:# Similar to remote runtime...parsed_url = urlparse(runtime_url)- vscode_url = f'{parsed_url.scheme}://vscode-{parsed_url.netloc}'+ url = f'{parsed_url.scheme}://{prefix}-{parsed_url.netloc}'+ return url++ @property+ def vscode_url(self) -> str | None:+ token = super().get_vscode_token()+ if not token:+ return None+ vscode_url = self._create_url('vscode', self._vscode_port)return f'{vscode_url}/?tkn={token}&folder={self.config.workspace_mount_path_in_sandbox}'@propertydef web_hosts(self) -> dict[str, int]:hosts: dict[str, int] = {}- for port in self._app_ports:- hosts[f'{self.runtime_url}:{port}'] = port+ for index, port in enumerate(self._app_ports):+ url = self._create_url(f'work-{index + 1}', port)+ hosts[url] = portreturn hosts