diff --git a/src/routes/devpod.ts b/src/routes/devpod.ts index b75a161..3f09bbf 100644 --- a/src/routes/devpod.ts +++ b/src/routes/devpod.ts @@ -29,11 +29,14 @@ export async function devpodRoutes(app: FastifyInstance) { })); // Determine overall state + const hasRunningPods = pods.some((p: any) => p.ready); + const hasFailedPods = pods.some((p: any) => p.status === "Failed"); let state: "stopped" | "running" | "starting" | "error"; - if (replicas === 0) state = "stopped"; - else if (readyReplicas > 0 && pods.some((p: any) => p.ready)) state = "running"; - else if (pods.some((p: any) => p.status === "Failed")) state = "error"; - else state = "starting"; + if (hasRunningPods) state = "running"; + else if (hasFailedPods) state = "error"; + else if (replicas === 0 && pods.length === 0) state = "stopped"; + else if (pods.length > 0) state = "starting"; + else state = "stopped"; return reply.send({ state, replicas, readyReplicas, image, pods }); });