diff --git a/desktop/src/features/workflows/ui/WorkflowDeleteDialog.tsx b/desktop/src/features/workflows/ui/WorkflowDeleteDialog.tsx
index db07470f2c..925830990f 100644
--- a/desktop/src/features/workflows/ui/WorkflowDeleteDialog.tsx
+++ b/desktop/src/features/workflows/ui/WorkflowDeleteDialog.tsx
@@ -12,6 +12,7 @@ import {
import { Button } from "@/shared/ui/button";
type WorkflowDeleteDialogProps = {
+ isPending: boolean;
open: boolean;
workflow: Workflow | null;
onConfirm: (workflow: Workflow) => void;
@@ -19,6 +20,7 @@ type WorkflowDeleteDialogProps = {
};
export function WorkflowDeleteDialog({
+ isPending,
open,
workflow,
onConfirm,
@@ -37,13 +39,17 @@ export function WorkflowDeleteDialog({
-
{
+ disabled={isPending}
+ onClick={(event) => {
+ // Keep this controlled dialog open until the relay confirms
+ // deletion. On failure the toast appears and the user can retry.
+ event.preventDefault();
if (workflow) {
onConfirm(workflow);
}
@@ -51,7 +57,7 @@ export function WorkflowDeleteDialog({
type="button"
variant="destructive"
>
- Delete
+ {isPending ? "Deleting…" : "Delete"}
diff --git a/desktop/src/features/workflows/ui/WorkflowsView.tsx b/desktop/src/features/workflows/ui/WorkflowsView.tsx
index e0e5b7e948..d4906104fb 100644
--- a/desktop/src/features/workflows/ui/WorkflowsView.tsx
+++ b/desktop/src/features/workflows/ui/WorkflowsView.tsx
@@ -126,6 +126,14 @@ export function WorkflowsView({
const triggerMutation = useMutation({
mutationFn: (workflowId: string) => triggerWorkflow(workflowId),
+ onError: (error) => {
+ toast.error("Couldn’t run workflow", {
+ description:
+ error instanceof Error
+ ? error.message
+ : "The workflow did not start. Try again.",
+ });
+ },
onSuccess: () => {
void queryClient.invalidateQueries({
predicate: (query) => query.queryKey[0] === "workflow-runs",
@@ -135,7 +143,16 @@ export function WorkflowsView({
const deleteMutation = useMutation({
mutationFn: (workflowId: string) => deleteWorkflow(workflowId),
+ onError: (error) => {
+ toast.error("Couldn’t delete workflow", {
+ description:
+ error instanceof Error
+ ? error.message
+ : "The workflow was not deleted. Try again.",
+ });
+ },
onSuccess: (_data, workflowId) => {
+ setDeleteTarget(null);
if (selectedWorkflowId === workflowId) {
onCloseWorkflow();
}
@@ -194,7 +211,6 @@ export function WorkflowsView({
const handleConfirmDelete = React.useCallback(
(workflow: Workflow) => {
deleteOne(workflow.id);
- setDeleteTarget(null);
},
[deleteOne],
);
@@ -314,9 +330,10 @@ export function WorkflowsView({
/>
{
- if (!open) setDeleteTarget(null);
+ if (!open && !deleteMutation.isPending) setDeleteTarget(null);
}}
open={deleteTarget !== null}
workflow={deleteTarget}