@@ -22,6 +22,8 @@ interface EditContextProps {
2222interface EditContextState {
2323 loading : boolean ;
2424 setLoading : ( loading : boolean ) => void ;
25+ notFound : boolean ;
26+ setNotFound : ( notFound : boolean ) => void ;
2527 root : Tool ;
2628 dependencies : DependencyBlock [ ] ; setDependencies : React . Dispatch < React . SetStateAction < DependencyBlock [ ] > > ;
2729 models : string [ ] , setModels : React . Dispatch < React . SetStateAction < string [ ] > > ;
@@ -48,6 +50,7 @@ interface EditContextState {
4850const EditContext = createContext < EditContextState > ( { } as EditContextState ) ;
4951const EditContextProvider : React . FC < EditContextProps > = ( { scriptPath, children} ) => {
5052 const [ loading , setLoading ] = useState ( true ) ;
53+ const [ notFound , setNotFound ] = useState ( false ) ;
5154 const [ root , setRoot ] = useState < Tool > ( { } as Tool ) ;
5255 const [ tools , setTools ] = useState < Tool [ ] > ( [ ] ) ;
5356 const [ script , setScript ] = useState < Block [ ] > ( [ ] ) ;
@@ -72,6 +75,10 @@ const EditContextProvider: React.FC<EditContextProps> = ({scriptPath, children})
7275
7376 getScript ( scriptPath )
7477 . then ( async ( script ) => {
78+ if ( script === undefined ) {
79+ setNotFound ( true ) ;
80+ return ;
81+ }
7582 const parsedScript = await parse ( script . content || '' )
7683 const texts = await getTexts ( script . content || '' ) ;
7784 setScript ( parsedScript ) ;
@@ -223,6 +230,7 @@ const EditContextProvider: React.FC<EditContextProps> = ({scriptPath, children})
223230 dynamicInstructions, setDynamicInstructions,
224231 models, setModels,
225232 loading, setLoading,
233+ notFound, setNotFound,
226234 root, setRoot,
227235 tools, setTools,
228236 script, setScript,
0 commit comments