"use client"; import { useState } from "react"; import { IconLoader } from "@tabler/icons-react"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@kandev/ui/alert-dialog"; import { Checkbox } from "@kandev/ui/checkbox"; export type TaskResetEnvConfirmDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; hasWorktreePath: boolean; isResetting?: boolean; onConfirm: (opts: { pushBranch: boolean }) => void; }; export function TaskResetEnvConfirmDialog({ open, onOpenChange, hasWorktreePath, isResetting, onConfirm, }: TaskResetEnvConfirmDialogProps) { const [acknowledged, setAcknowledged] = useState(false); const [pushBranch, setPushBranch] = useState(false); const handleOpenChange = (next: boolean) => { if (!next) { // reset local state when closing setAcknowledged(false); setPushBranch(false); } onOpenChange(next); }; return ( e.stopPropagation()}> Reset environment?

This tears down the current container, sandbox, and/or worktree for this task so the next session starts with a fresh environment.

Any uncommitted or unpushed changes in the workspace will be lost.

{hasWorktreePath && ( )}
Cancel { // Radix's AlertDialogAction auto-closes the dialog on click, // which would dismiss it before the async reset completes — the // user never sees the loading spinner, and the dialog closes // even on failure. Block the auto-close so the parent owns the // close decision via `onOpenChange` after the promise settles. e.preventDefault(); if (isResetting || !acknowledged) return; onConfirm({ pushBranch }); }} > {isResetting ? : null} Reset environment
); }