12 lines
669 B
TypeScript
12 lines
669 B
TypeScript
import type { CanvasNodeData } from "@/types/canvas";
|
|
|
|
/** A historical taskId is not a lock. Only live task states / submission are. */
|
|
export function isCanvasNodeGenerating(node: CanvasNodeData | undefined, runningNodeId?: string | null) {
|
|
if (!node) return false;
|
|
if (runningNodeId === node.id) return true;
|
|
const meta = node.metadata;
|
|
if (meta?.taskId && (meta.taskStatus === "queued" || meta.taskStatus === "running")) return true;
|
|
if (["succeeded", "failed", "cancelled"].includes(meta?.taskStatus || "")) return false;
|
|
return meta?.status === "loading" || Boolean(meta?.taskId && meta.status !== "success" && meta.status !== "error");
|
|
}
|