fix(ui): auto-close task modal when marking task as done

Previously, clicking "Mark as Done" or "Delete Worktree & Mark Done"
  would update the task status but leave the modal open, requiring an
  extra click on "Close". Now the modal automatically closes after
  successfully marking a task as done for better UX.
This commit is contained in:
AndyMik90
2025-12-20 13:30:08 +01:00
parent 05062562f0
commit 297d380f4c
3 changed files with 14 additions and 5 deletions
@@ -407,6 +407,7 @@ function TaskDetailModalContent({ open, task, onOpenChange }: { open: boolean; t
onStageOnlyChange={state.setStageOnly}
onShowConflictDialog={state.setShowConflictDialog}
onLoadMergePreview={state.loadMergePreview}
onClose={handleClose}
/>
</>
)}
@@ -39,6 +39,7 @@ interface TaskReviewProps {
onStageOnlyChange: (value: boolean) => void;
onShowConflictDialog: (show: boolean) => void;
onLoadMergePreview: () => void;
onClose?: () => void;
}
/**
@@ -77,7 +78,8 @@ export function TaskReview({
onShowDiffDialog,
onStageOnlyChange,
onShowConflictDialog,
onLoadMergePreview
onLoadMergePreview,
onClose
}: TaskReviewProps) {
return (
<div className="space-y-4">
@@ -119,9 +121,10 @@ export function TaskReview({
task={task}
projectPath={stagedProjectPath}
hasWorktree={worktreeStatus?.exists || false}
onClose={onClose}
/>
) : (
<NoWorkspaceMessage task={task} />
<NoWorkspaceMessage task={task} onClose={onClose} />
)}
{/* QA Feedback Section */}
@@ -24,12 +24,13 @@ export function LoadingMessage({ message = 'Loading workspace info...' }: Loadin
interface NoWorkspaceMessageProps {
task?: Task;
onClose?: () => void;
}
/**
* Displays message when no workspace is found for the task
*/
export function NoWorkspaceMessage({ task }: NoWorkspaceMessageProps) {
export function NoWorkspaceMessage({ task, onClose }: NoWorkspaceMessageProps) {
const [isMarkingDone, setIsMarkingDone] = useState(false);
const handleMarkDone = async () => {
@@ -38,6 +39,8 @@ export function NoWorkspaceMessage({ task }: NoWorkspaceMessageProps) {
setIsMarkingDone(true);
try {
await persistTaskStatus(task.id, 'done');
// Auto-close modal after marking as done
onClose?.();
} catch (err) {
console.error('Error marking task as done:', err);
} finally {
@@ -85,12 +88,13 @@ interface StagedInProjectMessageProps {
task: Task;
projectPath?: string;
hasWorktree?: boolean;
onClose?: () => void;
}
/**
* Displays message when changes have already been staged in the main project
*/
export function StagedInProjectMessage({ task, projectPath, hasWorktree = false }: StagedInProjectMessageProps) {
export function StagedInProjectMessage({ task, projectPath, hasWorktree = false, onClose }: StagedInProjectMessageProps) {
const [isDeleting, setIsDeleting] = useState(false);
const [error, setError] = useState<string | null>(null);
@@ -110,7 +114,8 @@ export function StagedInProjectMessage({ task, projectPath, hasWorktree = false
// Mark task as done
await persistTaskStatus(task.id, 'done');
// Success - the UI will update automatically via the store
// Auto-close modal after marking as done
onClose?.();
} catch (err) {
console.error('Error deleting worktree:', err);
setError(err instanceof Error ? err.message : 'Failed to delete worktree');