Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Feat vscode startup (#7518)

tofarrb9af0188fe3b
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):