Skip to content

fix: worktree mounts its own code + hosts entry stays in sync - #16

Merged
graphicfox merged 2 commits into
masterfrom
fix/worktree-mounts-hosts
Jul 17, 2026
Merged

fix: worktree mounts its own code + hosts entry stays in sync#16
graphicfox merged 2 commits into
masterfrom
fix/worktree-mounts-hosts

Conversation

@graphicfox

Copy link
Copy Markdown
Contributor

4.3.1 — worktree apps now serve their OWN branch

Follow-up to the 4.3.0 retest. 4.3.0 fixed startup/IP/port; these two fixes make a worktree app actually usable for testing its own branch.

BUG A (critical) — worktree bind-mounted the MAIN checkout's code

APP_ROOT_DIR / APP_WORKING_DIR / APP_OPT_DIR (and the other APP_*_DIR) came from the shared .env and pointed at the main app, so the "worktree app" was just a second copy of main on a different IP (worktree-only routes 404'd).

AppIdentity now repoints the declared directory variables at the worktree's own paths and injects them into docker compose (creating them if missing). The container serves the worktree's code/config. .env is still never rewritten.

BUG B — worktree domain resolved to the main app's IP

The hosts entry was only written during init, which is skipped when the docker-file hash is unchanged — so after upgrading, the worktree domain could still point at main's IP. The hosts entry is now re-synced with the effective identity on every lab up (writes only when it changed), so the worktree domain always points at the worktree IP.

BUG C — already fixed (usage note)

down and test gained -y/--yes in 4.1.0: use lab down -y / lab test -y for headless runs (they were run without -y in the report).

Verification

npm run build ✅ · npm test ✅ (29 suites / 61 tests; new AppIdentity tests assert the worktree dir overrides + that only declared vars are injected + none in a main checkout).

🤖 Generated with Claude Code

Kim Martini and others added 2 commits July 17, 2026 15:48
… in sync

Two follow-ups to the 4.3.0 worktree isolation:

- BUG A: the worktree container still bind-mounted the MAIN checkout's code,
  because APP_ROOT_DIR / APP_WORKING_DIR / APP_OPT_DIR (and the other APP_*_DIR)
  came from the shared .env and pointed at the main app. AppIdentity now repoints
  the declared directory variables at the WORKTREE's own paths and injects them
  into docker compose (and creates them if missing), so the worktree app serves
  its own branch's code / config instead of the main checkout's.

- BUG B: the worktree domain could resolve to the main app's ip because the hosts
  entry was only written during init (which is skipped when the docker-file hash
  is unchanged). The hosts entry is now re-synced with the effective identity on
  every "lab up", so the worktree domain always points at the worktree ip.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@graphicfox
graphicfox merged commit 8beb56c into master Jul 17, 2026
1 check passed
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