@@ -22,6 +22,8 @@ interface EditContextProps {
22
22
interface EditContextState {
23
23
loading : boolean ;
24
24
setLoading : ( loading : boolean ) => void ;
25
+ notFound : boolean ;
26
+ setNotFound : ( notFound : boolean ) => void ;
25
27
root : Tool ;
26
28
dependencies : DependencyBlock [ ] ; setDependencies : React . Dispatch < React . SetStateAction < DependencyBlock [ ] > > ;
27
29
models : string [ ] , setModels : React . Dispatch < React . SetStateAction < string [ ] > > ;
@@ -48,6 +50,7 @@ interface EditContextState {
48
50
const EditContext = createContext < EditContextState > ( { } as EditContextState ) ;
49
51
const EditContextProvider : React . FC < EditContextProps > = ( { scriptPath, children} ) => {
50
52
const [ loading , setLoading ] = useState ( true ) ;
53
+ const [ notFound , setNotFound ] = useState ( false ) ;
51
54
const [ root , setRoot ] = useState < Tool > ( { } as Tool ) ;
52
55
const [ tools , setTools ] = useState < Tool [ ] > ( [ ] ) ;
53
56
const [ script , setScript ] = useState < Block [ ] > ( [ ] ) ;
@@ -72,6 +75,10 @@ const EditContextProvider: React.FC<EditContextProps> = ({scriptPath, children})
72
75
73
76
getScript ( scriptPath )
74
77
. then ( async ( script ) => {
78
+ if ( script === undefined ) {
79
+ setNotFound ( true ) ;
80
+ return ;
81
+ }
75
82
const parsedScript = await parse ( script . content || '' )
76
83
const texts = await getTexts ( script . content || '' ) ;
77
84
setScript ( parsedScript ) ;
@@ -223,6 +230,7 @@ const EditContextProvider: React.FC<EditContextProps> = ({scriptPath, children})
223
230
dynamicInstructions, setDynamicInstructions,
224
231
models, setModels,
225
232
loading, setLoading,
233
+ notFound, setNotFound,
226
234
root, setRoot,
227
235
tools, setTools,
228
236
script, setScript,
0 commit comments