Repository navigation
Conversation
Scratch ("No project") is a plain folder, not a Git repository, so a
scheduled task saved with "Create a new worktree" (the editor default, and
what MCP schedule_task stores for unbound tasks) failed every run with
"Workspace preparation failed".
ThreadLaunchService.launch now treats a worktree request on Scratch as a
root launch, up front, so the per-thread Scratch folder, preparation and
retries all see root. ScheduledTaskService.upsert, which both the web
editor and MCP go through, stores such tasks as root. Both ask the new
ManagedProjectFolders.isScratchProject.
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix for scheduled and direct launches targeting the non-Git Scratch project. It preserves Git-project worktrees, adds coverage for legacy and new task paths, and does not alter schemas, product defaults, deployment, or static-analysis configuration. You can add or adjust custom eligibility rules. Learn more. |
This branch has not been deployed
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.
Fixes #17309
Problem
@bzbetty reported that a scheduled task for "No project" fails on start with "Workspace preparation failed" when worktree creation is left enabled.
@Alb11747 reproduced it end to end over MCP:
schedule_taskstores unbound tasks with a worktree strategy, and the run failed inremoteExistson the Scratch folder before the provider started.@juliusmarminge traced it on
mainand asked for a server-side fix that coerces worktree strategies on Scratch torootboth on upsert and at launch, so existing tasks and MCP-created tasks stop failing.Scratch ("No project") is a plain folder, not a Git repository. Only
rootlaunches get a per-thread Scratch folder; aworktreelaunch always rangit.createWorktreeagainst it and failed.Change
ThreadLaunchService.launchtreats aworktreerequest on Scratch asroot, once, up front. A root request allocates a per-thread Scratch folder, and the launch persists that folder on the run asexisting_worktree, so preparation and replays of the launch use it. Tasks already stored with a worktree strategy now run.ScheduledTaskService.upsertstores a Scratch task'sworktreestrategy asroot. The web editor and MCPschedule_task/update_scheduled_taskboth save through it.ManagedProjectFolders.isScratchProject(projectId). It reuses the existing Scratch root check thatfolderForThreadalready relied on.Coercion rather than rejection: on Scratch, a root request allocates a per-thread Scratch folder, which is what a worktree was meant to give. Rejecting would only push the same fix onto the user or agent, and no existing validation error covers this case.
Relation to open PRs:
rooteither way, so the two compose.Verification
43f8a8de17)failed, and a probe showedWorkspace preparation failed during provision worktree: Failed to resolve the VCS driver for this Git command.ThreadLaunchService.test.ts,ManagedProjectFolders.test.ts,src/scheduledTasks/*,Scheduler.integration.test.ts,ClaudeAutomaticDelivery.integration.test.tsvp run typecheck(apps/server)error TS/warning TSThreadLaunchService.test.ts, on a line this PR does not touch)worktreeon Scratch is released (starting) in its own Scratch folder, stored asexisting_worktree, nocreateWorktreeworktreeon a Git project completes worktree creation and is released with itsworktreestrategyworktreeis stored asrootworktreeworktreeworktreeruns (runNow), is released in its own Scratch folder, stored asexisting_worktreefailedin workspace preparationisScratchProjectis true for Scratch, false for other projects and when Scratch is unavailableThis is a server-only change with no UI, so there are no screenshots.
The tests mock Git to fail on the Scratch root with the same
GitCommandErrorthe real path raises ("Failed to resolve the VCS driver for this Git command."), and to succeed on the Git project. They wait on the run's release or failure event, with no polling.Limitations / not checked:
retryPreparation) still reuses its storedworktreestrategy and fails again. Running the task again creates a corrected launch.Implemented with Claude Opus 5.5, verified with GPT-6 Astra, coordinated by Claude Fable 5.1 in Claude Code.