diff --git a/frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte b/frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte index 7aade584f9..c81665cf60 100644 --- a/frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte +++ b/frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte @@ -99,8 +99,10 @@ } }, rejectAllModuleActions() { - for (const id of Object.keys(affectedModules)) { - this.revertModuleAction(id) + // Do it in reverse to revert nested modules first then parents + const ids = Object.keys(affectedModules) + for (let i = ids.length - 1; i >= 0; i--) { + this.revertModuleAction(ids[i]) } affectedModules = {} },