From e8c64f4731be42ab894d865b72e1e65ea5ba4e42 Mon Sep 17 00:00:00 2001 From: Marco D'Alia Date: Sat, 27 Jun 2026 15:48:35 +0100 Subject: [PATCH] feat(box): land interactive SSH/login shells in /workspace Adding a box as a remote host (Codex app, VS Code Remote-SSH, plain `ssh `) opened the session in /home/vscode instead of the project at /workspace. SSH config has no start-directory directive, and the only client-side option (RemoteCommand) would break scp/sftp and VS Code's remote bootstrap on the same shared alias. So fix it server-side: make interactive login shells cd into /workspace via the existing /etc/profile.d/agentbox.sh shim every box installs. Guarded to interactive shells only (scp/sftp and `ssh box ` untouched) and only when still at $HOME (never overrides a caller-chosen dir, e.g. agentbox's own tmux `-c /workspace`). Applied to all provider shims for consistency: hetzner, vercel, e2b, and the canonical docker Dockerfile.box. Claude-Session: https://claude.ai/code/session_01An9tT8HqjQoGKKVWuYg4bb --- packages/sandbox-docker/Dockerfile.box | 9 +++++++++ packages/sandbox-e2b/scripts/build-template.sh | 12 ++++++++++++ packages/sandbox-hetzner/scripts/install-box.sh | 12 ++++++++++++ packages/sandbox-vercel/scripts/provision.sh | 12 ++++++++++++ 4 files changed, 45 insertions(+) diff --git a/packages/sandbox-docker/Dockerfile.box b/packages/sandbox-docker/Dockerfile.box index 98e87ac..e41a5f8 100644 --- a/packages/sandbox-docker/Dockerfile.box +++ b/packages/sandbox-docker/Dockerfile.box @@ -510,6 +510,15 @@ RUN printf '%s\n' \ ' . /etc/agentbox/box.env' \ ' set +a' \ 'fi' \ + '# Land interactive login shells in the workspace (remote-host integrations,' \ + '# plain `ssh `); interactive-only and only when still at $HOME.' \ + 'case $- in' \ + ' *i*)' \ + ' if [ "$PWD" = "$HOME" ] && [ -d /workspace ]; then' \ + ' cd /workspace' \ + ' fi' \ + ' ;;' \ + 'esac' \ > /etc/profile.d/agentbox.sh \ && chmod 0644 /etc/profile.d/agentbox.sh diff --git a/packages/sandbox-e2b/scripts/build-template.sh b/packages/sandbox-e2b/scripts/build-template.sh index d1c3852..57a8e94 100755 --- a/packages/sandbox-e2b/scripts/build-template.sh +++ b/packages/sandbox-e2b/scripts/build-template.sh @@ -244,6 +244,18 @@ export DISABLE_AUTOUPDATER=${DISABLE_AUTOUPDATER:-1} export DISPLAY=${DISPLAY:-:1} export AGENT_BROWSER_EXECUTABLE_PATH=${AGENT_BROWSER_EXECUTABLE_PATH:-/usr/local/bin/chromium} export BROWSER=${BROWSER:-/usr/local/bin/agentbox-open} +# Land interactive login shells in the workspace, so remote-host integrations +# (Codex app, VS Code Remote-SSH, plain `ssh `) open in the project instead +# of $HOME. Interactive-only so scp/sftp and `ssh box ` are untouched; only +# when still at $HOME so a caller-chosen dir (e.g. agentbox's tmux `-c /workspace`) +# is never overridden. +case $- in + *i*) + if [ "$PWD" = "$HOME" ] && [ -d /workspace ]; then + cd /workspace + fi + ;; +esac PROFILE chmod 0644 /etc/profile.d/agentbox.sh done_ "login-shell shim (/etc/profile.d/agentbox.sh)" diff --git a/packages/sandbox-hetzner/scripts/install-box.sh b/packages/sandbox-hetzner/scripts/install-box.sh index ee9ddbc..17aaa3e 100644 --- a/packages/sandbox-hetzner/scripts/install-box.sh +++ b/packages/sandbox-hetzner/scripts/install-box.sh @@ -290,6 +290,18 @@ export LC_ALL=${LC_ALL:-en_US.UTF-8} export DISPLAY=${DISPLAY:-:1} export AGENT_BROWSER_EXECUTABLE_PATH=${AGENT_BROWSER_EXECUTABLE_PATH:-/usr/local/bin/chromium} export BROWSER=${BROWSER:-/usr/local/bin/agentbox-open} +# Land interactive login shells in the workspace, so remote-host integrations +# (Codex app, VS Code Remote-SSH, plain `ssh `) open in the project instead +# of $HOME. Interactive-only so scp/sftp and `ssh box ` are untouched; only +# when still at $HOME so a caller-chosen dir (e.g. agentbox's tmux `-c /workspace`) +# is never overridden. +case $- in + *i*) + if [ "$PWD" = "$HOME" ] && [ -d /workspace ]; then + cd /workspace + fi + ;; +esac PROFILE chmod 0644 /etc/profile.d/agentbox.sh done_ "login-shell shim (/etc/profile.d/agentbox.sh)" diff --git a/packages/sandbox-vercel/scripts/provision.sh b/packages/sandbox-vercel/scripts/provision.sh index b87cb45..ed0e3f6 100644 --- a/packages/sandbox-vercel/scripts/provision.sh +++ b/packages/sandbox-vercel/scripts/provision.sh @@ -269,6 +269,18 @@ export DISABLE_AUTOUPDATER=${DISABLE_AUTOUPDATER:-1} export DISPLAY=${DISPLAY:-:1} export AGENT_BROWSER_EXECUTABLE_PATH=${AGENT_BROWSER_EXECUTABLE_PATH:-/usr/local/bin/chromium} export BROWSER=${BROWSER:-/usr/local/bin/agentbox-open} +# Land interactive login shells in the workspace, so remote-host integrations +# (Codex app, VS Code Remote-SSH, plain `ssh `) open in the project instead +# of $HOME. Interactive-only so scp/sftp and `ssh box ` are untouched; only +# when still at $HOME so a caller-chosen dir (e.g. agentbox's tmux `-c /workspace`) +# is never overridden. +case $- in + *i*) + if [ "$PWD" = "$HOME" ] && [ -d /workspace ]; then + cd /workspace + fi + ;; +esac PROFILE chmod 0644 /etc/profile.d/agentbox.sh done_ "login-shell shim (/etc/profile.d/agentbox.sh)"