Fixed status updates

This commit is contained in:
Umar Adilov 2026-01-12 19:22:25 +05:00
parent 853c434d75
commit 369b201cfa
2 changed files with 14 additions and 5 deletions

View File

@ -4,6 +4,14 @@ import { Axios } from "axios";
import { promises as fs } from "fs"; import { promises as fs } from "fs";
import { z } from "zod"; import { z } from "zod";
export enum AppStatus {
PENDING_PROVISION = "PENDING_PROVISION",
PROVISIONING = "PROVISIONING",
RUNNING = "RUNNING",
FAILED = "FAILED",
TERMINATED = "TERMINATED",
}
const { vmOrchestrationStatusUpdateUrl } = z const { vmOrchestrationStatusUpdateUrl } = z
.object({ .object({
vmOrchestrationStatusUpdateUrl: z.string(), vmOrchestrationStatusUpdateUrl: z.string(),
@ -17,7 +25,7 @@ const axios = new Axios({
baseURL: vmOrchestrationStatusUpdateUrl, baseURL: vmOrchestrationStatusUpdateUrl,
}); });
const updateAppStatus = async (status: "Errored" | "Active" | "Pending") => { const updateAppStatus = async (status: AppStatus) => {
await axios.put( await axios.put(
"/", "/",
JSON.stringify({ JSON.stringify({
@ -55,7 +63,7 @@ export const BuildPlugin: Plugin = async ({ client, $ }) => {
console.log({ isAnyChange }); console.log({ isAnyChange });
if (!isAnyChange || isAbortionError) { if (!isAnyChange || isAbortionError) {
await updateAppStatus("Active"); await updateAppStatus(AppStatus.RUNNING);
return; return;
} }
@ -72,7 +80,7 @@ export const BuildPlugin: Plugin = async ({ client, $ }) => {
} }
if (sessionRetries[event.properties.info.sessionID] > 3) { if (sessionRetries[event.properties.info.sessionID] > 3) {
await updateAppStatus("Errored"); await updateAppStatus(AppStatus.FAILED);
return; return;
} }
@ -147,11 +155,11 @@ export const BuildPlugin: Plugin = async ({ client, $ }) => {
console.error("Failed to push to git", error); console.error("Failed to push to git", error);
} }
await updateAppStatus("Active"); await updateAppStatus(AppStatus.RUNNING);
}, },
"chat.message": async () => { "chat.message": async () => {
await updateAppStatus("Pending"); await updateAppStatus(AppStatus.PROVISIONING);
}, },
}; };
}; };

View File

@ -74,6 +74,7 @@ export default defineConfig({
host: true, host: true,
port: 5173, port: 5173,
hmr: { hmr: {
host: "",
protocol: "wss", protocol: "wss",
clientPort: 443, clientPort: 443,
path: "/__vite_hmr", path: "/__vite_hmr",