Repository navigation
feat: give each worktree its own dev-server port - #126
Merged
Merged
Conversation
Two worktrees of one project both ran `pnpm dev` and both wanted the framework's default port, so the second one lost — and the setup script that had just installed the dependencies had no way to know it should have picked another number. Every session now starts with LICH_WORKTREE_PORT set to a port derived from its checkout's path, so a setup script (or a command typed in the terminal) reads `PORT=$LICH_WORKTREE_PORT pnpm dev` and both worktrees come up. The port is a pure function of the path: the same checkout gets the same number across restarts of the session and of lich. The variable is derived from the session's start directory alone, so it is exported even when the transport failed to start — unlike LICH_PORT, which addresses that transport. It is deliberately not LICH_PORT: that name is the hook listener (docs/hooks/README.md). Nothing probes and nothing binds — two checkouts can hash to the same number, and only the dev server started second finds out. Probing was the alternative and it costs the stability that is the point: the previous server still holding the port would move it on every restart. Recorded as a Known Ceiling. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Rne8dofV1xs996xDBhRWH
This was referenced Jul 29, 2026
Merged
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.
Two worktrees of one project both ran
pnpm devand both wanted theframework's default port, so the second one lost — and the setup script
that had just installed the dependencies had no way to know it should
have picked another number.
Every session now starts with LICH_WORKTREE_PORT set to a port derived
from its checkout's path, so a setup script (or a command typed in the
terminal) reads
PORT=$LICH_WORKTREE_PORT pnpm devand both worktreescome up. The port is a pure function of the path: the same checkout gets
the same number across restarts of the session and of lich.
The variable is derived from the session's start directory alone, so it
is exported even when the transport failed to start — unlike LICH_PORT,
which addresses that transport. It is deliberately not LICH_PORT: that
name is the hook listener (docs/hooks/README.md).
Nothing probes and nothing binds — two checkouts can hash to the same
number, and only the dev server started second finds out. Probing was
the alternative and it costs the stability that is the point: the
previous server still holding the port would move it on every restart.
Recorded as a Known Ceiling.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_018Rne8dofV1xs996xDBhRWH