Fix command execution race condition in Agentic Chat
What does this MR do and why?
It fixes a race condition that happens when Duo Agentic Chat attempts to execute an external command (e.g. Troubleshoot pipeline) and it is also trying to load an existing workflow that the user is currently working on. When executing commands by adding them to the duoChatGlobalState.commands array, the duo_agentic_chat.vue component cleans up existing state before executing the command but it doesn't abort loading operations. This state mismatch causes a race condition because the state cleanup removes the existing workflowID but the loading operation is still happening.
This MR fixes this problem by ensuring that Duo Agentic Chat only executes commands when loading operations complete. This "serial" mode helps us avoid conflicts between multiple loading operations.
References
Related to Investigate `$workflowId error` showing up in t... (#571445 - closed)
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
Setting up Duo Agentic Chat and having a failing CI pipeline are prerequisites to test this Merge Request locally.
- Open a failing job in your local environment, for example https://gdk.test:3443/gitlab-org/blank-project-18.4/-/jobs/373.
- Close the agentic chat panel if it is opened.
- Click the "Troubleshoot" button that is located at the bottom of the job page.
- The agentic chat panel will open, clean up existing workflow, and send the command to troubleshoot the current pipeline.
- After this fix, there won't be a "loading workflow with invalid ID" error because the workflow ID is only removed after the Duo Agentic Chat completes the initial load.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.