Revert the migration to promise actor
This commit is contained in:
		| @ -40,9 +40,6 @@ export type ModelingCommandSchema = { | ||||
|   Loft: { | ||||
|     selection: Selections | ||||
|   } | ||||
|   'Delete selection': { | ||||
|     selection: Selections | ||||
|   } | ||||
|   Shell: { | ||||
|     selection: Selections | ||||
|     thickness: KclCommandValue | ||||
|  | ||||
| @ -237,7 +237,6 @@ export type ModelingMachineEvent = | ||||
|     } | ||||
|   | { | ||||
|       type: 'Delete selection' | ||||
|       data?: ModelingCommandSchema['Delete selection'] | ||||
|     } | ||||
|   | { type: 'Sketch no face' } | ||||
|   | { type: 'Toggle gui mode' } | ||||
| @ -732,6 +731,38 @@ export const modelingMachine = setup({ | ||||
|         } | ||||
|       })().catch(reportRejection) | ||||
|     }, | ||||
|     'AST delete selection': ({ context: { selectionRanges } }) => { | ||||
|       ;(async () => { | ||||
|         const errorMessage = | ||||
|           'Unable to delete selection. Please edit manually in code pane.' | ||||
|         let ast = kclManager.ast | ||||
|  | ||||
|         const modifiedAst = await deleteFromSelection( | ||||
|           ast, | ||||
|           selectionRanges.graphSelections[0], | ||||
|           kclManager.programMemory, | ||||
|           getFaceDetails | ||||
|         ) | ||||
|         if (err(modifiedAst)) { | ||||
|           toast.error(errorMessage) | ||||
|           return | ||||
|         } | ||||
|  | ||||
|         const testExecute = await executeAst({ | ||||
|           ast: modifiedAst, | ||||
|           engineCommandManager, | ||||
|           // We make sure to send an empty program memory to denote we mean mock mode. | ||||
|           programMemoryOverride: ProgramMemory.empty(), | ||||
|         }) | ||||
|         if (testExecute.errors.length) { | ||||
|           toast.error(errorMessage) | ||||
|           return | ||||
|         } | ||||
|  | ||||
|         await kclManager.updateAst(modifiedAst, true) | ||||
|         await codeManager.updateEditorWithAstAndWriteToFile(modifiedAst) | ||||
|       })().catch(reportRejection) | ||||
|     }, | ||||
|     'AST fillet': ({ event }) => { | ||||
|       if (event.type !== 'Fillet') return | ||||
|       if (!event.data) return | ||||
| @ -1639,46 +1670,6 @@ export const modelingMachine = setup({ | ||||
|         } | ||||
|       } | ||||
|     ), | ||||
|     deleteSelectionAstMod: fromPromise( | ||||
|       async ({ | ||||
|         input, | ||||
|       }: { | ||||
|         input: ModelingCommandSchema['Delete selection'] | undefined | ||||
|       }) => { | ||||
|         console.log('input', input) | ||||
|         if (!input) { | ||||
|           return new Error('No input provided') | ||||
|         } | ||||
|  | ||||
|         // Extract inputs | ||||
|         const ast = kclManager.ast | ||||
|         const { selection } = input | ||||
|  | ||||
|         const modifiedAst = await deleteFromSelection( | ||||
|           ast, | ||||
|           selection.graphSelections[0], | ||||
|           kclManager.programMemory, | ||||
|           getFaceDetails | ||||
|         ) | ||||
|         if (err(modifiedAst)) { | ||||
|           return | ||||
|         } | ||||
|  | ||||
|         const testExecute = await executeAst({ | ||||
|           ast: modifiedAst, | ||||
|           engineCommandManager, | ||||
|           // We make sure to send an empty program memory to denote we mean mock mode. | ||||
|           programMemoryOverride: ProgramMemory.empty(), | ||||
|         }) | ||||
|         if (testExecute.errors.length) { | ||||
|           toast.error('Unable to delete part') | ||||
|           return | ||||
|         } | ||||
|  | ||||
|         await kclManager.updateAst(modifiedAst, true) | ||||
|         await codeManager.updateEditorWithAstAndWriteToFile(modifiedAst) | ||||
|       } | ||||
|     ), | ||||
|     'submit-prompt-edit': fromPromise( | ||||
|       async ({ input }: { input: ModelingCommandSchema['Prompt-to-edit'] }) => { | ||||
|         console.log('doing thing', input) | ||||
| @ -1774,8 +1765,9 @@ export const modelingMachine = setup({ | ||||
|         }, | ||||
|  | ||||
|         'Delete selection': { | ||||
|           target: 'Applying selection delete', | ||||
|           target: 'idle', | ||||
|           guard: 'has valid selection for deletion', | ||||
|           actions: ['AST delete selection'], | ||||
|           reenter: false, | ||||
|         }, | ||||
|  | ||||
| @ -2561,21 +2553,6 @@ export const modelingMachine = setup({ | ||||
|       }, | ||||
|     }, | ||||
|  | ||||
|     'Applying selection delete': { | ||||
|       invoke: { | ||||
|         src: 'deleteSelectionAstMod', | ||||
|         id: 'deleteSelectionAstMod', | ||||
|         input: ({ event, context }) => { | ||||
|           console.log('event', event) | ||||
|           if (event.type !== 'Delete selection') return undefined | ||||
|           if (!context.selectionRanges) return undefined | ||||
|           return { selection: context.selectionRanges } | ||||
|         }, | ||||
|         onDone: ['idle'], | ||||
|         onError: ['idle'], | ||||
|       }, | ||||
|     }, | ||||
|  | ||||
|     'Applying Prompt-to-edit': { | ||||
|       invoke: { | ||||
|         src: 'submit-prompt-edit', | ||||
|  | ||||
		Reference in New Issue
	
	Block a user