@genfeedai/workflow-ui 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -33
- package/dist/canvas.d.ts +22 -22
- package/dist/canvas.mjs +16 -17
- package/dist/{chunk-WBR34V4L.mjs → chunk-2FUPL67V.mjs} +1593 -1045
- package/dist/{chunk-4VEN4UN7.mjs → chunk-53XDE62A.mjs} +818 -623
- package/dist/{chunk-PCIWWD37.mjs → chunk-7LV4UAUS.mjs} +19 -19
- package/dist/{chunk-7SKSRSS7.mjs → chunk-B4EAAKYF.mjs} +16 -16
- package/dist/{chunk-ZJD5WMR3.mjs → chunk-C6MQBJFC.mjs} +45 -13
- package/dist/{chunk-7H3WJJYS.mjs → chunk-ESVULCFY.mjs} +12 -6
- package/dist/{chunk-GWBGK3KL.mjs → chunk-FWJIAW2E.mjs} +82 -47
- package/dist/{chunk-R727OFBR.mjs → chunk-GPYIIWD5.mjs} +404 -350
- package/dist/{chunk-OQREHJXK.mjs → chunk-IYFWAJBB.mjs} +208 -203
- package/dist/{chunk-2JQSKIWR.mjs → chunk-MGLAKMDP.mjs} +24 -23
- package/dist/{chunk-LT3ZJJL6.mjs → chunk-OJWVEEMM.mjs} +497 -399
- package/dist/{chunk-ZD2BADZO.mjs → chunk-ORVDYXDP.mjs} +221 -175
- package/dist/{chunk-CV4M7CNU.mjs → chunk-QQVHGJ2G.mjs} +149 -142
- package/dist/{chunk-6PSJTBNV.mjs → chunk-U4QPE4CY.mjs} +387 -347
- package/dist/{chunk-EFXQT23N.mjs → chunk-VVQ4CH77.mjs} +5 -5
- package/dist/{chunk-VRN3UWE5.mjs → chunk-XRC3O5GK.mjs} +73 -73
- package/dist/{chunk-FT33LFII.mjs → chunk-YUIK4AHM.mjs} +1 -1
- package/dist/{chunk-JT4Y5H3U.mjs → chunk-ZSITTZ4S.mjs} +630 -569
- package/dist/hooks.d.ts +37 -37
- package/dist/hooks.mjs +10 -10
- package/dist/index.d.ts +26 -11
- package/dist/index.mjs +99 -20
- package/dist/lib.d.ts +203 -203
- package/dist/lib.mjs +228 -199
- package/dist/nodes.d.ts +2 -2
- package/dist/nodes.mjs +12 -13
- package/dist/panels.d.ts +2 -3
- package/dist/panels.mjs +3 -3
- package/dist/provider.d.ts +2 -2
- package/dist/provider.mjs +2 -2
- package/dist/stores.d.ts +5 -5
- package/dist/stores.mjs +5 -5
- package/dist/toolbar.d.ts +42 -24
- package/dist/toolbar.mjs +4 -5
- package/dist/ui.d.ts +2 -2
- package/dist/ui.mjs +2 -2
- package/dist/{useCommentNavigation-BakbiiIc.d.ts → useRequiredInputs-ByoIS-fT.d.ts} +160 -160
- package/dist/{promptLibraryStore-Dl3Q3cP6.d.ts → workflowStore-Bsz0nd5c.d.ts} +368 -368
- package/dist/workflowStore-N2F7WIG3.mjs +2 -0
- package/package.json +79 -77
- package/src/styles/workflow-ui.css +56 -19
- package/dist/chunk-OY7BRSGG.mjs +0 -60
- package/dist/workflowStore-UAAKOOIK.mjs +0 -2
- package/dist/{types-IEKYuYhu.d.ts → types-CRXJnajq.d.ts} +1 -1
|
@@ -1,34 +1,39 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
|
|
3
3
|
var useContextMenuStore = create((set) => ({
|
|
4
|
+
close: () => {
|
|
5
|
+
set({
|
|
6
|
+
isOpen: false,
|
|
7
|
+
menuType: null,
|
|
8
|
+
targetId: null,
|
|
9
|
+
targetIds: null
|
|
10
|
+
});
|
|
11
|
+
},
|
|
4
12
|
isOpen: false,
|
|
5
|
-
position: { x: 0, y: 0 },
|
|
6
13
|
menuType: null,
|
|
7
|
-
|
|
8
|
-
targetIds: null,
|
|
9
|
-
openNodeMenu: (nodeId, x, y) => {
|
|
14
|
+
openEdgeMenu: (edgeId, x, y) => {
|
|
10
15
|
set({
|
|
11
16
|
isOpen: true,
|
|
17
|
+
menuType: "edge",
|
|
12
18
|
position: { x, y },
|
|
13
|
-
|
|
14
|
-
targetId: nodeId,
|
|
19
|
+
targetId: edgeId,
|
|
15
20
|
targetIds: null
|
|
16
21
|
});
|
|
17
22
|
},
|
|
18
|
-
|
|
23
|
+
openNodeMenu: (nodeId, x, y) => {
|
|
19
24
|
set({
|
|
20
25
|
isOpen: true,
|
|
26
|
+
menuType: "node",
|
|
21
27
|
position: { x, y },
|
|
22
|
-
|
|
23
|
-
targetId: edgeId,
|
|
28
|
+
targetId: nodeId,
|
|
24
29
|
targetIds: null
|
|
25
30
|
});
|
|
26
31
|
},
|
|
27
32
|
openPaneMenu: (x, y) => {
|
|
28
33
|
set({
|
|
29
34
|
isOpen: true,
|
|
30
|
-
position: { x, y },
|
|
31
35
|
menuType: "pane",
|
|
36
|
+
position: { x, y },
|
|
32
37
|
targetId: null,
|
|
33
38
|
targetIds: null
|
|
34
39
|
});
|
|
@@ -36,20 +41,15 @@ var useContextMenuStore = create((set) => ({
|
|
|
36
41
|
openSelectionMenu: (nodeIds, x, y) => {
|
|
37
42
|
set({
|
|
38
43
|
isOpen: true,
|
|
39
|
-
position: { x, y },
|
|
40
44
|
menuType: "selection",
|
|
45
|
+
position: { x, y },
|
|
41
46
|
targetId: null,
|
|
42
47
|
targetIds: nodeIds
|
|
43
48
|
});
|
|
44
49
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
menuType: null,
|
|
49
|
-
targetId: null,
|
|
50
|
-
targetIds: null
|
|
51
|
-
});
|
|
52
|
-
}
|
|
50
|
+
position: { x: 0, y: 0 },
|
|
51
|
+
targetId: null,
|
|
52
|
+
targetIds: null
|
|
53
53
|
}));
|
|
54
54
|
|
|
55
55
|
// src/stores/workflow/selectors.ts
|
|
@@ -10,27 +10,27 @@ function cn(...inputs) {
|
|
|
10
10
|
var buttonVariants = cva(
|
|
11
11
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
12
12
|
{
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
size: "default",
|
|
15
|
+
variant: "default"
|
|
16
|
+
},
|
|
13
17
|
variants: {
|
|
14
|
-
variant: {
|
|
15
|
-
default: "bg-white text-black hover:bg-white/90",
|
|
16
|
-
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
17
|
-
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
18
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19
|
-
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
20
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
21
|
-
},
|
|
22
18
|
size: {
|
|
23
19
|
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
24
|
-
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
25
|
-
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
26
20
|
icon: "size-9",
|
|
21
|
+
"icon-lg": "size-10",
|
|
27
22
|
"icon-sm": "size-8",
|
|
28
|
-
|
|
23
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
24
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5"
|
|
25
|
+
},
|
|
26
|
+
variant: {
|
|
27
|
+
default: "bg-white text-black hover:bg-white/90",
|
|
28
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
29
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
30
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
31
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
32
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
|
|
29
33
|
}
|
|
30
|
-
},
|
|
31
|
-
defaultVariants: {
|
|
32
|
-
variant: "default",
|
|
33
|
-
size: "default"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
);
|
|
@@ -48,7 +48,7 @@ function Button({
|
|
|
48
48
|
"data-slot": "button",
|
|
49
49
|
"data-variant": variant,
|
|
50
50
|
"data-size": size,
|
|
51
|
-
className: cn(buttonVariants({
|
|
51
|
+
className: cn(buttonVariants({ className, size, variant })),
|
|
52
52
|
...props
|
|
53
53
|
}
|
|
54
54
|
);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { cn } from './chunk-
|
|
1
|
+
import { cn } from './chunk-B4EAAKYF.mjs';
|
|
2
2
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
3
3
|
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
5
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
6
|
+
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
6
7
|
import * as React from 'react';
|
|
7
8
|
import { memo, useCallback, useRef, useState } from 'react';
|
|
8
|
-
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
9
9
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
10
10
|
|
|
11
|
-
function Checkbox({
|
|
11
|
+
function Checkbox({
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}) {
|
|
12
15
|
return /* @__PURE__ */ jsx(
|
|
13
16
|
CheckboxPrimitive.Root,
|
|
14
17
|
{
|
|
@@ -29,13 +32,19 @@ function Checkbox({ className, ...props }) {
|
|
|
29
32
|
}
|
|
30
33
|
);
|
|
31
34
|
}
|
|
32
|
-
function Select({
|
|
35
|
+
function Select({
|
|
36
|
+
...props
|
|
37
|
+
}) {
|
|
33
38
|
return /* @__PURE__ */ jsx(SelectPrimitive.Root, { "data-slot": "select", ...props });
|
|
34
39
|
}
|
|
35
|
-
function SelectGroup({
|
|
40
|
+
function SelectGroup({
|
|
41
|
+
...props
|
|
42
|
+
}) {
|
|
36
43
|
return /* @__PURE__ */ jsx(SelectPrimitive.Group, { "data-slot": "select-group", ...props });
|
|
37
44
|
}
|
|
38
|
-
function SelectValue({
|
|
45
|
+
function SelectValue({
|
|
46
|
+
...props
|
|
47
|
+
}) {
|
|
39
48
|
return /* @__PURE__ */ jsx(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
|
|
40
49
|
}
|
|
41
50
|
function SelectTrigger({
|
|
@@ -97,7 +106,10 @@ function SelectContent({
|
|
|
97
106
|
}
|
|
98
107
|
) });
|
|
99
108
|
}
|
|
100
|
-
function SelectLabel({
|
|
109
|
+
function SelectLabel({
|
|
110
|
+
className,
|
|
111
|
+
...props
|
|
112
|
+
}) {
|
|
101
113
|
return /* @__PURE__ */ jsx(
|
|
102
114
|
SelectPrimitive.Label,
|
|
103
115
|
{
|
|
@@ -156,7 +168,10 @@ function SelectScrollUpButton({
|
|
|
156
168
|
SelectPrimitive.ScrollUpButton,
|
|
157
169
|
{
|
|
158
170
|
"data-slot": "select-scroll-up-button",
|
|
159
|
-
className: cn(
|
|
171
|
+
className: cn(
|
|
172
|
+
"flex cursor-default items-center justify-center py-1",
|
|
173
|
+
className
|
|
174
|
+
),
|
|
160
175
|
...props,
|
|
161
176
|
children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-4" })
|
|
162
177
|
}
|
|
@@ -170,7 +185,10 @@ function SelectScrollDownButton({
|
|
|
170
185
|
SelectPrimitive.ScrollDownButton,
|
|
171
186
|
{
|
|
172
187
|
"data-slot": "select-scroll-down-button",
|
|
173
|
-
className: cn(
|
|
188
|
+
className: cn(
|
|
189
|
+
"flex cursor-default items-center justify-center py-1",
|
|
190
|
+
className
|
|
191
|
+
),
|
|
174
192
|
...props,
|
|
175
193
|
children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4" })
|
|
176
194
|
}
|
|
@@ -232,7 +250,10 @@ function Slider({
|
|
|
232
250
|
}
|
|
233
251
|
);
|
|
234
252
|
}
|
|
235
|
-
function Label2({
|
|
253
|
+
function Label2({
|
|
254
|
+
className,
|
|
255
|
+
...props
|
|
256
|
+
}) {
|
|
236
257
|
return /* @__PURE__ */ jsx(
|
|
237
258
|
LabelPrimitive.Root,
|
|
238
259
|
{
|
|
@@ -272,8 +293,16 @@ var GRID_POSITIONS = [
|
|
|
272
293
|
{ x: 0.5, y: 1 },
|
|
273
294
|
{ x: 1, y: 1 }
|
|
274
295
|
];
|
|
275
|
-
var X_LABELS = {
|
|
276
|
-
|
|
296
|
+
var X_LABELS = {
|
|
297
|
+
0: "left",
|
|
298
|
+
0.5: "center",
|
|
299
|
+
1: "right"
|
|
300
|
+
};
|
|
301
|
+
var Y_LABELS = {
|
|
302
|
+
0: "top",
|
|
303
|
+
0.5: "middle",
|
|
304
|
+
1: "bottom"
|
|
305
|
+
};
|
|
277
306
|
function getPositionTitle(pos) {
|
|
278
307
|
return `Position: ${X_LABELS[pos.x] ?? "center"}, ${Y_LABELS[pos.y] ?? "middle"}`;
|
|
279
308
|
}
|
|
@@ -363,7 +392,10 @@ function ComparisonSliderComponent({
|
|
|
363
392
|
"div",
|
|
364
393
|
{
|
|
365
394
|
ref: containerRef,
|
|
366
|
-
className: cn(
|
|
395
|
+
className: cn(
|
|
396
|
+
"relative overflow-hidden rounded-md cursor-ew-resize select-none",
|
|
397
|
+
className
|
|
398
|
+
),
|
|
367
399
|
style: { height },
|
|
368
400
|
onMouseDown: handleMouseDown,
|
|
369
401
|
onMouseMove: handleMouseMove,
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { useWorkflowStore } from './chunk-
|
|
1
|
+
import { useWorkflowStore } from './chunk-GPYIIWD5.mjs';
|
|
2
2
|
import { useMemo, useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
function useCommentNavigation(nodeId) {
|
|
5
5
|
const nodes = useWorkflowStore((state) => state.nodes);
|
|
6
|
-
const getNodesWithComments = useWorkflowStore(
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const getNodesWithComments = useWorkflowStore(
|
|
7
|
+
(state) => state.getNodesWithComments
|
|
8
|
+
);
|
|
9
|
+
const markCommentViewed = useWorkflowStore(
|
|
10
|
+
(state) => state.markCommentViewed
|
|
11
|
+
);
|
|
12
|
+
const setNavigationTarget = useWorkflowStore(
|
|
13
|
+
(state) => state.setNavigationTarget
|
|
14
|
+
);
|
|
9
15
|
const nodeComment = useMemo(() => {
|
|
10
16
|
const node = nodes.find((n) => n.id === nodeId);
|
|
11
17
|
const data = node?.data;
|
|
@@ -43,9 +49,9 @@ function useCommentNavigation(nodeId) {
|
|
|
43
49
|
return {
|
|
44
50
|
currentIndex: currentIndex + 1,
|
|
45
51
|
// 1-based for display
|
|
46
|
-
|
|
52
|
+
onNext,
|
|
47
53
|
onPrevious,
|
|
48
|
-
|
|
54
|
+
totalCount: nodesWithComments.length
|
|
49
55
|
};
|
|
50
56
|
}
|
|
51
57
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Button } from './chunk-
|
|
2
|
-
import { extractEnumValues, supportsImageInput, validateRequiredSchemaFields, CONNECTION_FIELDS, getSchemaDefaults, getImageDimensions, getVideoMetadata } from './chunk-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { Button } from './chunk-B4EAAKYF.mjs';
|
|
2
|
+
import { extractEnumValues, supportsImageInput, validateRequiredSchemaFields, CONNECTION_FIELDS, getSchemaDefaults, getImageDimensions, getVideoMetadata } from './chunk-VVQ4CH77.mjs';
|
|
3
|
+
import { useWorkflowUIConfig } from './chunk-YUIK4AHM.mjs';
|
|
4
|
+
import { useExecutionStore } from './chunk-OJWVEEMM.mjs';
|
|
5
|
+
import { useWorkflowStore } from './chunk-GPYIIWD5.mjs';
|
|
6
6
|
import { useMemo, useCallback, useRef, useEffect, useState } from 'react';
|
|
7
7
|
import { ChevronDown, Expand, Square, Play } from 'lucide-react';
|
|
8
8
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -44,11 +44,11 @@ function useAIGenNode({
|
|
|
44
44
|
[nodeId, updateNodeData]
|
|
45
45
|
);
|
|
46
46
|
return {
|
|
47
|
-
|
|
47
|
+
componentSchemas,
|
|
48
48
|
enumValues,
|
|
49
|
-
modelSupportsImageInput,
|
|
50
49
|
handleSchemaParamChange,
|
|
51
|
-
|
|
50
|
+
modelSupportsImageInput,
|
|
51
|
+
schemaProperties
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
function useAIGenNodeHeader({
|
|
@@ -79,7 +79,16 @@ function useAIGenNodeHeader({
|
|
|
79
79
|
);
|
|
80
80
|
const headerActions = useMemo(
|
|
81
81
|
() => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
82
|
-
hasOutput && /* @__PURE__ */ jsx(
|
|
82
|
+
hasOutput && /* @__PURE__ */ jsx(
|
|
83
|
+
Button,
|
|
84
|
+
{
|
|
85
|
+
variant: "ghost",
|
|
86
|
+
size: "icon-sm",
|
|
87
|
+
onClick: onExpand,
|
|
88
|
+
title: "Expand preview",
|
|
89
|
+
children: /* @__PURE__ */ jsx(Expand, { className: "h-3 w-3" })
|
|
90
|
+
}
|
|
91
|
+
),
|
|
83
92
|
isProcessing ? /* @__PURE__ */ jsxs(Button, { variant: "destructive", size: "sm", onClick: onStop, children: [
|
|
84
93
|
/* @__PURE__ */ jsx(Square, { className: "h-4 w-4 fill-current" }),
|
|
85
94
|
"Generating"
|
|
@@ -99,7 +108,7 @@ function useAIGenNodeHeader({
|
|
|
99
108
|
] }),
|
|
100
109
|
[hasOutput, isProcessing, canGenerate, onGenerate, onStop, onExpand]
|
|
101
110
|
);
|
|
102
|
-
return {
|
|
111
|
+
return { headerActions, titleElement };
|
|
103
112
|
}
|
|
104
113
|
function useAutoLoadModelSchema({
|
|
105
114
|
currentModel,
|
|
@@ -119,7 +128,10 @@ function useAutoLoadModelSchema({
|
|
|
119
128
|
let isCancelled = false;
|
|
120
129
|
const loadSchema = async () => {
|
|
121
130
|
try {
|
|
122
|
-
const model = await modelSchema.fetchModelSchema(
|
|
131
|
+
const model = await modelSchema.fetchModelSchema(
|
|
132
|
+
modelId,
|
|
133
|
+
controller.signal
|
|
134
|
+
);
|
|
123
135
|
if (model && !isCancelled) {
|
|
124
136
|
hasAttemptedSchemaLoad.current = true;
|
|
125
137
|
onModelSelect(model);
|
|
@@ -139,10 +151,16 @@ function useRequiredInputs(nodeId, nodeType) {
|
|
|
139
151
|
return useMemo(() => {
|
|
140
152
|
const nodeDef = NODE_DEFINITIONS[nodeType];
|
|
141
153
|
if (!nodeDef) {
|
|
142
|
-
return {
|
|
154
|
+
return {
|
|
155
|
+
connectionStatus: /* @__PURE__ */ new Map(),
|
|
156
|
+
hasRequiredInputs: true,
|
|
157
|
+
missingInputs: []
|
|
158
|
+
};
|
|
143
159
|
}
|
|
144
160
|
const incomingEdges = edges.filter((e) => e.target === nodeId);
|
|
145
|
-
const connectedHandles = new Set(
|
|
161
|
+
const connectedHandles = new Set(
|
|
162
|
+
incomingEdges.map((e) => e.targetHandle).filter(Boolean)
|
|
163
|
+
);
|
|
146
164
|
const connectionStatus = /* @__PURE__ */ new Map();
|
|
147
165
|
const missingInputs = [];
|
|
148
166
|
for (const input of nodeDef.inputs) {
|
|
@@ -153,9 +171,9 @@ function useRequiredInputs(nodeId, nodeType) {
|
|
|
153
171
|
}
|
|
154
172
|
}
|
|
155
173
|
return {
|
|
174
|
+
connectionStatus,
|
|
156
175
|
hasRequiredInputs: missingInputs.length === 0,
|
|
157
|
-
missingInputs
|
|
158
|
-
connectionStatus
|
|
176
|
+
missingInputs
|
|
159
177
|
};
|
|
160
178
|
}, [nodeId, nodeType, edges]);
|
|
161
179
|
}
|
|
@@ -178,8 +196,13 @@ function useCanGenerate({
|
|
|
178
196
|
inputSchema,
|
|
179
197
|
schemaParams
|
|
180
198
|
}) {
|
|
181
|
-
const { hasRequiredInputs, missingInputs } = useRequiredInputs(
|
|
182
|
-
|
|
199
|
+
const { hasRequiredInputs, missingInputs } = useRequiredInputs(
|
|
200
|
+
nodeId,
|
|
201
|
+
nodeType
|
|
202
|
+
);
|
|
203
|
+
const getConnectedInputs = useWorkflowStore(
|
|
204
|
+
(state) => state.getConnectedInputs
|
|
205
|
+
);
|
|
183
206
|
const incomingEdgesSelector = useCallback(
|
|
184
207
|
(state) => state.edges.filter((e) => e.target === nodeId),
|
|
185
208
|
[nodeId]
|
|
@@ -191,7 +214,10 @@ function useCanGenerate({
|
|
|
191
214
|
for (const edge of incomingEdges) {
|
|
192
215
|
const sourceNode = state.nodes.find((n) => n.id === edge.source);
|
|
193
216
|
if (sourceNode) {
|
|
194
|
-
outputs[edge.source] = extractOutputValue(
|
|
217
|
+
outputs[edge.source] = extractOutputValue(
|
|
218
|
+
sourceNode,
|
|
219
|
+
edge.sourceHandle
|
|
220
|
+
);
|
|
195
221
|
}
|
|
196
222
|
}
|
|
197
223
|
return outputs;
|
|
@@ -203,9 +229,9 @@ function useCanGenerate({
|
|
|
203
229
|
const missingItems = [];
|
|
204
230
|
for (const inputId of missingInputs) {
|
|
205
231
|
missingItems.push({
|
|
206
|
-
type: "connection",
|
|
207
232
|
field: inputId,
|
|
208
|
-
message: `Missing connection: ${inputId}
|
|
233
|
+
message: `Missing connection: ${inputId}`,
|
|
234
|
+
type: "connection"
|
|
209
235
|
});
|
|
210
236
|
}
|
|
211
237
|
const connectedInputs = getConnectedInputs(nodeId);
|
|
@@ -234,18 +260,18 @@ function useCanGenerate({
|
|
|
234
260
|
);
|
|
235
261
|
for (const field of schemaValidation.missingFields) {
|
|
236
262
|
missingItems.push({
|
|
237
|
-
type: "schema",
|
|
238
263
|
field,
|
|
239
|
-
message: `Required field: ${field}
|
|
264
|
+
message: `Required field: ${field}`,
|
|
265
|
+
type: "schema"
|
|
240
266
|
});
|
|
241
267
|
}
|
|
242
268
|
const canGenerate = hasRequiredInputs && hasRequiredData && schemaValidation.isValid;
|
|
243
269
|
return {
|
|
244
270
|
canGenerate,
|
|
245
|
-
missingItems,
|
|
246
|
-
hasRequiredConnections: hasRequiredInputs,
|
|
247
271
|
hasConnectedData,
|
|
248
|
-
|
|
272
|
+
hasRequiredConnections: hasRequiredInputs,
|
|
273
|
+
hasRequiredSchemaFields: schemaValidation.isValid,
|
|
274
|
+
missingItems
|
|
249
275
|
};
|
|
250
276
|
}, [
|
|
251
277
|
nodeId,
|
|
@@ -265,17 +291,17 @@ function useModelSelection({ nodeId, modelMap, fallbackModel }) {
|
|
|
265
291
|
const internalModel = modelMap[model.id] ?? fallbackModel;
|
|
266
292
|
const schemaDefaults = getSchemaDefaults(model.inputSchema);
|
|
267
293
|
const selectedModel = {
|
|
268
|
-
|
|
269
|
-
modelId: model.id,
|
|
294
|
+
componentSchemas: model.componentSchemas,
|
|
270
295
|
displayName: model.displayName,
|
|
271
296
|
inputSchema: model.inputSchema,
|
|
272
|
-
|
|
297
|
+
modelId: model.id,
|
|
298
|
+
provider: model.provider
|
|
273
299
|
};
|
|
274
300
|
updateNodeData(nodeId, {
|
|
275
301
|
model: internalModel,
|
|
276
302
|
provider: model.provider,
|
|
277
|
-
|
|
278
|
-
|
|
303
|
+
schemaParams: schemaDefaults,
|
|
304
|
+
selectedModel
|
|
279
305
|
});
|
|
280
306
|
},
|
|
281
307
|
[nodeId, modelMap, fallbackModel, updateNodeData]
|
|
@@ -285,7 +311,9 @@ function useModelSelection({ nodeId, modelMap, fallbackModel }) {
|
|
|
285
311
|
function useNodeExecution(nodeId) {
|
|
286
312
|
const updateNodeData = useWorkflowStore((state) => state.updateNodeData);
|
|
287
313
|
const executeNode = useExecutionStore((state) => state.executeNode);
|
|
288
|
-
const stopNodeExecution = useExecutionStore(
|
|
314
|
+
const stopNodeExecution = useExecutionStore(
|
|
315
|
+
(state) => state.stopNodeExecution
|
|
316
|
+
);
|
|
289
317
|
const handleGenerate = useCallback(() => {
|
|
290
318
|
updateNodeData(nodeId, { status: NodeStatusEnum.PROCESSING });
|
|
291
319
|
executeNode(nodeId);
|
|
@@ -381,8 +409,8 @@ function useMediaUpload({
|
|
|
381
409
|
const meta = await getVideoMetadata(urlValue);
|
|
382
410
|
metadata = {
|
|
383
411
|
duration: meta.duration,
|
|
384
|
-
|
|
385
|
-
|
|
412
|
+
height: meta.dimensions.height,
|
|
413
|
+
width: meta.dimensions.width
|
|
386
414
|
};
|
|
387
415
|
}
|
|
388
416
|
updateNodeData(nodeId, buildUrlUpdateRef.current(urlValue, metadata));
|
|
@@ -404,15 +432,15 @@ function useMediaUpload({
|
|
|
404
432
|
);
|
|
405
433
|
return {
|
|
406
434
|
fileInputRef,
|
|
407
|
-
showUrlInput,
|
|
408
|
-
setShowUrlInput,
|
|
409
|
-
urlValue,
|
|
410
|
-
setUrlValue,
|
|
411
|
-
isUploading,
|
|
412
435
|
handleFileSelect,
|
|
413
436
|
handleRemove,
|
|
437
|
+
handleUrlKeyDown,
|
|
414
438
|
handleUrlSubmit,
|
|
415
|
-
|
|
439
|
+
isUploading,
|
|
440
|
+
setShowUrlInput,
|
|
441
|
+
setUrlValue,
|
|
442
|
+
showUrlInput,
|
|
443
|
+
urlValue
|
|
416
444
|
};
|
|
417
445
|
}
|
|
418
446
|
function usePromptAutocomplete({
|
|
@@ -423,7 +451,10 @@ function usePromptAutocomplete({
|
|
|
423
451
|
onTemplateCommit
|
|
424
452
|
}) {
|
|
425
453
|
const [showAutocomplete, setShowAutocomplete] = useState(false);
|
|
426
|
-
const [autocompletePosition, setAutocompletePosition] = useState({
|
|
454
|
+
const [autocompletePosition, setAutocompletePosition] = useState({
|
|
455
|
+
left: 0,
|
|
456
|
+
top: 0
|
|
457
|
+
});
|
|
427
458
|
const [autocompleteFilter, setAutocompleteFilter] = useState("");
|
|
428
459
|
const [selectedAutocompleteIndex, setSelectedAutocompleteIndex] = useState(0);
|
|
429
460
|
const filteredAutocompleteVars = useMemo(() => {
|
|
@@ -469,7 +500,7 @@ function usePromptAutocomplete({
|
|
|
469
500
|
const currentLine = lines.length - 1;
|
|
470
501
|
const top = currentLine * lineHeight + 30;
|
|
471
502
|
const left = 10;
|
|
472
|
-
setAutocompletePosition({
|
|
503
|
+
setAutocompletePosition({ left, top });
|
|
473
504
|
setShowAutocomplete(true);
|
|
474
505
|
} else {
|
|
475
506
|
setShowAutocomplete(false);
|
|
@@ -482,7 +513,9 @@ function usePromptAutocomplete({
|
|
|
482
513
|
if (!showAutocomplete) return;
|
|
483
514
|
if (e.key === "ArrowDown") {
|
|
484
515
|
e.preventDefault();
|
|
485
|
-
setSelectedAutocompleteIndex(
|
|
516
|
+
setSelectedAutocompleteIndex(
|
|
517
|
+
(prev) => (prev + 1) % filteredAutocompleteVars.length
|
|
518
|
+
);
|
|
486
519
|
} else if (e.key === "ArrowUp") {
|
|
487
520
|
e.preventDefault();
|
|
488
521
|
setSelectedAutocompleteIndex(
|
|
@@ -491,7 +524,9 @@ function usePromptAutocomplete({
|
|
|
491
524
|
} else if (e.key === "Enter" || e.key === "Tab") {
|
|
492
525
|
if (filteredAutocompleteVars.length > 0) {
|
|
493
526
|
e.preventDefault();
|
|
494
|
-
handleAutocompleteSelect(
|
|
527
|
+
handleAutocompleteSelect(
|
|
528
|
+
filteredAutocompleteVars[selectedAutocompleteIndex].name
|
|
529
|
+
);
|
|
495
530
|
}
|
|
496
531
|
} else if (e.key === "Escape") {
|
|
497
532
|
e.preventDefault();
|
|
@@ -510,14 +545,14 @@ function usePromptAutocomplete({
|
|
|
510
545
|
setShowAutocomplete(false);
|
|
511
546
|
}, []);
|
|
512
547
|
return {
|
|
513
|
-
showAutocomplete,
|
|
514
548
|
autocompletePosition,
|
|
549
|
+
closeAutocomplete,
|
|
515
550
|
filteredAutocompleteVars,
|
|
516
|
-
|
|
551
|
+
handleAutocompleteSelect,
|
|
517
552
|
handleChange,
|
|
518
553
|
handleKeyDown,
|
|
519
|
-
|
|
520
|
-
|
|
554
|
+
selectedAutocompleteIndex,
|
|
555
|
+
showAutocomplete
|
|
521
556
|
};
|
|
522
557
|
}
|
|
523
558
|
|