diff --git a/wasp-ai/main.wasp b/wasp-ai/main.wasp index 1229e6136..bf399d85b 100644 --- a/wasp-ai/main.wasp +++ b/wasp-ai/main.wasp @@ -49,6 +49,7 @@ entity Project {=psl name String description String createdAt DateTime @default(now()) + status String @default("in-progress") files File[] logs Log[] psl=} diff --git a/wasp-ai/migrations/20230629140423_add_status/migration.sql b/wasp-ai/migrations/20230629140423_add_status/migration.sql new file mode 100644 index 000000000..5081ff926 --- /dev/null +++ b/wasp-ai/migrations/20230629140423_add_status/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Project" ADD COLUMN "status" TEXT NOT NULL DEFAULT 'in-progress'; diff --git a/wasp-ai/src/client/pages/ResultPage.jsx b/wasp-ai/src/client/pages/ResultPage.jsx index 08aa4e0e6..760c1b193 100644 --- a/wasp-ai/src/client/pages/ResultPage.jsx +++ b/wasp-ai/src/client/pages/ResultPage.jsx @@ -30,14 +30,14 @@ export const ResultPage = () => { useEffect(() => { if ( - appGenerationResult?.status === "success" || - appGenerationResult?.status === "failure" + appGenerationResult?.project?.status === "success" || + appGenerationResult?.project?.status === "failure" ) { setGenerationDone(true); setCurrentStatus({ - status: appGenerationResult.status === "success" ? "success" : "error", + status: appGenerationResult.project.status === "success" ? "success" : "error", message: - appGenerationResult.status === "success" + appGenerationResult.project.status === "success" ? "Finished" : "There was an error", }); diff --git a/wasp-ai/src/server/operations.ts b/wasp-ai/src/server/operations.ts index cc65c9208..c8fd295aa 100644 --- a/wasp-ai/src/server/operations.ts +++ b/wasp-ai/src/server/operations.ts @@ -35,7 +35,6 @@ export const startGeneratingNewApp: StartGeneratingNewApp< const appId = project.id; appGenerationResults[appId] = { - status: "in-progress", unconsumedStdout: "", }; @@ -132,17 +131,26 @@ export const startGeneratingNewApp: StartGeneratingNewApp< console.error(data.toString()); }); - waspCliProcess.on("close", (code) => { + waspCliProcess.on("close", async (code) => { if (code === 0) { - appGenerationResults[appId].status = "success"; + await Project.update({ + where: { id: appId }, + data: { status: "success" }, + }); } else { - appGenerationResults[appId].status = "failure"; + await Project.update({ + where: { id: appId }, + data: { status: "failure" }, + }); } }); - waspCliProcess.on("error", (err) => { + waspCliProcess.on("error", async (err) => { console.error("WASP CLI PROCESS ERROR", err); - appGenerationResults[appId].status = "failure"; + await Project.update({ + where: { id: appId }, + data: { status: "failure" }, + }); }); return appId; @@ -164,7 +172,6 @@ export const getAppGenerationResult = (async (args, context) => { }, }); return { - status: appGenerationResults[appId]?.status ?? "success", project, }; } catch (e) {