Migrate Text-to-CAD (edit) to multi-file endpoint (#6066)
* start of migrate to multi file endpoint * get some relative path stuff sorted * blobifying files, and making selections work with imports working * add write to disk * warn about big projects * update known circular * update snapshot * remove log * tweak selection filters * Update src/components/ModelingMachineProvider.tsx Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> * fmt * fix one thing * typo * raw dog form data like a fucking peasant * remove fake data * fmt * steal Kevin's stuff * good progress * clean up * fix writing to files when response returns * comment the terriable code * push fix of sorts * better fix * spot of clean up * fix: Needed to support the bad request flow, the toast will hang forever, the return control flows don't dismiss a forever toast * fix: handling more error flows by dismissing the toast * chore: leaving a comment for a confusing workflow * fix: trying to clean up some async logic * fix: trying to fix a few things at once... * fix: fixing toast success * fix: how did this desync? * fix: removing useless logic, we write to disk ahead of time, the continue is to say ya no problem * fix: typo * Change back to `spawnChild`, forego `actors` by reference * fix: updating PR comments * fix: found a bug with paths from rust! it is actually OS paths! * fix: updated type still is failing tsc * fix: the type of the machine was wrong, we always set it to at least '' * fix: idk man * Fix happy path test (button labels) --------- Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Co-authored-by: Kevin Nadro <kevin@zoo.dev> Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com> Co-authored-by: Kevin Nadro <nadr0@users.noreply.github.com> Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import type { Project } from '@src/lib/project'
|
||||
import type { ActorRefFrom } from 'xstate'
|
||||
import type { systemIOMachine } from '@src/machines/systemIO/systemIOMachine'
|
||||
|
||||
export enum SystemIOMachineActors {
|
||||
readFoldersFromProjectDirectory = 'read folders from project directory',
|
||||
@ -11,6 +13,8 @@ export enum SystemIOMachineActors {
|
||||
/** TODO: rename this event to be more generic, like `createKCLFileAndNavigate` */
|
||||
importFileFromURL = 'import file from URL',
|
||||
deleteKCLFile = 'delete kcl delete',
|
||||
bulkCreateKCLFiles = 'bulk create kcl files',
|
||||
bulkCreateKCLFilesAndNavigateToProject = 'bulk create kcl files and navigate to project',
|
||||
}
|
||||
|
||||
export enum SystemIOMachineStates {
|
||||
@ -25,6 +29,8 @@ export enum SystemIOMachineStates {
|
||||
/** TODO: rename this event to be more generic, like `createKCLFileAndNavigate` */
|
||||
importFileFromURL = 'importFileFromURL',
|
||||
deletingKCLFile = 'deletingKCLFile',
|
||||
bulkCreatingKCLFiles = 'bulkCreatingKCLFiles',
|
||||
bulkCreatingKCLFilesAndNavigateToProject = 'bulkCreatingKCLFilesAndNavigateToProject',
|
||||
}
|
||||
|
||||
const donePrefix = 'xstate.done.actor.'
|
||||
@ -48,6 +54,8 @@ export enum SystemIOMachineEvents {
|
||||
done_importFileFromURL = donePrefix + 'import file from URL',
|
||||
generateTextToCAD = 'generate text to CAD',
|
||||
deleteKCLFile = 'delete kcl file',
|
||||
bulkCreateKCLFiles = 'bulk create kcl files',
|
||||
bulkCreateKCLFilesAndNavigateToProject = 'bulk create kcl files and navigate to project',
|
||||
}
|
||||
|
||||
export enum SystemIOMachineActions {
|
||||
@ -89,3 +97,28 @@ export type SystemIOContext = {
|
||||
project: string
|
||||
}
|
||||
}
|
||||
|
||||
export type RequestedKCLFile = {
|
||||
requestedProjectName: string
|
||||
requestedFileName: string
|
||||
requestedCode: string
|
||||
}
|
||||
|
||||
export const waitForIdleState = async ({
|
||||
systemIOActor,
|
||||
}: { systemIOActor: ActorRefFrom<typeof systemIOMachine> }) => {
|
||||
// Check if already idle before setting up subscription
|
||||
if (systemIOActor.getSnapshot().matches(SystemIOMachineStates.idle)) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
const waitForIdlePromise = new Promise((resolve) => {
|
||||
const subscription = systemIOActor.subscribe((state) => {
|
||||
if (state.matches(SystemIOMachineStates.idle)) {
|
||||
subscription.unsubscribe()
|
||||
resolve(undefined)
|
||||
}
|
||||
})
|
||||
})
|
||||
return waitForIdlePromise
|
||||
}
|
||||
|
Reference in New Issue
Block a user