Repository navigation
fix(server): a worktree thread moved to the project checkout no longer holds new messages - #40100
Closed
MarcoDotIO wants to merge 1 commit into
Closed
MarcoDotIO wants to merge 1 commit into
MarcoDotIO wants to merge 1 commit into
Conversation
…r holds new messages When a worktree thread's first turn failed or was stopped and the user then switched the thread to the project checkout, every new message was held with "Retry worktree setup", though the setup had succeeded and there was nothing to retry. Any ended run that had asked for a worktree counted as a failed setup. A run that started already had its worktree, so only runs that never started now count, for the queue hold and for side chats. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
Closing: MarcoDotIO already has 3 or more open PRs here, which is the limit for contributors who are not vouched. Once one of them is merged or closed, open this again. See the open PR limit. |
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.
Problem
When a worktree thread's first turn fails or is stopped, and the user then moves the thread to the project checkout, every new message is held. Two things move the thread there: picking the default branch in the branch picker, which sends
thread.metadata.updatewithworktreePath: null, orthread.project.adopt-folder. Resume is refused with "Retry worktree setup or choose a workspace before resuming the queue." There is nothing to retry, because the setup succeeded. The only way out is to move the thread back into a worktree.The cause is in
Orchestrator.ts.worktreeSetupPending, theworktreeMissingRuncheck indispatchMessageand theworktreeMissingcheck instartNextQueuedRunall treat anyfailedorinterruptedrun withworkspacePreparation.type === "worktree"as a failed setup onceworktreePathis null.dispatchPreparedRunReleasekeepsworkspacePreparationon the run, so a run whose worktree was created and which later failed in the provider looks the same as a real setup failure. The sharedorchestrationV2WorktreePendinguses the same test, so side chats are blocked the same way ("Available once the thread's worktree is set up.").Fix
A run only gets
startedAtafter its preparation is released, which happens after its worktree is recorded. A failed setup (prepared-run.fail) or a Stop during preparation leavesstartedAtnull. All four checks now also requirestartedAt === null, so only a setup that never finished holds the queue or blocks side chats.Threads that are already stuck recover after the update, because nothing new needs to be stored.
Three existing fixtures modeled a failed setup as a run that had started (
startedAt: now), which production never writes. They now usestartedAt: null: theendpatch in theruntimeLayer.test.tsqueue harness can now set it, andwriteParentRuninThreadFork.execution.test.tsuses it too. What those tests assert is unchanged.Scope and approval
This is a small fix for an obvious bug: a hold meant for a failed worktree setup fires for a setup that succeeded, and leaves the thread unable to run anything in the checkout the user chose. The change adds one condition at four sites. It adds no new state, schema or UI. It does not touch the separate open report #37196, where a Stop during preparation leaves a held message with no retry control.
Verification
runtimeLayer.test.ts, "starts messages in the project checkout after a failed turn whose worktree was set up". It launches a run with a worktree strategy, releases it, fails it, setsworktreePath: nullthroughthread.metadata.update, then sends a user message.efbd13983f:AssertionError: expected 'queued' to equal 'starting'.vp test runonruntimeLayer.test.ts,ThreadFork.execution.test.ts,ThreadLaunchService.test.ts,ProviderRuntimeRecoveryService.test.tsandOrchestratorMcpService.test.ts: 415/415 pass.vp run check:changed: format, lint, knip, graphql and typecheck (36 packages) pass. Two tests inOrchestrator.control-reads.test.tsfail withstatement.stat is not a function. They fail the same way on base, because the local Node (22.22) lacks thatnode:sqliteAPI.status: "queued",queueHeld: true),queue.resumerefused with "Retry worktree setup…", still queued afterwards.startedAt: null, so that narrow window still reads as an unfinished setup.Claude Opus 5.5 (Claude Code desktop app)
🤖 Generated with Claude Code