Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: workflow import sync env and conversation variables (#21215)

zxhlyhcff039d12323
diff --git a/web/app/components/workflow-app/components/workflow-main.tsx b/web/app/components/workflow-app/components/workflow-main.tsx
index 2f2295cb59e..6be190c897b 100644
--- a/web/app/components/workflow-app/components/workflow-main.tsx
+++ b/web/app/components/workflow-app/components/workflow-main.tsx
@@ -12,6 +12,7 @@ import {
useWorkflowRun,
useWorkflowStartRun,
} from '../hooks'
+import { useWorkflowStore } from '@/app/components/workflow/store'
type WorkflowMainProps = Pick<WorkflowProps, 'nodes' | 'edges' | 'viewport'>
const WorkflowMain = ({
@@ -20,14 +21,28 @@ const WorkflowMain = ({
viewport,
}: WorkflowMainProps) => {
const featuresStore = useFeaturesStore()
+ const workflowStore = useWorkflowStore()
const handleWorkflowDataUpdate = useCallback((payload: any) => {
- if (payload.features && featuresStore) {
+ const {
+ features,
+ conversation_variables,
+ environment_variables,
+ } = payload
+ if (features && featuresStore) {
const { setFeatures } = featuresStore.getState()
- setFeatures(payload.features)
+ setFeatures(features)
}
- }, [featuresStore])
+ if (conversation_variables) {
+ const { setConversationVariables } = workflowStore.getState()
+ setConversationVariables(conversation_variables)
+ }
+ if (environment_variables) {
+ const { setEnvironmentVariables } = workflowStore.getState()
+ setEnvironmentVariables(environment_variables)
+ }
+ }, [featuresStore, workflowStore])
const {
doSyncWorkflowDraft,
diff --git a/web/app/components/workflow/update-dsl-modal.tsx b/web/app/components/workflow/update-dsl-modal.tsx
index b789e3b2fd4..00c36cce909 100644
--- a/web/app/components/workflow/update-dsl-modal.tsx
+++ b/web/app/components/workflow/update-dsl-modal.tsx
@@ -86,6 +86,8 @@ const UpdateDSLModal = ({
graph,
features,
hash,
+ conversation_variables,
+ environment_variables,
} = await fetchWorkflowDraft(`/apps/${app_id}/workflows/draft`)
const { nodes, edges, viewport } = graph
@@ -122,6 +124,8 @@ const UpdateDSLModal = ({
viewport,
features: newFeatures,
hash,
+ conversation_variables: conversation_variables || [],
+ environment_variables: environment_variables || [],
},
} as any)
}, [eventEmitter])