Skip to content

i15-1: display basic feedback from blueapi - #44

Merged
noemifrisina merged 54 commits into
mainfrom
1539-i15_1-blueapi_feedback
Jul 28, 2026
Merged

i15-1: display basic feedback from blueapi#44
noemifrisina merged 54 commits into
mainfrom
1539-i15_1-blueapi_feedback

Conversation

@noemifrisina

Copy link
Copy Markdown
Collaborator

@jacob720
jacob720 marked this pull request as ready for review June 10, 2026 09:11

@DominicOram DominicOram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, some comments in code, additionally:

  • I can quite easily trigger multiple plans at once by just hitting the button twice. This is probably because of the fact we have to do two calls to BlueAPI to run the plan and we only disable the button on the second call. This should be fixed when BlueAPI moves away from the two calls in DiamondLightSource/blueapi#1326 but can we have an issue that acknowledges this?
  • We should move Abort and WorkerState into blueapi-query as they seem common. Also update the docs in there so that people know it's available

Comment thread apps/i15-1/src/routes/Robot.tsx
Comment thread packages/blueapi-ui/src/RunPlanButton.tsx Outdated
return new Promise((res) => setTimeout(res, ms));
};

const runTask = async (task_id: string) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: Can we have some tests on the logic in this?

await startTask.mutateAsync(task_id).then(async (response) => {
if (response) {
let status = workerState.data;
while (status !== "IDLE" && status !== "ABORTING") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could: Can we pull these into constants somewhere?

};
setLoading(true);
await submitAndRunTask(taskRequest);
await submitAndRunTask(taskRequest).catch((error) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: Can we have a test on this

@DominicOram DominicOram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, some more comments in code, I think there may have been a bad merge? Also, I still stand by wanting unit tests on some of the logic...

Comment thread apps/i15-1/src/routes/Robot.tsx Outdated
const theme = useTheme();
return (
<Box sx={{ ml: 5 }}>
<Stack direction={"column"} spacing={2}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must: I think this is a duplicate of the existing card. Maybe a bad merge?

Comment thread apps/i15-1/src/routes/Robot.tsx Outdated
import { ReadOnlyPv } from "@atlas/pvws-config";
import { StatusCard } from "../components/StatusCard";
import { BlueapiWorkerState } from "../components/BlueapiWorkerState";
// import { AbortPlanButton } from "../components/AbortPlanButton";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must: This is no longer used? I think we want it here, right?

@noemifrisina

Copy link
Copy Markdown
Collaborator Author

Added a few tests but after looking at some documentation, it seems that in order to be able to test the logic I would need to get those functions out of the component (can't test functions nested inside). Tbh, I would rather do that in a separate PR and get this functionality merged...

@EmsArnold EmsArnold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment in code, and then a further general comment:
If we're moving forward with the logic as is, and re-factoring the logic outside the component in the (near) future, it would be good to create an issue detailing the necessary work now and leave the new issue linked in a relevant location.

setMsg(
`Failed to run plan ${name}, see console and blueapi logs for full error.`,
);
console.log(`${msg}.\n Reason: ${error}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the first time a task fails, the snackbar shows the correct message:

Failed to run plan robot_load, see console and blueapi logs for full error.

However, the console message shows the default message:

Running robot_load plan.
 Reason: AxiosError: Request failed with status code 404

I imagine this is something that may also be fixed by refactoring the logic outside the component?

@noemifrisina noemifrisina Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, I hadn't noticed it. Tbh, not so sure just refactoring the logic out will fix this - not on its own at least. At least the error is the correct one (the latest), but it's still taking the old message. I have seen it in the past where the new message doesn't show up right away after the set in the same function, but can't remember what the fix was so will have to go look

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, after a quick read, I remember now. Long story short, not only is useState asynchronous, but the current state of msg actually would not change till next re-render. In general there's a few solutions to this if needed, but in this case since we just want the error messages to match I would simply update the log to not use msg directly...

@noemifrisina
noemifrisina requested a review from EmsArnold July 28, 2026 12:24
@EmsArnold

Copy link
Copy Markdown
Contributor

Coverage seems to be failing with an error:
TestingLibraryElementError: Unable to find an element by: [data-testid="Plan succeeded"]

  ❯ src/RunPlanButton.test.tsx:104:19
    102|     screen.getByText("Run").click();
    103|     expect(screen.findByTestId("Plan submission successful!"));
    104|     expect(screen.findByTestId("Plan succeeded"));
       |                   ^
    105|   });
    106| 

This likely originated from a mistake in my original RunPlanButton, but curious that CI is passing... Should these screen.findByTestId be screen.findByText?

@noemifrisina

Copy link
Copy Markdown
Collaborator Author

I actually changed them to findByTestId because findByText was failing... Checking a couple of things, I'm starting to think this test is flaky (it was passing then not, then passing again, with no changes)

@EmsArnold EmsArnold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but we should keep an eye on the suspected flaky test in the future.

@noemifrisina
noemifrisina dismissed DominicOram’s stale review July 28, 2026 17:01

Comments addressed

@noemifrisina
noemifrisina merged commit 108ef05 into main Jul 28, 2026
1 of 2 checks passed
@noemifrisina
noemifrisina deleted the 1539-i15_1-blueapi_feedback branch July 28, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants