Revert the migration to promise actor
This commit is contained in:
@ -40,9 +40,6 @@ export type ModelingCommandSchema = {
|
|||||||
Loft: {
|
Loft: {
|
||||||
selection: Selections
|
selection: Selections
|
||||||
}
|
}
|
||||||
'Delete selection': {
|
|
||||||
selection: Selections
|
|
||||||
}
|
|
||||||
Shell: {
|
Shell: {
|
||||||
selection: Selections
|
selection: Selections
|
||||||
thickness: KclCommandValue
|
thickness: KclCommandValue
|
||||||
|
|||||||
@ -237,7 +237,6 @@ export type ModelingMachineEvent =
|
|||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'Delete selection'
|
type: 'Delete selection'
|
||||||
data?: ModelingCommandSchema['Delete selection']
|
|
||||||
}
|
}
|
||||||
| { type: 'Sketch no face' }
|
| { type: 'Sketch no face' }
|
||||||
| { type: 'Toggle gui mode' }
|
| { type: 'Toggle gui mode' }
|
||||||
@ -732,6 +731,38 @@ export const modelingMachine = setup({
|
|||||||
}
|
}
|
||||||
})().catch(reportRejection)
|
})().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 }) => {
|
'AST fillet': ({ event }) => {
|
||||||
if (event.type !== 'Fillet') return
|
if (event.type !== 'Fillet') return
|
||||||
if (!event.data) 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(
|
'submit-prompt-edit': fromPromise(
|
||||||
async ({ input }: { input: ModelingCommandSchema['Prompt-to-edit'] }) => {
|
async ({ input }: { input: ModelingCommandSchema['Prompt-to-edit'] }) => {
|
||||||
console.log('doing thing', input)
|
console.log('doing thing', input)
|
||||||
@ -1774,8 +1765,9 @@ export const modelingMachine = setup({
|
|||||||
},
|
},
|
||||||
|
|
||||||
'Delete selection': {
|
'Delete selection': {
|
||||||
target: 'Applying selection delete',
|
target: 'idle',
|
||||||
guard: 'has valid selection for deletion',
|
guard: 'has valid selection for deletion',
|
||||||
|
actions: ['AST delete selection'],
|
||||||
reenter: false,
|
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': {
|
'Applying Prompt-to-edit': {
|
||||||
invoke: {
|
invoke: {
|
||||||
src: 'submit-prompt-edit',
|
src: 'submit-prompt-edit',
|
||||||
|
|||||||
Reference in New Issue
Block a user