Skip to content

feat: pass a dynamically allocated open port to the sandbox IDE relay - #80

Open
amannocci wants to merge 1 commit into
mainfrom
feat/dynamic-ide-relay-port
Open

amannocci wants to merge 1 commit into
mainfrom
feat/dynamic-ide-relay-port

Conversation

@amannocci

Copy link
Copy Markdown
Member

🧑‍💻What is the change being made?

The host-side IDE relay of the Claude sandbox now listens on a free loopback port chosen by the OS at each launch, instead of the fixed port 41337. The port is handed to the container through IDE_RELAY_PORT: devcontainer.json passes it to init-sandbox.sh, which opens the egress firewall for that single port on the host, and claude.sh reads it for the lock file and the socat forward. The sudoers rule now also accepts one numeric argument, and init-sandbox.sh only honours the first port given after each container start.

❓ Why is the change being made?

A fixed port fails whenever it is already taken on the host, for example by a second sandbox session or another program, and the IDE bridge is then silently disabled. Letting the OS pick a free port removes that collision and the need to keep three files in sync on one constant.

✅ How has this been tested?

Ran ruff format and ruff check on scripts/tasks/sandbox.py, and bash -n on claude.sh and init-sandbox.sh. The pre-commit hooks pass. The sandbox was not launched end to end with an IDE attached, so that flow still needs a manual run.

📚 How has this been documented?

Updated the sandbox section of README.md to say the relay uses a free loopback port picked at each launch. Comments in the touched scripts describe how the port travels from the host to the firewall and to claude.sh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant