diff --git a/src/routes/collections.$collectionId.tsx b/src/routes/collections.$collectionId.tsx index 3b63c37..dddfe24 100644 --- a/src/routes/collections.$collectionId.tsx +++ b/src/routes/collections.$collectionId.tsx @@ -61,6 +61,8 @@ import { Tag, } from "lucide-react"; import { toast } from "sonner"; +import { spawnNextCollectionWorkflowTask } from "@/lib/workflow-chain"; +import { ApplyCollectionWorkflowDialog } from "@/components/collections/apply-collection-workflow-dialog"; export const Route = createFileRoute("/collections/$collectionId")({ component: CollectionDetailRoute, @@ -224,8 +226,15 @@ function CollectionDetailRoute() { done_at: next ? new Date().toISOString() : null, }) .eq("id", t.id); - if (error) toast.error("Could not update", { description: error.message }); - else refreshTasks(); + if (error) { + toast.error("Could not update", { description: error.message }); + return; + } + if (next) { + // Auto-spawn the next workflow task in the chain (if any) + await spawnNextCollectionWorkflowTask(t.id); + } + refreshTasks(); }; const deleteTask = async (id: string) => {