From b9af0188fe3b43cf8f280dd52e25008c6dff14e4 Mon Sep 17 00:00:00 2001 From: tofarr Date: Wed, 26 Mar 2025 16:01:23 -0600 Subject: [PATCH] Feat vscode startup (#7518) Co-authored-by: OpenHands Bot --- openhands/runtime/plugins/vscode/__init__.py | 4 ++-- openhands/runtime/plugins/vscode/settings.json | 4 ++++ openhands/runtime/utils/runtime_templates/Dockerfile.j2 | 7 +++++++ openhands/server/file_config.py | 9 ++++++++- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 openhands/runtime/plugins/vscode/settings.json diff --git a/openhands/runtime/plugins/vscode/__init__.py b/openhands/runtime/plugins/vscode/__init__.py index 0a93d6b3e9..efa7036a1b 100644 --- a/openhands/runtime/plugins/vscode/__init__.py +++ b/openhands/runtime/plugins/vscode/__init__.py @@ -37,10 +37,10 @@ class VSCodePlugin(Plugin): f"su - {username} -s /bin/bash << 'EOF'\n" f'sudo chown -R {username}:{username} /openhands/.openvscode-server\n' 'cd /workspace\n' - f'exec /openhands/.openvscode-server/bin/openvscode-server --host 0.0.0.0 --connection-token {self.vscode_connection_token} --port {self.vscode_port}\n' + f'exec /openhands/.openvscode-server/bin/openvscode-server --host 0.0.0.0 --connection-token {self.vscode_connection_token} --port {self.vscode_port} --disable-workspace-trust\n' 'EOF' ) - print(cmd) + self.gateway_process = subprocess.Popen( cmd, stderr=subprocess.STDOUT, diff --git a/openhands/runtime/plugins/vscode/settings.json b/openhands/runtime/plugins/vscode/settings.json new file mode 100644 index 0000000000..77c19483b7 --- /dev/null +++ b/openhands/runtime/plugins/vscode/settings.json @@ -0,0 +1,4 @@ +{ + "workbench.colorTheme": "Default Dark Modern", + "workbench.startupEditor": "none" +} \ No newline at end of file diff --git a/openhands/runtime/utils/runtime_templates/Dockerfile.j2 b/openhands/runtime/utils/runtime_templates/Dockerfile.j2 index bde8d45f70..f7b95cde4a 100644 --- a/openhands/runtime/utils/runtime_templates/Dockerfile.j2 +++ b/openhands/runtime/utils/runtime_templates/Dockerfile.j2 @@ -135,6 +135,9 @@ RUN \ COPY ./code/pyproject.toml ./code/poetry.lock /openhands/code/ +COPY ./code/openhands/runtime/plugins/vscode/settings.json /workspace/.vscode/settings.json +RUN chmod -R a+rwx /workspace/.vscode/settings.json + {{ install_dependencies() }} # ================================================================ @@ -147,6 +150,10 @@ COPY ./code/pyproject.toml ./code/poetry.lock /openhands/code/ # ================================================================ RUN if [ -d /openhands/code/openhands ]; then rm -rf /openhands/code/openhands; fi COPY ./code/pyproject.toml ./code/poetry.lock /openhands/code/ + +COPY ./code/openhands/runtime/plugins/vscode/settings.json /workspace/.vscode/settings.json +RUN chmod -R a+rwx /workspace/.vscode/settings.json + COPY ./code/openhands /openhands/code/openhands RUN chmod a+rwx /openhands/code/openhands/__init__.py diff --git a/openhands/server/file_config.py b/openhands/server/file_config.py index 29d1c2bf61..1e4d6c5314 100644 --- a/openhands/server/file_config.py +++ b/openhands/server/file_config.py @@ -5,7 +5,14 @@ from openhands.core.config import AppConfig from openhands.core.logger import openhands_logger as logger from openhands.server.shared import config as shared_config -FILES_TO_IGNORE = ['.git/', '.DS_Store', 'node_modules/', '__pycache__/', 'lost+found/'] +FILES_TO_IGNORE = [ + '.git/', + '.DS_Store', + 'node_modules/', + '__pycache__/', + 'lost+found/', + '.vscode/', +] def sanitize_filename(filename):