@@ -8,6 +8,7 @@ import type {
88 OutputSpec ,
99 TaskSpec ,
1010} from "@/utils/componentSpec" ;
11+ import { deepClone } from "@/utils/deepClone" ;
1112import {
1213 getUniqueInputName ,
1314 getUniqueOutputName ,
@@ -20,7 +21,7 @@ const addTask = (
2021 position : XYPosition ,
2122 componentSpec : ComponentSpec ,
2223) : ComponentSpec => {
23- const newComponentSpec = { ... componentSpec } ;
24+ const newComponentSpec = deepClone ( componentSpec ) ;
2425
2526 if ( ! ( "graph" in newComponentSpec . implementation ) ) {
2627 console . error ( "Implementation does not contain a graph." ) ;
@@ -77,24 +78,24 @@ const addTask = (
7778 }
7879
7980 if ( taskType === "input" ) {
80- const inputId = getUniqueInputName ( componentSpec ) ;
81+ const inputId = getUniqueInputName ( newComponentSpec ) ;
8182 const inputSpec : InputSpec = {
8283 name : inputId ,
8384 annotations : positionAnnotations ,
8485 } ;
85- const inputs = ( componentSpec . inputs ?? [ ] ) . concat ( [ inputSpec ] ) ;
86+ const inputs = ( newComponentSpec . inputs ?? [ ] ) . concat ( [ inputSpec ] ) ;
8687
8788 newComponentSpec . inputs = inputs ;
8889 }
8990
9091 if ( taskType === "output" ) {
91- const outputId = getUniqueOutputName ( componentSpec ) ;
92+ const outputId = getUniqueOutputName ( newComponentSpec ) ;
9293 const outputSpec : OutputSpec = {
9394 name : outputId ,
9495 annotations : positionAnnotations ,
9596 } ;
9697
97- const outputs = ( componentSpec . outputs ?? [ ] ) . concat ( [ outputSpec ] ) ;
98+ const outputs = ( newComponentSpec . outputs ?? [ ] ) . concat ( [ outputSpec ] ) ;
9899
99100 newComponentSpec . outputs = outputs ;
100101 }
0 commit comments