Fix Delete Worktree Status Regression (#1076)
* auto-claude: subtask-1-1 - Add skipStatusChange parameter to discardWorktree Fix bug where clicking Delete Worktree button on a staged task would reset it to backlog instead of setting it to done. Pass skipStatusChange=true to prevent backend from automatically resetting status to backlog during worktree deletion, allowing the subsequent persistTaskStatus call to properly set it to done. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(frontend): handle persistTaskStatus failure after worktree deletion - Add error handling for persistTaskStatus in handleDeleteWorktreeAndMarkDone - If status update fails after worktree deletion, show specific error message to inform user of inconsistent state (worktree deleted but status not updated) - Update mock function signature to include skipStatusChange parameter Fixes PR review findings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+10
-3
@@ -107,15 +107,22 @@ export function StagedInProjectMessage({ task, projectPath, hasWorktree = false,
|
||||
|
||||
try {
|
||||
// Call the discard/delete worktree command
|
||||
const result = await window.electronAPI.discardWorktree(task.id);
|
||||
// Pass skipStatusChange=true to prevent backend from resetting to 'backlog'
|
||||
// since we explicitly set status to 'done' immediately after
|
||||
const result = await window.electronAPI.discardWorktree(task.id, true);
|
||||
|
||||
if (!result.success) {
|
||||
setError(result.error || 'Failed to delete worktree');
|
||||
return;
|
||||
}
|
||||
|
||||
// Mark task as done
|
||||
await persistTaskStatus(task.id, 'done');
|
||||
// Mark task as done - check result since worktree is already deleted
|
||||
const statusResult = await persistTaskStatus(task.id, 'done');
|
||||
if (!statusResult.success) {
|
||||
// Worktree is already deleted but status update failed - inform user of inconsistent state
|
||||
setError('Worktree deleted but failed to update task status: ' + (statusResult.error || 'Unknown error'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Auto-close modal after marking as done
|
||||
onClose?.();
|
||||
|
||||
@@ -62,7 +62,7 @@ export const workspaceMock = {
|
||||
}
|
||||
}),
|
||||
|
||||
discardWorktree: async () => ({
|
||||
discardWorktree: async (_taskId: string, _skipStatusChange?: boolean) => ({
|
||||
success: true,
|
||||
data: {
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user