From dad130c5e6c615bac14d0e2b999bbcd9cc48811d Mon Sep 17 00:00:00 2001 From: James Gilbert Date: Fri, 27 Mar 2026 09:45:14 +0000 Subject: [PATCH 1/2] Disable RunPlanButton when worker is not idle --- apps/i15-1/src/components/RunPlanButton.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/i15-1/src/components/RunPlanButton.tsx b/apps/i15-1/src/components/RunPlanButton.tsx index 673a39d..74dd8d3 100644 --- a/apps/i15-1/src/components/RunPlanButton.tsx +++ b/apps/i15-1/src/components/RunPlanButton.tsx @@ -1,7 +1,11 @@ import { Button } from "@mui/material"; import { useState } from "react"; -import { useSetActiveTask, useSubmitTask } from "@atlas/blueapi-query"; +import { + useGetWorkerState, + useSetActiveTask, + useSubmitTask, +} from "@atlas/blueapi-query"; import type { TaskRequest } from "@atlas/blueapi"; type RunPlanButtonProps = { @@ -38,12 +42,19 @@ const RunPlanButton = ({ setLoading(false); }; + const isButtonDisabled = () => { + const workerState = useGetWorkerState(); + const disable = workerState.data !== "IDLE"; + return disable; + }; + return ( From 02b46796dfd18837eb5a95d5ed9f72cf038e9d54 Mon Sep 17 00:00:00 2001 From: James Gilbert Date: Fri, 27 Mar 2026 09:46:17 +0000 Subject: [PATCH 2/2] Mock running plans using in-memory worker state --- apps/i15-1/src/mocks/handlers.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/i15-1/src/mocks/handlers.ts b/apps/i15-1/src/mocks/handlers.ts index a2a3aa7..e2aa2b2 100644 --- a/apps/i15-1/src/mocks/handlers.ts +++ b/apps/i15-1/src/mocks/handlers.ts @@ -1,9 +1,11 @@ import { http, HttpResponse, graphql } from "msw"; const fakeTaskId = "7304e8e0-81c6-4978-9a9d-9046ab79ce3c"; +let workerStatus = { status: "IDLE", duration: 0 }; export const handlers = [ http.put("/api/worker/task", () => { + workerStatus.status = "RUNNING"; return HttpResponse.json({ task_id: fakeTaskId, }); @@ -18,4 +20,12 @@ export const handlers = [ http.put("/api/worker/state", () => { return HttpResponse.json("IDLE"); }), + + http.get("/api/worker/state", () => { + if (workerStatus.duration >= 10) { + workerStatus.status = "IDLE"; + workerStatus.duration = 0; + } else workerStatus.duration++; + return HttpResponse.json(workerStatus.status); + }), ];