feat(workflow): 工作流提供方 - 集成 RunningHub 与 ComfyUI Bridge
This commit is contained in:
1 parent
6141bd688c
commit
86fc3fda2f
82 files changed
+11404
-247
No files matched your search
@@ -282,13 +282,17 @@ export function useCanvasGeneration({ projectId, domainProjectId, projectLoaded,
|
||||
|
||||
const applyGenerationTaskResult = useCallback(
|
||||
async (nodeId: string, task: GenerationTask) => {
|
||||
const applyStoredTaskResult = async () => {
|
||||
const applied = await applyGenerationTaskResultToNodes(nodesRef.current, task, nodeId);
|
||||
if (!applied.updated || !applied.node) throw new Error("画布中找不到对应任务节点");
|
||||
nodesRef.current = applied.nodes;
|
||||
setNodes(applied.nodes);
|
||||
};
|
||||
if (!task.outputs?.length && task.type === "canvas_text") {
|
||||
await applyStoredTaskResult();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!task.outputs?.length && task.type === "canvas_text") {
|
||||
const applied = await applyGenerationTaskResultToNodes(nodesRef.current, task, nodeId);
|
||||
if (!applied.updated || !applied.node) throw new Error("画布中找不到对应任务节点");
|
||||
setNodes((current) => current.map((node) => (node.id === applied.nodeId ? applied.node! : node)));
|
||||
return;
|
||||
}
|
||||
await consumeGenerationTaskNode(
|
||||
task,
|
||||
nodeId,
|
||||
@@ -307,11 +311,24 @@ export function useCanvasGeneration({ projectId, domainProjectId, projectLoaded,
|
||||
},
|
||||
{ signal: consumerControllerRef.current.signal },
|
||||
);
|
||||
const currentNode = nodesRef.current.find((node) => node.id === nodeId || node.metadata?.taskId === task.id);
|
||||
if (task.status === "succeeded" && (!currentNode?.metadata?.content || currentNode.metadata.status !== NODE_STATUS_SUCCESS)) {
|
||||
// attach effect 可能已经完成,但旧画布快照仍停留在 loading。
|
||||
// 最终以节点是否真实拿到媒体结果为准,不能只信幂等记录。
|
||||
await applyStoredTaskResult();
|
||||
}
|
||||
} catch (error) {
|
||||
if (generationTaskCanReloadResource(task)) {
|
||||
setNodes((current) => current.map((node) => (node.id === nodeId ? { ...node, metadata: { ...node.metadata, resourceReloadAvailable: true } } : node)));
|
||||
// 成功任务的副作用确认失败时,直接用已持久化结果回写节点,避免永久停留在生成中。
|
||||
if (task.status === "succeeded") {
|
||||
await applyStoredTaskResult().catch(() => {
|
||||
throw error;
|
||||
});
|
||||
} else {
|
||||
if (generationTaskCanReloadResource(task)) {
|
||||
setNodes((current) => current.map((node) => (node.id === nodeId ? { ...node, metadata: { ...node.metadata, resourceReloadAvailable: true } } : node)));
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
[nodesRef, projectId, setNodes],
|
||||
|
||||
Reference in new issue
Block a user