Skip to content

Commit 8a638a3

Browse files
committed
fix bug for resetting canvasapp tempdata after importing flow
1 parent 00b5eee commit 8a638a3

File tree

2 files changed

+153
-29
lines changed

2 files changed

+153
-29
lines changed

examples-test-flows/google-gemini-flash-create-mermaid-diagram-and-openapi-yaml.json

Lines changed: 136 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"id": "c3a8bd9e-f4d5-46db-9384-b1de17a33c5f",
1111
"x": 3914.0981303650296,
1212
"y": 1509.8835261671454,
13-
"width": 120.0001953794722,
14-
"height": 272.00002877196243,
13+
"width": 119.99970924607368,
14+
"height": 271.99996525391947,
1515
"nodeType": "Shape",
1616
"nodeInfo": {
1717
"type": "show-input",
@@ -45,8 +45,8 @@
4545
"id": "8b7d6c8d-1806-4596-a47a-514038cffe13",
4646
"x": 3149.212174053084,
4747
"y": 1326.861468973325,
48-
"width": 174.42197730022014,
49-
"height": 84.00000888545898,
48+
"width": 174.42193533126735,
49+
"height": 84.0000759723274,
5050
"nodeType": "Shape",
5151
"nodeInfo": {
5252
"type": "scope-variable",
@@ -66,8 +66,8 @@
6666
"id": "342b786f-955e-4ef8-968e-60b24427b75a",
6767
"x": 3465.454621654088,
6868
"y": 1255.391240672226,
69-
"width": 174.42197730022014,
70-
"height": 84.00000888545898,
69+
"width": 174.42213093843722,
70+
"height": 83.99997816874246,
7171
"nodeType": "Shape",
7272
"nodeInfo": {
7373
"type": "scope-variable",
@@ -88,7 +88,7 @@
8888
"x": 3313.952444530195,
8989
"y": 1505.1885017162472,
9090
"width": 200,
91-
"height": 165.03125,
91+
"height": 174.7578125,
9292
"nodeType": "Shape",
9393
"nodeInfo": {
9494
"type": "composition-cb3e91c2-6654-4014-af63-b445dffc7f22",
@@ -105,8 +105,8 @@
105105
"id": "2ea8b5ec-c20a-440c-a9b1-2e91b099086c",
106106
"x": 3725.328825736654,
107107
"y": 1715.7699016658066,
108-
"width": 120.0001953794722,
109-
"height": 56.00000592363933,
108+
"width": 120.00005892783024,
109+
"height": 55.9999310536406,
110110
"nodeType": "Shape",
111111
"nodeInfo": {
112112
"type": "show-input",
@@ -122,8 +122,8 @@
122122
"id": "c29665a3-2bdd-4a30-b2b8-a67f3d6d7c18",
123123
"x": 4243.814455933351,
124124
"y": 1402.1353921330267,
125-
"width": 199.99983846989537,
126-
"height": 148.23431039820878,
125+
"width": 199.99227352160653,
126+
"height": 149.10945263413817,
127127
"nodeType": "Shape",
128128
"nodeInfo": {
129129
"type": "mermaid-node",
@@ -157,7 +157,7 @@
157157
"x": 3319.9035792065756,
158158
"y": 2054.039831924315,
159159
"width": 200,
160-
"height": 165.03125,
160+
"height": 174.7578125,
161161
"nodeType": "Shape",
162162
"nodeInfo": {
163163
"type": "composition-cb3e91c2-6654-4014-af63-b445dffc7f22",
@@ -174,8 +174,8 @@
174174
"id": "14c6949e-1438-4780-a09e-c305be78dd9e",
175175
"x": 4104.257555693473,
176176
"y": 2205.2278375828564,
177-
"width": 119.99983000755348,
178-
"height": 272.00002877196243,
177+
"width": 120.0000837918712,
178+
"height": 271.9999651816266,
179179
"nodeType": "Shape",
180180
"nodeInfo": {
181181
"type": "show-input",
@@ -187,10 +187,62 @@
187187
"isSettingsPopup": true
188188
}
189189
},
190+
{
191+
"id": "a5d3e0fc-8228-47a4-9a82-dae013dd4c4a",
192+
"x": 2602.3507120955996,
193+
"y": 1704.5636376206703,
194+
"width": 200,
195+
"height": 200,
196+
"nodeType": "Shape",
197+
"nodeInfo": {
198+
"type": "fetch",
199+
"formValues": {
200+
"url": "https://api.openai.com/v1/chat/completions",
201+
"headers": "Authorization: Bearer [openai-key]"
202+
},
203+
"isSettingsPopup": true
204+
}
205+
},
206+
{
207+
"id": "93c060e8-89a0-474e-acae-1abe69d4f742",
208+
"x": 2324.0799691422144,
209+
"y": 1756.667987830748,
210+
"width": 111.7109375,
211+
"height": 96,
212+
"nodeType": "Shape",
213+
"nodeInfo": {
214+
"type": "json-node",
215+
"formValues": {
216+
"json": "{ \n \"messages\": [\n {\"role\": \"developer\", \"content\": \"You are a helpful assistant.\"},\n {\"role\": \"user\", \"content\": \"create a small random data json object\"}\n ],\n \"model\": \"gpt-4o\",\n \"response_format\" : { \"type\": \"json_object\" }\n}"
217+
},
218+
"nodeCannotBeReplaced": true,
219+
"showFormOnlyInPopup": true,
220+
"useInCompositionOnly": false,
221+
"keepPopupOpenAfterUpdate": true
222+
}
223+
},
224+
{
225+
"id": "0726dce4-0348-438e-967e-cb35af5d6521",
226+
"x": 3037.362157182044,
227+
"y": 1777.6220636654464,
228+
"width": 200,
229+
"height": 100,
230+
"nodeType": "Shape",
231+
"nodeInfo": {
232+
"type": "expression",
233+
"formValues": {
234+
"expression": "choices[0].message.content",
235+
"inputType": "number"
236+
},
237+
"showFormOnlyInPopup": true,
238+
"isSettingsPopup": true,
239+
"supportsPreview": true
240+
}
241+
},
190242
{
191243
"id": "3735612d-a425-45c2-ae8f-8a3adfcde306",
192244
"x": 3513.952444530195,
193-
"y": 1565.2196985171856,
245+
"y": 1569.946314865085,
194246
"endX": 3914.0981303650296,
195247
"endY": 1539.8835261671454,
196248
"startNodeId": "be45d12a-a496-4fd5-b70c-7d779b8ed7bb",
@@ -207,7 +259,7 @@
207259
"x": 2926.3640311889217,
208260
"y": 1553.1434885344127,
209261
"endX": 3313.952444530195,
210-
"endY": 1565.2197517162472,
262+
"endY": 1569.9463142162472,
211263
"startNodeId": "9f1f3e1c-787f-406f-b52b-b6db3e7b85dd",
212264
"endNodeId": "be45d12a-a496-4fd5-b70c-7d779b8ed7bb",
213265
"startThumbName": "output",
@@ -220,7 +272,7 @@
220272
{
221273
"id": "00a0e5fc-39b9-4662-bc1b-dc982dcb50fe",
222274
"x": 3513.952444530195,
223-
"y": 1615.2196985171856,
275+
"y": 1619.946246517597,
224276
"endX": 3725.328825736654,
225277
"endY": 1745.7699016658066,
226278
"startNodeId": "be45d12a-a496-4fd5-b70c-7d779b8ed7bb",
@@ -234,10 +286,10 @@
234286
},
235287
{
236288
"id": "c66d47a3-a145-453c-8f48-b20629a15065",
237-
"x": 4034.098325744502,
289+
"x": 4034.097839611103,
238290
"y": 1539.8835261671454,
239291
"endX": 4243.814455933351,
240-
"endY": 1476.2525473321311,
292+
"endY": 1476.6901184500957,
241293
"startNodeId": "c3a8bd9e-f4d5-46db-9384-b1de17a33c5f",
242294
"endNodeId": "c29665a3-2bdd-4a30-b2b8-a67f3d6d7c18",
243295
"startThumbName": "output",
@@ -252,7 +304,7 @@
252304
"x": 2924.2454873300067,
253305
"y": 2099.360986881521,
254306
"endX": 3319.9035792065756,
255-
"endY": 2114.071081924315,
307+
"endY": 2118.797644424315,
256308
"startNodeId": "1438dcf5-ebdf-47c3-b793-818ec7676f04",
257309
"endNodeId": "d392400d-d256-4a13-93f0-48ef7f441833",
258310
"startThumbName": "output",
@@ -265,7 +317,7 @@
265317
{
266318
"id": "fa69fcd7-6fc0-4640-987f-07b361bac08b",
267319
"x": 3519.9035792065756,
268-
"y": 2114.0710287252537,
320+
"y": 2118.797645063915,
269321
"endX": 4104.257555693473,
270322
"endY": 2235.2278375828564,
271323
"startNodeId": "d392400d-d256-4a13-93f0-48ef7f441833",
@@ -276,6 +328,69 @@
276328
"nodeType": "Connection",
277329
"layer": 1,
278330
"nodeInfo": {}
331+
},
332+
{
333+
"id": "950f61cd-4355-4dad-ac74-016c1df54253",
334+
"x": 2435.7909066422144,
335+
"y": 1804.667987830748,
336+
"endX": 2602.3507120955996,
337+
"endY": 1804.5636376206703,
338+
"startNodeId": "93c060e8-89a0-474e-acae-1abe69d4f742",
339+
"endNodeId": "a5d3e0fc-8228-47a4-9a82-dae013dd4c4a",
340+
"startThumbName": "output",
341+
"endThumbName": "input",
342+
"lineType": "BezierCubic",
343+
"nodeType": "Connection",
344+
"layer": 1,
345+
"nodeInfo": {}
346+
},
347+
{
348+
"id": "b489f5bf-9cff-4027-809b-ea291203df78",
349+
"x": 2802.3507120955996,
350+
"y": 1734.5636376206703,
351+
"endX": 3037.362157182044,
352+
"endY": 1827.6220636654464,
353+
"startNodeId": "a5d3e0fc-8228-47a4-9a82-dae013dd4c4a",
354+
"endNodeId": "0726dce4-0348-438e-967e-cb35af5d6521",
355+
"startThumbName": "output",
356+
"endThumbName": "input",
357+
"lineType": "BezierCubic",
358+
"nodeType": "Connection",
359+
"layer": 1,
360+
"nodeInfo": {}
361+
},
362+
{
363+
"id": "563e736a-88f0-4a2b-be6a-8c145dba22bd",
364+
"x": 3237.362157182044,
365+
"y": 1827.6220636654464,
366+
"endX": 3566.1439515630404,
367+
"endY": 1932.2574620250257,
368+
"startNodeId": "0726dce4-0348-438e-967e-cb35af5d6521",
369+
"endNodeId": "64166334-15ee-4ec8-979c-b06fe3877b49",
370+
"startThumbName": "output",
371+
"endThumbName": "input",
372+
"lineType": "BezierCubic",
373+
"nodeType": "Connection",
374+
"layer": 1,
375+
"nodeInfo": {}
376+
},
377+
{
378+
"id": "64166334-15ee-4ec8-979c-b06fe3877b49",
379+
"x": 3566.1439515630404,
380+
"y": 1902.2574620250257,
381+
"width": 120.0000837918712,
382+
"height": 271.9999651816266,
383+
"nodeType": "Shape",
384+
"nodeInfo": {
385+
"type": "show-input",
386+
"formValues": {
387+
"name": "",
388+
"data-type": "default"
389+
},
390+
"initializeOnStartFlow": true,
391+
"isSettingsPopup": true,
392+
"taskType": "show-input"
393+
}
279394
}
280395
]
281396
}

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,20 @@ export class FlowAppElement extends AppElement<NodeInfo> {
230230
return false;
231231
};
232232

233+
initAPIKey = () => {
234+
if (!this.canvasApp) {
235+
return;
236+
}
237+
const openAIKey = sessionStorage.getItem('openai-key');
238+
const googleGeminiAIKey = sessionStorage.getItem('googleGeminiAI-key');
239+
if (openAIKey) {
240+
this.canvasApp.setTempData('openai-key', openAIKey);
241+
}
242+
if (googleGeminiAIKey) {
243+
this.canvasApp.setTempData('googleGeminiAI-key', googleGeminiAIKey);
244+
}
245+
};
246+
233247
constructor(
234248
appRootSelector: string,
235249
storageProvider?: StorageProvider<NodeInfo>,
@@ -280,14 +294,7 @@ export class FlowAppElement extends AppElement<NodeInfo> {
280294
let intervalCancel: any = undefined;
281295
let intervalPreview: any = undefined;
282296

283-
const openAIKey = sessionStorage.getItem('openai-key');
284-
const googleGeminiAIKey = sessionStorage.getItem('googleGeminiAI-key');
285-
if (openAIKey) {
286-
this.canvasApp.setTempData('openai-key', openAIKey);
287-
}
288-
if (googleGeminiAIKey) {
289-
this.canvasApp.setTempData('googleGeminiAI-key', googleGeminiAIKey);
290-
}
297+
this.initAPIKey();
291298

292299
this.canvasApp.setOnDraggingOverNode((node, draggedNode, isCancelling) => {
293300
const connection = draggedNode as IConnectionNodeComponent<NodeInfo>;
@@ -755,6 +762,7 @@ export class FlowAppElement extends AppElement<NodeInfo> {
755762
);
756763
this.updateToolbarTaskList?.();
757764
canvasUpdated();
765+
this.initAPIKey();
758766
},
759767
});
760768
if (!isReadOnly) {
@@ -1001,6 +1009,7 @@ export class FlowAppElement extends AppElement<NodeInfo> {
10011009
this.updateToolbarTaskList?.();
10021010
this.isStoring = false;
10031011
canvasUpdated();
1012+
this.initAPIKey();
10041013
},
10051014
});
10061015

0 commit comments

Comments
 (0)