chore: share worktree port assignment, document both worktree managers - #10727
Draft
hugocasa wants to merge 3 commits into
Draft
chore: share worktree port assignment, document both worktree managers#10727hugocasa wants to merge 3 commits into
hugocasa wants to merge 3 commits into
Conversation
The slot scan and the .env.local writer existed twice, once inline in scripts/worktree-env and once in scripts/post-create.sh. Both are now wm_assign_ports and wm_write_env_local in scripts/worktree-common.sh, so a third caller cannot drift from the other two. wm_assign_ports takes the worktree root instead of reading the process cwd, which lets it run from outside the worktree, and prints its slot line to stderr so stdout carries only the port pair. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The section assumed webmux and tmux throughout. Worktree tooling is being trialled on herdr alongside it, so the detection markers and the pane inspection commands now appear side by side. Corrects the pointer for per-worktree values: .env.local is written by both managers through wm_write_env_local and is readable, so it is the portable source. webmux's runtime.env stays documented as the place carrying the extras .env.local lacks. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deploying windmill with
|
| Latest commit: |
1c42763
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b40bdad8.windmill.pages.dev |
| Branch Preview URL: | https://share-worktree-port-assignme.windmill.pages.dev |
Naming the repo left the reader to work out what to do with it. The plugins do nothing until they are installed and their actions are bound, and Herdr has no action palette to discover them through. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The per-worktree port slot scan and the
.env.localwriter were duplicated: once inline inscripts/worktree-env, once inscripts/post-create.sh. This lifts both intoscripts/worktree-common.shso every caller shares one implementation, and updates theAGENTS.mddev environment section to match.The motivating third caller lives outside this repo. Worktree tooling is being trialled on
herdr alongside the existing setup, and its hooks need the same slot
arithmetic. Sharing the helpers means both paths draw from one port registry (each worktree's
.env.local) and cannot hand out the same slot twice.No behaviour change for existing callers, and nothing about the webmux setup changes.
Changes
wm_port_in_use,wm_assign_portsandwm_write_env_localtoscripts/worktree-common.shscripts/worktree-env: drop the inline slot scan and heredoc, call the helpersscripts/post-create.sh: drop the duplicated heredoc, callwm_write_env_localwm_assign_portstakes the worktree root as an argument rather than reading the process cwd,so it can run from outside the worktree, and prints its slot line to stderr so stdout carries
only the port pair
AGENTS.md: the dev environment section assumed webmux and tmux throughout. It now shows thedetection marker and pane inspection commands for both managers side by side
The
AGENTS.mdchange also corrects a stale pointer. The section sent readers towebmux/runtime.envon the grounds that.env.localwould trip the secret-file read rules. Itdoes not, only
.envdoes. Since both managers write.env.localthrough the same helper, it isthe portable source;
runtime.envstays documented as the place carrying the extras.env.locallacks (
WEBMUX_*,WM_CLONE_DB,USE_RUST_PLUGIN).Test plan
bash -non all five worktree scriptswm_assign_portson the main checkout returns the lowest free slot, skipping the 28 slotsalready claimed by existing worktrees
wm_write_env_localwritesBACKEND_PORT,FRONTEND_PORT,REMOTEandCARGO_FEATURESidentically to the previous heredocs
served on its assigned port, frontend returned 200 against it
.env.localis present with the same keys in both a webmux worktree and a herdrone, and is readable
Summary by cubic
Shares per-worktree port assignment and
.env.localwriting across worktree tooling, and documents both worktree managers. This prevents slot collisions, keepswebmux,herdr, and repo scripts in sync, and clarifies.env.localas the portable source of per-worktree values.wm_port_in_use,wm_assign_ports(<repo_root>), andwm_write_env_local(<repo_root> <backend> <frontend>)inscripts/worktree-common.sh; updatesscripts/worktree-envandscripts/post-create.shto call them. Behavior change:wm_assign_portsrequires the worktree root and logs its slot message to stderr; stdout emits only "<backend_port> <frontend_port>"..env.localand picks the lowest free slot; it warns if the chosen ports are already in use.AGENTS.mdnow shows detection markers and pane inspect/log commands for bothwebmuxandherdr, points to.env.localas authoritative, keepswebmux’swebmux/runtime.envdocumented for extras, addsherdrplugin setup (windmill-labs/windmill-herdr,./setup.sh), and clarifies whereWM_CLONE_DBis configured under each manager.Written for commit 1c42763. Summary will update on new commits.