From 94f0bfef795f15ec752ee325ea88b6c21867079c Mon Sep 17 00:00:00 2001 From: Kurt Hutten Irev-Dev Date: Fri, 2 May 2025 21:21:16 +1000 Subject: [PATCH] push fix of sorts --- src/components/ToastTextToCad.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/ToastTextToCad.tsx b/src/components/ToastTextToCad.tsx index 75e84cb41..29cc48d51 100644 --- a/src/components/ToastTextToCad.tsx +++ b/src/components/ToastTextToCad.tsx @@ -606,6 +606,12 @@ export const writeOverFilesAndExecute = async ({ }) }) + const mainCodeInfo = kclManager.execState.filenames[0] + const mainCodePath = mainCodeInfo?.type === 'Local' ? mainCodeInfo.value : '' + const mainCodeContent = requestedFiles.find((file) => + mainCodePath.endsWith(file.requestedFileName) + )?.requestedCode + systemIOActor.send({ type: SystemIOMachineEvents.bulkCreateKCLFilesAndNavigateToProject, data: { @@ -618,13 +624,9 @@ export const writeOverFilesAndExecute = async ({ // Wait for the bulk create operation to complete await bulkCreatePromise - // TODO: get rid of this, the fact that a random wait is needed is a sign that there's a race and - // the bulkCreatePromise is not enough. - // just an an observation running tron:start does not need this timeout, - // but running tronb:package:dev && ./out/mac-arm64/Zoo\ Design\ Studio.app/Contents/MacOS/Zoo\ Design\ Studio - // is a different story, some how a race that only shows up when packaged - await new Promise((r) => setTimeout(r, 100)) - // Now execute the code after all files are written + if (mainCodeContent) { + codeManager.updateCodeEditor(mainCodeContent) + } await kclManager.executeCode() }