@@ -174,10 +198,17 @@ export function ScheduledView({ onOpenRun, onRunNow, initialOpenId }: Props) {
className="sched-card-del"
title="Delete automation"
aria-label={`Delete ${t.title}`}
- onClick={async (e) => {
+ onClick={(e) => {
e.stopPropagation();
- await deleteAutomation(t.id);
- refresh();
+ setPendingDelete({
+ id: t.id,
+ title: t.title,
+ onConfirm: async () => {
+ await deleteAutomation(t.id);
+ announceAutomationsChanged();
+ await refresh();
+ },
+ });
}}
>
@@ -296,6 +327,10 @@ function TaskDetail({
const [time, setTime] = useState("09:00");
const [freq, setFreq] = useState("daily");
const [saving, setSaving] = useState(false);
+ const [pendingDelete, setPendingDelete] = useState<{
+ title: string;
+ onConfirm: () => void | Promise
;
+ } | null>(null);
// The seen mark AS OF opening — the "new" pills compare against this frozen value
// while mark-seen advances the stored one (badge clears; highlights survive).
@@ -358,6 +393,15 @@ function TaskDetail({
await updateAutomation(id, { enabled: !task.enabled });
refresh();
};
+ const closeDeleteModal = () => setPendingDelete(null);
+ const handleDeleteConfirm = async () => {
+ if (!pendingDelete) return;
+ try {
+ await pendingDelete.onConfirm();
+ } finally {
+ closeDeleteModal();
+ }
+ };
const remove = async () => {
await deleteAutomation(id);
announceAutomationsChanged(); // the sidebar band must not wait out its poll
@@ -366,6 +410,15 @@ function TaskDetail({
return (
+ {pendingDelete && (
+
+ )}
@@ -395,7 +448,15 @@ function TaskDetail({
▶ Run now
-