Merge pull request #1818 from AndyMik90/auto-claude/227-fix-mark-as-done-on-task-modal
auto-claude: 227-fix-mark-as-done-on-task-modal
This commit is contained in:
@@ -569,7 +569,7 @@ export function registerTaskExecutionHandlers(
|
||||
_,
|
||||
taskId: string,
|
||||
status: TaskStatus,
|
||||
options?: { forceCleanup?: boolean }
|
||||
options?: { forceCleanup?: boolean; keepWorktree?: boolean }
|
||||
): Promise<IPCResult & { worktreeExists?: boolean; worktreePath?: string }> => {
|
||||
// Find task and project first (needed for worktree check)
|
||||
const { task, project } = findTaskAndProject(taskId);
|
||||
@@ -581,13 +581,17 @@ export function registerTaskExecutionHandlers(
|
||||
// Validate status transition - 'done' can only be set through merge handler
|
||||
// UNLESS there's no worktree (limbo state - already merged/discarded or failed)
|
||||
// OR forceCleanup is requested (user confirmed they want to delete the worktree)
|
||||
// OR keepWorktree is requested (user wants to mark done without deleting worktree)
|
||||
if (status === 'done') {
|
||||
// Check if worktree exists (task.specId matches worktree folder name)
|
||||
const worktreePath = findTaskWorktree(project.path, task.specId);
|
||||
const hasWorktree = worktreePath !== null;
|
||||
|
||||
if (hasWorktree) {
|
||||
if (options?.forceCleanup) {
|
||||
if (options?.keepWorktree) {
|
||||
// User explicitly chose to keep worktree - allow marking as done
|
||||
console.warn(`[TASK_UPDATE_STATUS] Marking task ${taskId} as done while keeping worktree at ${worktreePath}`);
|
||||
} else if (options?.forceCleanup) {
|
||||
// User confirmed cleanup - delete worktree and branch
|
||||
console.warn(`[TASK_UPDATE_STATUS] Cleaning up worktree for task ${taskId} (user confirmed)`);
|
||||
try {
|
||||
|
||||
@@ -44,7 +44,7 @@ export interface TaskAPI {
|
||||
updateTaskStatus: (
|
||||
taskId: string,
|
||||
status: TaskStatus,
|
||||
options?: { forceCleanup?: boolean }
|
||||
options?: { forceCleanup?: boolean; keepWorktree?: boolean }
|
||||
) => Promise<IPCResult & { worktreeExists?: boolean; worktreePath?: string }>;
|
||||
recoverStuckTask: (
|
||||
taskId: string,
|
||||
@@ -135,7 +135,7 @@ export const createTaskAPI = (): TaskAPI => ({
|
||||
updateTaskStatus: (
|
||||
taskId: string,
|
||||
status: TaskStatus,
|
||||
options?: { forceCleanup?: boolean }
|
||||
options?: { forceCleanup?: boolean; keepWorktree?: boolean }
|
||||
): Promise<IPCResult & { worktreeExists?: boolean; worktreePath?: string }> =>
|
||||
ipcRenderer.invoke(IPC_CHANNELS.TASK_UPDATE_STATUS, taskId, status, options),
|
||||
|
||||
|
||||
@@ -198,7 +198,11 @@ export function StagedInProjectMessage({ task, projectPath, hasWorktree = false,
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
await persistTaskStatus(task.id, 'done');
|
||||
const result = await persistTaskStatus(task.id, 'done', { keepWorktree: true });
|
||||
if (!result.success) {
|
||||
setError(result.error || 'Failed to mark as done');
|
||||
return;
|
||||
}
|
||||
onClose?.();
|
||||
} catch (err) {
|
||||
console.error('Error marking task as done:', err);
|
||||
|
||||
@@ -792,7 +792,7 @@ export interface PersistStatusResult {
|
||||
export async function persistTaskStatus(
|
||||
taskId: string,
|
||||
status: TaskStatus,
|
||||
options?: { forceCleanup?: boolean }
|
||||
options?: { forceCleanup?: boolean; keepWorktree?: boolean }
|
||||
): Promise<PersistStatusResult> {
|
||||
const store = useTaskStore.getState();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user