diff --git a/src/areas/workflows/workflowRunStore.ts b/src/areas/workflows/workflowRunStore.ts index 0f0341d..5ea6acd 100644 --- a/src/areas/workflows/workflowRunStore.ts +++ b/src/areas/workflows/workflowRunStore.ts @@ -163,29 +163,39 @@ async function executeExtensionNode( if (src.outputType === 'mesh') nodeInputMeshPath = src.filePath else if (src.outputType === 'image') nodeInputPath = src.filePath else if (src.filePath !== undefined) nodeInputPath = src.filePath - if (src.text !== undefined) nodeInputText = src.text + if (src.text !== undefined && src.text.trim().length > 0) nodeInputText = src.text } } else { for (const edge of incomingEdges) { const src = resolveSource(edge.source) if (src?.filePath !== undefined) nodeInputPath = src.filePath - if (src?.text !== undefined) nodeInputText = src.text + if (src?.text !== undefined && src.text.trim().length > 0) nodeInputText = src.text } } const isModelNode = ext?.type === 'model' if (isModelNode) { - const activeImagePath = nodeInputPath ?? selectedImagePath - if (!selectedImageData && (!activeImagePath || activeImagePath.trim().length === 0)) { + const isTextInput = ext?.inputs ? ext.inputs.every((i) => i === 'text') : ext?.input === 'text' + const activeImagePath = isTextInput ? undefined : (nodeInputPath ?? selectedImagePath) + if (!isTextInput && !selectedImageData && (!activeImagePath || activeImagePath.trim().length === 0)) { throw new Error('No input image selected for model node') } - const base64 = selectedImageData && nodeInputPath === undefined - ? selectedImageData - : await window.electron.fs.readFileBase64(activeImagePath as string) - const bytes = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0)) - const blob = new Blob([bytes], { type: 'image/png' }) - const fname = activeImagePath?.split(/[\\/]/).pop() ?? 'image.png' + + let blob: Blob + let fname: string + if (isTextInput || (!activeImagePath && selectedImageData)) { + const base64 = selectedImageData && nodeInputPath === undefined + ? selectedImageData + : 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==' // 1x1 transparent PNG + fname = 'placeholder.png' + blob = new Blob([Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))], { type: 'image/png' }) + } else { + const base64 = await window.electron.fs.readFileBase64(activeImagePath as string) + const bytes = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0)) + blob = new Blob([bytes], { type: 'image/png' }) + fname = activeImagePath?.split(/[\\/]/).pop() ?? 'image.png' + } const extraParams: Record = {} if (nodeInputMeshPath) { @@ -194,6 +204,10 @@ async function executeExtensionNode( ? norm.slice(workspaceDir.length).replace(/^\//, '') : norm } + if (nodeInputText !== undefined && nodeInputText.trim().length > 0) { + extraParams.prompt = nodeInputText + extraParams.text = nodeInputText + } const schemaDefaults = Object.fromEntries( (ext.params ?? []).map((p) => [p.id, p.default]),