Skip to content

Commit ec43eac

Browse files
committed
multiple fixes but most importantly improving restarting a flow after updating some node-types
1 parent 1e4d034 commit ec43eac

File tree

6 files changed

+191
-33
lines changed

6 files changed

+191
-33
lines changed

examples-test-flows/openai-fetch-completion-as-stream.json

Lines changed: 125 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"nodes": [
99
{
1010
"id": "8f4ac174-5c8e-45da-8ad4-a81a40f4f666",
11-
"x": 3705.3357978745244,
12-
"y": 1054.0469793471455,
11+
"x": 3705.3356695038824,
12+
"y": 1054.0469817505104,
1313
"width": 200,
1414
"height": 155,
1515
"nodeType": "Shape",
@@ -25,8 +25,8 @@
2525
},
2626
{
2727
"id": "3cf44538-9913-4aa2-aade-a7c619910f45",
28-
"x": 2870.5595746525687,
29-
"y": 1063.2936725366305,
28+
"x": 2870.237434699719,
29+
"y": 1063.2936656401973,
3030
"width": 161.1015625,
3131
"height": 136,
3232
"nodeType": "Shape",
@@ -46,8 +46,8 @@
4646
"id": "d186a002-218b-47dc-aae8-07522a3da6ed",
4747
"x": 4086.2794839807348,
4848
"y": 1055.5511660082343,
49-
"width": 119.99986652031868,
50-
"height": 272.00006594174204,
49+
"width": 119.9999294340761,
50+
"height": 272.00006892594394,
5151
"nodeType": "Shape",
5252
"nodeInfo": {
5353
"type": "show-input",
@@ -63,8 +63,8 @@
6363
"id": "383eb9cf-3b45-489e-8281-720b702b9159",
6464
"x": 3302.6185234344857,
6565
"y": 529.4952359949934,
66-
"width": 239.99998428769624,
67-
"height": 95.99999371507849,
66+
"width": 240.0000734388129,
67+
"height": 95.99998646139302,
6868
"nodeType": "Shape",
6969
"nodeInfo": {
7070
"type": "scope-variable",
@@ -117,8 +117,8 @@
117117
},
118118
{
119119
"id": "bfc480ee-0c81-4221-a725-252298402221",
120-
"x": 4363.497084971121,
121-
"y": 1061.016367383506,
120+
"x": 4363.497086195699,
121+
"y": 1061.0164055112382,
122122
"width": 110,
123123
"height": 110,
124124
"nodeType": "Shape",
@@ -165,8 +165,8 @@
165165
},
166166
{
167167
"id": "2a227359-4016-4fa7-9788-948030bc0e90",
168-
"x": 3287.9477488867783,
169-
"y": 1054.0470154874329,
168+
"x": 3287.9477754176096,
169+
"y": 1054.0469817505104,
170170
"width": 200,
171171
"height": 128,
172172
"nodeType": "Shape",
@@ -181,12 +181,65 @@
181181
"keepPopupOpenAfterUpdate": false
182182
}
183183
},
184+
{
185+
"id": "38a6cf26-b1c4-460d-92b0-86656e215a5a",
186+
"x": 4930.955909075822,
187+
"y": 626.8231157984133,
188+
"width": 200,
189+
"height": 96,
190+
"nodeType": "Shape",
191+
"nodeInfo": {
192+
"type": "join-array",
193+
"formValues": {
194+
"joinChar": ""
195+
},
196+
"nodeCannotBeReplaced": false,
197+
"showFormOnlyInPopup": false,
198+
"useInCompositionOnly": false,
199+
"keepPopupOpenAfterUpdate": false
200+
}
201+
},
202+
{
203+
"id": "b936e1cd-134c-4476-b412-342c7d89c762",
204+
"x": 5483.973522524997,
205+
"y": 643.887255157914,
206+
"width": 119.9999294340761,
207+
"height": 56.00004574514444,
208+
"nodeType": "Shape",
209+
"nodeInfo": {
210+
"type": "show-input",
211+
"formValues": {
212+
"name": "",
213+
"data-type": "default"
214+
},
215+
"initializeOnStartFlow": true,
216+
"isSettingsPopup": true
217+
}
218+
},
219+
{
220+
"id": "471f94ef-642e-4065-9b19-600e87184b0c",
221+
"x": 4578.4913247279355,
222+
"y": 654.9053277392578,
223+
"width": 200,
224+
"height": 64,
225+
"nodeType": "Shape",
226+
"nodeInfo": {
227+
"type": "get-array",
228+
"formValues": {
229+
"variableName": "result"
230+
},
231+
"nodeCannotBeReplaced": false,
232+
"showFormOnlyInPopup": true,
233+
"useInCompositionOnly": false,
234+
"keepPopupOpenAfterUpdate": false
235+
}
236+
},
184237
{
185238
"id": "1a35b609-3594-4529-bec1-2b50b205aa0d",
186-
"x": 3031.6611371525687,
187-
"y": 1131.2936725366305,
188-
"endX": 3287.9477488867783,
189-
"endY": 1118.0470154874329,
239+
"x": 3031.338997199719,
240+
"y": 1131.2936656401973,
241+
"endX": 3287.9477754176096,
242+
"endY": 1118.0469817505104,
190243
"startNodeId": "3cf44538-9913-4aa2-aade-a7c619910f45",
191244
"endNodeId": "2a227359-4016-4fa7-9788-948030bc0e90",
192245
"startThumbName": "input",
@@ -198,8 +251,8 @@
198251
},
199252
{
200253
"id": "a16c5c54-c867-41af-a922-9a014786c513",
201-
"x": 3905.3357978745244,
202-
"y": 1084.0469793471455,
254+
"x": 3905.3356695038824,
255+
"y": 1084.0469817505104,
203256
"endX": 4086.2794839807348,
204257
"endY": 1085.5511660082343,
205258
"startNodeId": "8f4ac174-5c8e-45da-8ad4-a81a40f4f666",
@@ -213,10 +266,10 @@
213266
},
214267
{
215268
"id": "9c9efadf-8473-439f-849b-1fa8cbc09ad5",
216-
"x": 4206.279350501053,
269+
"x": 4206.279413414811,
217270
"y": 1085.5511660082343,
218-
"endX": 4363.497084971121,
219-
"endY": 1116.016367383506,
271+
"endX": 4363.497086195699,
272+
"endY": 1116.0164055112382,
220273
"startNodeId": "d186a002-218b-47dc-aae8-07522a3da6ed",
221274
"endNodeId": "bfc480ee-0c81-4221-a725-252298402221",
222275
"startThumbName": "output",
@@ -243,8 +296,8 @@
243296
},
244297
{
245298
"id": "441e2ae8-bb43-4d98-b5c2-73b5d33f1884",
246-
"x": 4473.497084971121,
247-
"y": 1141.016367383506,
299+
"x": 4473.497086195699,
300+
"y": 1141.0164055112382,
248301
"endX": 4625.622731449648,
249302
"endY": 1138.1032555200543,
250303
"startNodeId": "bfc480ee-0c81-4221-a725-252298402221",
@@ -273,10 +326,10 @@
273326
},
274327
{
275328
"id": "b58697e4-82bf-4d83-917a-03be6daedc12",
276-
"x": 3487.9477488867783,
277-
"y": 1118.0470154874329,
278-
"endX": 3705.3357978745244,
279-
"endY": 1131.5469793471455,
329+
"x": 3487.9477754176096,
330+
"y": 1118.0469817505104,
331+
"endX": 3705.3356695038824,
332+
"endY": 1131.5469817505104,
280333
"startNodeId": "2a227359-4016-4fa7-9788-948030bc0e90",
281334
"endNodeId": "8f4ac174-5c8e-45da-8ad4-a81a40f4f666",
282335
"startThumbName": "output",
@@ -285,6 +338,51 @@
285338
"nodeType": "Connection",
286339
"layer": 1,
287340
"nodeInfo": {}
341+
},
342+
{
343+
"id": "0dd730cc-1691-454f-868c-cb19da250699",
344+
"x": 4473.497086195699,
345+
"y": 1091.0164055112382,
346+
"endX": 4578.4913247279355,
347+
"endY": 686.9053277392578,
348+
"startNodeId": "bfc480ee-0c81-4221-a725-252298402221",
349+
"endNodeId": "471f94ef-642e-4065-9b19-600e87184b0c",
350+
"startThumbName": "output1",
351+
"endThumbName": "input",
352+
"lineType": "BezierCubic",
353+
"nodeType": "Connection",
354+
"layer": 1,
355+
"nodeInfo": {}
356+
},
357+
{
358+
"id": "e93c6ee9-f78f-40b0-94ef-d16b06126c68",
359+
"x": 5130.955909075822,
360+
"y": 674.8231157984133,
361+
"endX": 5483.973522524997,
362+
"endY": 673.887255157914,
363+
"startNodeId": "38a6cf26-b1c4-460d-92b0-86656e215a5a",
364+
"endNodeId": "b936e1cd-134c-4476-b412-342c7d89c762",
365+
"startThumbName": "output",
366+
"endThumbName": "input",
367+
"lineType": "BezierCubic",
368+
"nodeType": "Connection",
369+
"layer": 1,
370+
"nodeInfo": {}
371+
},
372+
{
373+
"id": "31caf385-4ad3-4f88-8702-8feec6f30f4f",
374+
"x": 4778.4913247279355,
375+
"y": 686.9053277392578,
376+
"endX": 4930.955909075822,
377+
"endY": 674.8231157984133,
378+
"startNodeId": "471f94ef-642e-4065-9b19-600e87184b0c",
379+
"endNodeId": "38a6cf26-b1c4-460d-92b0-86656e215a5a",
380+
"startThumbName": "output",
381+
"endThumbName": "input",
382+
"lineType": "BezierCubic",
383+
"nodeType": "Connection",
384+
"layer": 1,
385+
"nodeInfo": {}
288386
}
289387
]
290388
}

libs/app-canvas/src/app/flow-app.element.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,14 @@ export class FlowAppElement extends AppElement<NodeInfo> {
440440
flowChangeType === FlowChangeType.AddConnection ||
441441
flowChangeType === FlowChangeType.UpdateConnection
442442
) {
443+
let interval: any = undefined;
444+
clearTimeout(interval);
443445
console.log('TRIGGER RUN!', getIsStopAnimations());
444446
resetRunIndex();
445447
(this.runButton?.domElement as HTMLButtonElement).disabled = false;
446448
setStopAnimations();
447449
// Wait until isStopAnimations is set to false
448-
const interval = setInterval(() => {
450+
interval = setInterval(() => {
449451
if (!getIsStopAnimations()) {
450452
clearInterval(interval);
451453
this.run();

libs/visual-programming-system/src/components/meta-view-dialog/meta-view-dialog.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { IRectNodeComponent } from '../../interfaces';
22
import {
33
BaseNodeInfo,
4+
IAnyMetaField,
45
IArrayMetaField,
56
IJSonMetaField,
67
IMatrixMetaField,
78
IMetaField,
89
IOtherMetaField,
10+
IStringMetaField,
911
} from '../../types/base-node-info';
1012
import { renderElement, createJSXElement } from '../../utils';
1113

@@ -33,6 +35,18 @@ export const isJsonMetaField = (
3335
return (metaField as unknown as IJSonMetaField).type === 'json';
3436
};
3537

38+
export const isStringMetaField = (
39+
metaField: IMetaField
40+
): metaField is IStringMetaField => {
41+
return (metaField as unknown as IStringMetaField).type === 'string';
42+
};
43+
44+
export const isAnyMetaField = (
45+
metaField: IMetaField
46+
): metaField is IAnyMetaField => {
47+
return (metaField as unknown as IAnyMetaField).type === 'any';
48+
};
49+
3650
export const showMetaViewDialog = (
3751
nodeComponent: IRectNodeComponent<BaseNodeInfo>
3852
) => {
@@ -150,6 +164,14 @@ export const showMetaViewDialog = (
150164
}
151165
}
152166
}
167+
} else if (isStringMetaField(meta) && meta.propertyName) {
168+
renderElement(<h1>{meta.displayName}</h1>, divElement);
169+
const value = meta.getText
170+
? meta.getText()
171+
: nodeComponent.nodeInfo?.formValues?.[meta.propertyName];
172+
if (value) {
173+
renderElement(<p>{value}</p>, divElement);
174+
}
153175
} else if (isJsonMetaField(meta) && meta.propertyName) {
154176
renderElement(<h1>{meta.displayName}</h1>, divElement);
155177
const json =
@@ -164,6 +186,24 @@ export const showMetaViewDialog = (
164186
divElement
165187
);
166188
}
189+
} else if (isAnyMetaField(meta) && meta.propertyName) {
190+
renderElement(<h1>{meta.displayName}</h1>, divElement);
191+
const data =
192+
meta.getData?.() ??
193+
nodeComponent.nodeInfo?.formValues?.[meta.propertyName] ??
194+
{};
195+
if (data) {
196+
if (typeof data === 'object' || Array.isArray(data)) {
197+
renderElement(
198+
<pre class="whitespace-pre-wrap">
199+
{JSON.stringify(data, null, 2)}
200+
</pre>,
201+
divElement
202+
);
203+
} else {
204+
renderElement(<p>{data}</p>, divElement);
205+
}
206+
}
167207
} else if (isArrayMetaField(meta) && meta.propertyName) {
168208
renderElement(<h1>{meta.displayName}</h1>, divElement);
169209
const array = meta.getData

libs/visual-programming-system/src/types/base-node-info.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,18 @@ export interface IJSonMetaField extends IMetaField {
2525
getData?: () => any;
2626
}
2727

28+
export interface IAnyMetaField extends IMetaField {
29+
type: 'any';
30+
getData?: () => any;
31+
}
32+
33+
export interface IStringMetaField extends IMetaField {
34+
type: 'string';
35+
getText?: () => string;
36+
}
37+
2838
export interface IOtherMetaField extends IMetaField {
29-
type: 'string' | 'info' | 'custom';
39+
type: 'info' | 'custom';
3040
description?: string;
3141
getDescription?: () => string;
3242
renderCustom?: () => JSX.Element;
@@ -37,6 +47,8 @@ export type AllMetaFieldTypes =
3747
| IMatrixMetaField
3848
| IArrayMetaField
3949
| IJSonMetaField
50+
| IStringMetaField
51+
| IAnyMetaField
4052
| IOtherMetaField;
4153

4254
export interface INodeDecorator {

libs/web-flow-executor/src/nodes/scoped-variable.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ export const getScopedVariable =
123123
currentValue = [];
124124
}
125125
}
126-
if (data) {
126+
if (data === 0) {
127+
if (scopeId && !isGlobal) {
128+
scopedData[scopeId] = [];
129+
} else {
130+
currentValue = [];
131+
}
132+
} else if (data) {
127133
if (scopeId && !isGlobal) {
128134
if (Array.isArray(data)) {
129135
scopedData[scopeId] = data;

libs/web-flow-executor/src/nodes/show-input.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ export const getShowInput: NodeTaskFactory<NodeInfo> = (
261261
];
262262
node.nodeInfo.meta = [
263263
{
264-
propertyName: 'json',
265-
displayName: 'raw input value',
266-
type: 'json',
264+
propertyName: 'input',
265+
displayName: 'input',
266+
type: 'any',
267267
getData: () => {
268268
return inputValues;
269269
},

0 commit comments

Comments
 (0)