Correct the Worktrees docs and the worktree lifecycle contract - #991
Merged
Conversation
Nightly docs audit — deep-dive on the docs-pane Worktrees section against `shared/git/worktree.ts`, `agents/tmux/setup-script.ts`, `agents/archive.ts` and the create-agent dialog. - Worktree location: the instance setting is read by the create-agent route, `dispatch_launch_agent` and the assisted-update path, but neither `TemplateService.launchTemplate` nor `JobService` passes it, so template launches and job runs always get the sibling path. Say so, and point at Settings → Agents rather than just "Settings". - Note that templates and jobs create worktrees through the same machinery (nothing said so anywhere). - The starting branch is remembered per working directory too, not just the new-branch checkbox. - api-spec: `createNewBranch: false` checks out `baseBranch` and ignores `worktreeBranch` — the old sentence had it backwards. Added where placement comes from. - agent-lifecycle: the setup script never posts `setup/phase: worktree` (it's the initial value written at insert), it unsets `DATABASE_URL` before sourcing `~/.dispatch/env`, and worktree creation is the only unrecoverable step. Documented the branch deletion `cleanupGitWorktree` performs on archive. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WBq8dmFViUshsBQodr8UXa
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 freeto 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.
Nightly docs audit. Deep-dive on the docs-pane Worktrees section (the
next_focuscarried over from #988), audited againstapps/server/src/shared/git/worktree.ts,apps/server/src/agents/tmux/setup-script.ts,apps/server/src/agents/archive.ts,apps/server/src/agents/manager.tsand the create-agent dialog.Diff since the last audit (
301b1f6a) was #986 (tilde resolution, already documented in the runbook), #989 (wire types), #990 (tests) and #988 (the previous run's own docs PR) — nothing doc-bearing, so no pivot.Verified clean (no change needed)
Creation flow and
.envcopy; lockfile priority pnpm → yarn → npm → bun and theterminal-type deps skip; the failure path (markSetupFailedwritesstopped+ ablockedlatest event, partial worktree/branch removed, no fallback to the primary checkout); both branch modes; theoriginfetch and its local-branch fallback; archive cleanup semantics (auto/keep/force,dispatchOwnsBranch, existing-branch worktrees keeping their branch); the per-cwd new-branch preference.Fixed
crud-routes.ts,mcp-handlers.ts(dispatch_launch_agent) andrelease.tsall read it, but neitherTemplateService.launchTemplatenorJobService.runJobpassesworktreeLocation, soinput.worktreeLocation ?? "sibling"silently forces the sibling path for every template launch and job run. Documented; the code fix is on the audit backlog.docs/03-api-spec.md:createNewBranch: falsechecks outbaseBranchand ignoresworktreeBranch— the sentence had it backwards. Also noted that placement comes from/agents/settings, not the create payload.docs/04-agent-lifecycle.md: the setup script never postssetup/phase: worktree(it's the initial value written at row insert); itunsetsDATABASE_URLbefore sourcing~/.dispatch/env; worktree creation is the only unrecoverable step (a failed install or missing.envis not). Documented thegit branch -DthatcleanupGitWorktreeperforms on archive, and that cleanup failures are swallowed.Deferred to a future run
worktreeLocationthroughTemplateServiceandJobServiceso the setting actually applies to template launches and job runs.🤖 Generated with Claude Code
https://claude.ai/code/session_01WBq8dmFViUshsBQodr8UXa