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 sync before export (#6380)

zxhlyh984658f5e989
diff --git a/web/app/components/workflow/hooks/use-workflow-interactions.ts b/web/app/components/workflow/hooks/use-workflow-interactions.ts
index 109771dc87d..88299af712b 100644
--- a/web/app/components/workflow/hooks/use-workflow-interactions.ts
+++ b/web/app/components/workflow/hooks/use-workflow-interactions.ts
@@ -1,4 +1,7 @@
-import { useCallback } from 'react'
+import {
+ useCallback,
+ useState,
+} from 'react'
import { useTranslation } from 'react-i18next'
import { useReactFlow } from 'reactflow'
import { useWorkflowStore } from '../store'
@@ -10,6 +13,7 @@ import {
} from '../utils'
import { useEdgesInteractions } from './use-edges-interactions'
import { useNodesInteractions } from './use-nodes-interactions'
+import { useNodesSyncDraft } from './use-nodes-sync-draft'
import { useEventEmitterContextContext } from '@/context/event-emitter'
import { fetchWorkflowDraft } from '@/service/workflow'
import { exportAppConfig } from '@/service/apps'
@@ -79,12 +83,21 @@ export const useWorkflowUpdate = () => {
export const useDSL = () => {
const { t } = useTranslation()
const { notify } = useToastContext()
+ const [exporting, setExporting] = useState(false)
+ const { doSyncWorkflowDraft } = useNodesSyncDraft()
+
const appDetail = useAppStore(s => s.appDetail)
const handleExportDSL = useCallback(async () => {
if (!appDetail)
return
+
+ if (exporting)
+ return
+
try {
+ setExporting(true)
+ await doSyncWorkflowDraft()
const { data } = await exportAppConfig(appDetail.id)
const a = document.createElement('a')
const file = new Blob([data], { type: 'application/yaml' })
@@ -95,7 +108,10 @@ export const useDSL = () => {
catch (e) {
notify({ type: 'error', message: t('app.exportFailed') })
}
- }, [appDetail, notify, t])
+ finally {
+ setExporting(false)
+ }
+ }, [appDetail, notify, t, doSyncWorkflowDraft, exporting])
return {
handleExportDSL,