From 53fb8b3ae0eb0f98a215e351400b12de29b3eaa5 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 5 Apr 2026 00:31:22 +0000 Subject: [PATCH] fix: dev pod state logic should prioritize actual pod status over replica spec Co-Authored-By: Claude Opus 4.6 (1M context) --- src/routes/devpod.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 }); });