Fix daemon terminating Claude for project-based tasks#495
Merged
Conversation
Root cause: UpdateTask() in setupWorktree/setupSharedWorkDir writes ALL
task fields back to the DB, including the stale task.Status ("queued").
This overwrites the "processing" status set by updateStatus() moments
earlier, because updateStatus() only updates the DB but not the in-memory
task struct. When pollTmuxSession sees status="queued" on its first tick,
it returns {Interrupted: true}, which kills Claude and leaves the task
in "queued" status, creating an infinite retry loop.
Fix: Keep task.Status in sync after updateStatus(processing) so that
subsequent UpdateTask() calls preserve the correct status.
Also fixes:
- result.Interrupted handler now explicitly sets status to backlog
instead of assuming Interrupt() already did it
- CleanupWorktree skips "git worktree remove" for non-worktree tasks
where WorktreePath is the project root (avoids "fatal: is a main
working tree" error)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
UpdateTask()insetupWorktree/setupSharedWorkDirwrites all task fields back to DB, including the staletask.Status("queued"). This overwrites the "processing" status set byupdateStatus()earlier, becauseupdateStatus()only updates the DB — not the in-memory task struct. WhenpollTmuxSessionseesstatus="queued"on its first tick, it returns{Interrupted: true}, killing Claude and leaving the task queued → infinite retry loop.task.Statusin sync with DB afterupdateStatus(processing)so subsequentUpdateTask()calls preserve the correct statusresult.Interruptedhandler now explicitly sets status to backlog (doesn't assumeInterrupt()already did it), andCleanupWorktreeskipsgit worktree removefor non-worktree tasks (avoids "fatal: is a main working tree")Test plan
TestUpdateTaskDoesNotResetStatus- verifies UpdateTask preserves processing statusTestCleanupWorktreeNonWorktreeTask- verifies cleanup handles non-worktree tasks🤖 Generated with Claude Code