Repository navigation
Description
Summary
In a non-Git umbrella project with multiple tracked Git repositories (e.g., 12–15 child repos), calling delegate_task with isolation: "worktree" (or t3_worktree_handoff) cannot select repositories and does not inherit the parent thread's TaskFolder selection or branch:
- 9+ tracked repos → silently 0 repo worktrees: Even when the parent thread is already in a TaskFolder with e.g. 2 explicitly selected repos, an isolated child gets a TaskFolder with zero repository worktrees (only symlinks to plain files, with all tracked repo directories skipped) and no error.
- 1–8 tracked repos → all repos checked out: Even when the parent only selected 2 repos (or the child only needs 1), every
delegate_task(isolation: "worktree")creates worktrees for all tracked repos up to 8. - Parent branch/commits are ignored: Non-Git delegation sets
baseRef: "HEAD", which resolves each repo to its own local default branch rather than the parent TaskFolder's branch/commits.
Follow-up to #42254 (merged PR #42261 fixed the parent-commit error on non-Git roots, leaving repository selection above 8 unfinished).
Root Cause (verified on main @ 85471b3681)
TASK_FOLDER_DEFAULT_REPOSITORIES_MAX = 8defaults to[]above 8:packages/contracts/src/workspaceFolders.ts#L54-L55apps/server/src/workspace/TaskFolders.ts#L631-L632:repositories = reachable.length <= TASK_FOLDER_DEFAULT_REPOSITORIES_MAX ? reachable : [];- Because tracked repos exist,
plan()returns a non-null plan withrepositories: [].linkFolder(TaskFolders.ts#L755) skips every tracked repository, leaving the child folder with no repos at all and no error.
delegate_taskhas norepositoriesparameter and ignores the parent TaskFolder:- Input schema (
packages/contracts/src/orchestratorMcp.ts#L173-L204) only exposesisolation: "shared" | "worktree". - Handler (
apps/server/src/mcp/OrchestratorMcpService.ts#L3043-L3050) sets{ type: "worktree", baseRef: "HEAD" }for any non-Git project without checking the parent thread's TaskFolder or passingrepositories. - By contrast, the underlying launch strategy (
packages/contracts/src/orchestrationV2.ts#L839-L861) andt3_thread_launch(apps/server/src/mcp/toolkits/project/tools.ts#L135-L157) already acceptrepositories: [{ path }]and forward it throughThreadLaunchService.ts#L751-L756.
- Input schema (
- Parent branch/commits are not carried forward on non-Git roots:
baseRef: "HEAD"is treated byrepositoryStart(TaskFolders.ts#L708-L737) as "no base chosen", starting each repo on its own local default branch.- The parent-branch behavior from [Bug]: delegate_task worktree children start a project's other repositories from their default branch, not the parent's branch #42536 / PR fix(server): delegate_task worktree children start every repository from the parent's branch #42546 (
OrchestratorMcpService.ts#L3080-L3093) only runs in the Git-root branch.
t3_worktree_handoffhas the same omission:packages/contracts/src/worktreeMcp.ts#L5-L29andapps/server/src/mcp/WorktreeMcpService.ts#L165-L203calltaskFolders.plan({ projectId })withoutrepositories.
Proposed Behavior
Repository selection (primary):
- Add optional
repositories(Array<{ path: string }>) todelegate_taskandt3_worktree_handoff, reusing the existingworkspaceStrategy.repositoriesshape fromt3_thread_launch. - Inherit parent TaskFolder selection by default: When a parent thread is already in a TaskFolder and
delegate_task(isolation: "worktree")omitsrepositories, inherit the parent TaskFolder's recordedrepositoryPathentries instead of falling back to the all-or-nothing project default. - Fail fast instead of creating a 0-repo TaskFolder: When a project tracks Git repos (e.g. >8) and
plan()resolves to 0 repositories with no custom layout, return an actionableinvalid_requesterror explaining the 8-repo default threshold and therepositoriesparameter.
Base branch/commit resolution (distinct from selection):
4. Carry forward the parent TaskFolder's branch/commit for inherited/matching repos instead of always passing baseRef: "HEAD", matching #42536 / PR #42546 for Git-root projects.
(Optional follow-ups: expose TaskFolders.addRepository via MCP for adding a repo mid-thread, and allow t3_worktree_list to target a tracked repo instead of returning isRepo: false, refs: [] on non-Git roots.)
Current Workarounds
- Use
t3_thread_launchwithworkspaceStrategy.repositories(creates a top-level thread, not a delegated child). - Keep dedicated single-repo projects for repos that use
delegate_task(isolation: "worktree"). - Use
isolation: "shared".
Related Issues
- [Bug]: delegate_task worktree isolation fails in a project whose root holds several repos (tracked folders): "Unable to resolve the parent checkout commit" #42254 / PR fix(server): delegate_task worktree isolation works in a project folder holding several repos #42261 (prior request for repo selection in
delegate_task) - delegate_task isolation "worktree" from a Git repo inside Scratch gives children an empty non-git folder #45050 / PR fix(server): refuse a worktree child that would lose the parent's Scratch repository #45064 (Scratch parent inside a Git repo; same
isNonGitProjectbranch) - [Bug]: delegate_task worktree children start a project's other repositories from their default branch, not the parent's branch #42536 / PR fix(server): delegate_task worktree children start every repository from the parent's branch #42546 (parent branch resolution on Git-root projects)
- Issue and PR MCP tools ignore a project's tracked repositories: link_issue, create_issue and pull_request_read fail when the project root has no remote #45382, PR review guides fail for pull requests in a project's tracked repositories #40350 (tracked-repo support in issue/PR/review-guide MCP tools)
Activity