From 0cd6bed7f91a4bee7f79b4511a2c6914678e66db Mon Sep 17 00:00:00 2001 From: HugoCasa Date: Fri, 4 Jul 2025 13:19:42 +0200 Subject: [PATCH] fix: correctly set selected step editor code when reverting to snapshot (#6131) --- .../components/copilot/chat/flow/FlowAIChat.svelte | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte b/frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte index 0dd3bfa20b..5c54e31dcb 100644 --- a/frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte +++ b/frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte @@ -115,6 +115,19 @@ if (snapshot) { flowStore.val = snapshot refreshStateStore(flowStore) + + if ($currentEditor) { + const module = getModule($currentEditor.stepId, snapshot) + if (module) { + if ($currentEditor.type === 'script' && module.value.type === 'rawscript') { + $currentEditor.editor.setCode(module.value.content) + } else if ($currentEditor.type === 'iterator' && module.value.type === 'forloopflow') { + $currentEditor.editor.setCode( + module.value.iterator.type === 'javascript' ? module.value.iterator.expr : '' + ) + } + } + } } }, showModuleDiff(id: string) {