From 053f10882428fa3ab6d0098ab59f6fb9f3755cd0 Mon Sep 17 00:00:00 2001 From: Ronen Mars Date: Tue, 28 Jan 2025 11:29:53 +0200 Subject: [PATCH] fix(UI-1262): fix entrypoint deconstruction for manual run (#937) --- src/store/useManualRunStore.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/store/useManualRunStore.ts b/src/store/useManualRunStore.ts index 30e5bfce1..d342ff042 100644 --- a/src/store/useManualRunStore.ts +++ b/src/store/useManualRunStore.ts @@ -67,7 +67,7 @@ const store: StateCreator = (set, get) => ({ projectId, { activeDeployment, entrypointFunction, filePath, files, isJson, isManualRunEnabled, params } ) => { - const { entrypointFunction: currentEntrypoint, filePath: currentFile } = get().projectManualRun[projectId]; + const previousProjectManualRunState = get().projectManualRun[projectId]; set((state) => { const projectData = { ...defaultManualRunState, @@ -82,7 +82,12 @@ const store: StateCreator = (set, get) => ({ projectData.files = files; projectData.fileOptions = fileOptions; - if (!files[currentFile?.value]?.includes(currentEntrypoint?.value)) { + const { filePath: prevFilePath, entrypointFunction: prevEntrypointFunction } = + previousProjectManualRunState || {}; + const fileExists = prevFilePath?.value && files?.[prevFilePath.value]; + const entrypointExists = fileExists?.includes(prevEntrypointFunction?.value); + + if (!entrypointExists) { Object.assign(projectData, { filePath: fileOptions[0], entrypointFunction: emptySelectItem }); } }