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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(workflow): confirm before saving an empty canvas (#43668)
Joelc497e930a6bd
diff --git a/api/controllers/console/app/workflow.py b/api/controllers/console/app/workflow.pyindex 96d6564c2c0..0b0c5860c78 100644--- a/api/controllers/console/app/workflow.py+++ b/api/controllers/console/app/workflow.py@@ -152,6 +152,7 @@ class SyncDraftWorkflowPayload(BaseModel):graph: dict[str, Any]features: dict[str, Any]hash: str | None = None+ force: bool = Field(default=False, strict=True, description="Explicitly confirm saving an empty workflow graph.")is_collaborative: bool = Field(default=False, alias="_is_collaborative")environment_variable_patch: SyncEnvironmentVariablePatchPayload | None = Noneconversation_variables: list[dict[str, Any]] = Field(@@ -654,6 +655,12 @@ class DraftWorkflowApi(Resource):return {"message": "Invalid JSON data"}, 400else:abort(415)++ # Empty autosaves can otherwise replace a populated draft, even with a matching hash.+ # Require explicit confirmation for both regular saves and text/plain unload beacons.+ if args_model.graph.get("nodes") == [] and args_model.graph.get("edges") == [] and not args_model.force:+ raise InvalidArgumentError(description="Saving an empty workflow requires force=true.")+workflow_service = WorkflowService()try:diff --git a/api/openapi/markdown/console-openapi.md b/api/openapi/markdown/console-openapi.mdindex fccbe4041cd..f2cabb5ce3f 100644--- a/api/openapi/markdown/console-openapi.md+++ b/api/openapi/markdown/console-openapi.md@@ -24118,6 +24118,7 @@ The subscription constructor of the trigger provider| conversation_variables | [ object ] | | No || environment_variable_patch | [SyncEnvironmentVariablePatchPayload](#syncenvironmentvariablepatchpayload) | | No || features | object | | Yes |+| force | boolean | Explicitly confirm saving an empty workflow graph. | No || graph | object | | Yes || hash | string | | No |diff --git a/api/tests/unit_tests/controllers/console/app/test_workflow.py b/api/tests/unit_tests/controllers/console/app/test_workflow.pyindex 7c454dd1cf1..b17728697cc 100644--- a/api/tests/unit_tests/controllers/console/app/test_workflow.py+++ b/api/tests/unit_tests/controllers/console/app/test_workflow.py@@ -350,6 +350,134 @@ def test_sync_draft_workflow_success(app: Flask, monkeypatch: pytest.MonkeyPatchassert sync_draft_workflow.call_args.kwargs["preserve_environment_variables"] is True[email protected]("content_type", ["application/json", "text/plain"])[email protected]("confirmation", [{}, {"force": False}], ids=["missing-force", "force-false"])+def test_sync_draft_workflow_rejects_empty_graph_without_confirmation(+ app: Flask,+ monkeypatch: pytest.MonkeyPatch,+ content_type: str,+ confirmation: dict[str, bool],+) -> None:+ workflow_service = Mock()+ monkeypatch.setattr(workflow_module, "WorkflowService", workflow_service)+ api = workflow_module.DraftWorkflowApi()+ handler = inspect.unwrap(api.post)++ with app.test_request_context(+ "/apps/app/workflows/draft",+ method="POST",+ data=json.dumps({"graph": {"nodes": [], "edges": []}, "features": {}, "hash": "h", **confirmation}),+ content_type=content_type,+ ):+ with pytest.raises(InvalidArgumentError) as exc:+ handler(api, _account(), app_model=_app())++ assert exc.value.code == 400+ assert exc.value.description == "Saving an empty workflow requires force=true."+ workflow_service.assert_not_called()++[email protected]("content_type", ["application/json", "text/plain"])+ ("graph", "confirmation"),+ [+ ({"nodes": [], "edges": []}, {"force": True}),+ ({"nodes": [{"id": "start"}], "edges": []}, {}),+ ({"nodes": [], "edges": [{"id": "edge-1", "source": "start", "target": "end"}]}, {}),+ ],+ ids=["confirmed-empty-graph", "nodes-without-edges", "edges-without-nodes"],+)+def test_sync_draft_workflow_saves_confirmed_empty_or_nonempty_graph(+ app: Flask,+ monkeypatch: pytest.MonkeyPatch,+ content_type: str,+ graph: dict[str, list[dict[str, str]]],+ confirmation: dict[str, bool],+) -> None:+ workflow = SimpleNamespace(unique_hash="next-hash", updated_at=None, created_at=datetime(2024, 1, 1))+ sync_draft_workflow = Mock(return_value=workflow)+ monkeypatch.setattr(+ workflow_module,+ "WorkflowService",+ lambda: SimpleNamespace(sync_draft_workflow=sync_draft_workflow),+ )+ api = workflow_module.DraftWorkflowApi()+ handler = inspect.unwrap(api.post)++ with app.test_request_context(+ "/apps/app/workflows/draft",+ method="POST",+ data=json.dumps({"graph": graph, "features": {}, "hash": "current-hash", **confirmation}),+ content_type=content_type,+ ):+ response = handler(api, _account(), app_model=_app())++ assert response["result"] == "success"+ assert response["hash"] == "next-hash"+ sync_draft_workflow.assert_called_once()+ assert sync_draft_workflow.call_args.kwargs["graph"] == graph+ assert sync_draft_workflow.call_args.kwargs["unique_hash"] == "current-hash"++[email protected]("content_type", ["application/json", "text/plain"])+def test_sync_draft_workflow_force_does_not_bypass_hash_conflict(+ app: Flask,+ monkeypatch: pytest.MonkeyPatch,+ content_type: str,+) -> None:+ sync_draft_workflow = Mock(side_effect=workflow_module.WorkflowHashNotEqualError())+ monkeypatch.setattr(+ workflow_module,+ "WorkflowService",+ lambda: SimpleNamespace(sync_draft_workflow=sync_draft_workflow),+ )+ api = workflow_module.DraftWorkflowApi()+ handler = inspect.unwrap(api.post)++ with app.test_request_context(+ "/apps/app/workflows/draft",+ method="POST",+ data=json.dumps({"graph": {"nodes": [], "edges": []}, "features": {}, "hash": "stale-hash", "force": True}),+ content_type=content_type,+ ):+ with pytest.raises(DraftWorkflowNotSync) as exc:+ handler(api, _account(), app_model=_app())++ assert exc.value.code == 409+ sync_draft_workflow.assert_called_once()+ assert sync_draft_workflow.call_args.kwargs["unique_hash"] == "stale-hash"++[email protected]("content_type", ["application/json", "text/plain"])[email protected]("force", ["true", 1, None], ids=["string", "integer", "null"])+def test_sync_draft_workflow_rejects_non_boolean_force(+ app: Flask,+ monkeypatch: pytest.MonkeyPatch,+ content_type: str,+ force: str | int | None,+) -> None:+ workflow_service = Mock()+ monkeypatch.setattr(workflow_module, "WorkflowService", workflow_service)+ api = workflow_module.DraftWorkflowApi()+ handler = inspect.unwrap(api.post)++ with app.test_request_context(+ "/apps/app/workflows/draft",+ method="POST",+ data=json.dumps({"graph": {"nodes": [], "edges": []}, "features": {}, "force": force}),+ content_type=content_type,+ ):+ if content_type == "application/json":+ with pytest.raises(ValidationError, match="Input should be a valid boolean"):+ handler(api, _account(), app_model=_app())+ else:+ response, status = handler(api, _account(), app_model=_app())+ assert status == 400+ assert response["message"] == "Invalid JSON data"++ workflow_service.assert_not_called()++def test_sync_draft_workflow_passes_environment_patch(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:workflow = _make_workflow(updated_at=None, created_at=datetime(2024, 1, 1))patched_variable = StringVariable(@@ -428,7 +556,6 @@ def test_sync_draft_workflow_rejects_legacy_environment_variables() -> None:def test_sync_draft_workflow_hash_mismatch(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:-def _raise(*_args, **_kwargs):raise workflow_module.WorkflowHashNotEqualError()diff --git a/packages/contracts/generated/api/console/apps/types.gen.ts b/packages/contracts/generated/api/console/apps/types.gen.tsindex 1f9feafdbc3..5fe09deb28b 100644--- a/packages/contracts/generated/api/console/apps/types.gen.ts+++ b/packages/contracts/generated/api/console/apps/types.gen.ts@@ -921,6 +921,7 @@ export type SyncDraftWorkflowPayload = {features: {[key: string]: unknown}+ force?: booleangraph: {[key: string]: unknown}diff --git a/packages/contracts/generated/api/console/apps/zod.gen.ts b/packages/contracts/generated/api/console/apps/zod.gen.tsindex 2604ecfa468..3c54f3e3313 100644--- a/packages/contracts/generated/api/console/apps/zod.gen.ts+++ b/packages/contracts/generated/api/console/apps/zod.gen.ts@@ -1741,6 +1741,7 @@ export const zSyncDraftWorkflowPayload = z.object({conversation_variables: z.array(z.record(z.string(), z.unknown())).optional(),environment_variable_patch: zSyncEnvironmentVariablePatchPayload.nullish(),features: z.record(z.string(), z.unknown()),+ force: z.boolean().optional().default(false),graph: z.record(z.string(), z.unknown()),hash: z.string().nullish(),})diff --git a/web/app/components/workflow-app/hooks/__tests__/use-nodes-sync-draft.spec.ts b/web/app/components/workflow-app/hooks/__tests__/use-nodes-sync-draft.spec.tsindex 91cc23437bc..fd4d78a6606 100644--- a/web/app/components/workflow-app/hooks/__tests__/use-nodes-sync-draft.spec.ts+++ b/web/app/components/workflow-app/hooks/__tests__/use-nodes-sync-draft.spec.ts@@ -1,3 +1,4 @@+import type { WorkflowSliceShape } from '@/app/components/workflow/store/workflow/workflow-slice'import type { EnvironmentVariablePatch } from '@/service/workflow'import { act } from '@testing-library/react'import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'@@ -17,6 +18,7 @@ const mockCollaborationRequestWorkflowSync = vi.fn()const mockCollaborationCanPersistLocalGraph = vi.fn()const mockCollaborationCanFlushGraphOnPageClose = vi.fn()const mockCollaborationCanUseLocalDraftFallback = vi.fn()+const mockSetShowConfirm = vi.fn<(confirmation: WorkflowSliceShape['showConfirm']) => void>()let isCollaborationEnabled = falselet reactFlowState: {@@ -32,6 +34,8 @@ let workflowStoreState: {conversationVariables: Array<Record<string, unknown>>setSyncWorkflowDraftHash: typeof mockSetSyncWorkflowDraftHashsetDraftUpdatedAt: typeof mockSetDraftUpdatedAt+ showConfirm: WorkflowSliceShape['showConfirm']+ setShowConfirm: typeof mockSetShowConfirm}let featuresState: {@@ -106,9 +110,12 @@ const renderUseNodesSyncDraft = () =>systemFeatures: { enable_collaboration_mode: isCollaborationEnabled },})-describe('useNodesSyncDraft — handleRefreshWorkflowDraft(true) on 409', () => {+describe('useNodesSyncDraft', () => {beforeEach(() => {vi.clearAllMocks()+ mockSetShowConfirm.mockImplementation((confirmation) => {+ workflowStoreState.showConfirm = confirmation+ })reactFlowState = {getNodes: mockGetNodes,edges: [],@@ -121,6 +128,8 @@ describe('useNodesSyncDraft — handleRefreshWorkflowDraft(true) on 409', () =>conversationVariables: [],setSyncWorkflowDraftHash: mockSetSyncWorkflowDraftHash,setDraftUpdatedAt: mockSetDraftUpdatedAt,+ showConfirm: undefined,+ setShowConfirm: mockSetShowConfirm,}featuresState = {features: {@@ -150,6 +159,318 @@ describe('useNodesSyncDraft — handleRefreshWorkflowDraft(true) on 409', () =>isCollaborationEnabled = false})+ it('should wait for confirmation before saving an empty graph with force', async () => {+ mockGetNodes.mockReturnValue([])+ const callbacks = {+ onSuccess: vi.fn(),+ onError: vi.fn(),+ onSettled: vi.fn(),+ }+ const { result } = renderUseNodesSyncDraft()+ let syncPromise!: ReturnType<typeof result.current.doSyncWorkflowDraft>++ act(() => {+ syncPromise = result.current.doSyncWorkflowDraft(false, callbacks)+ })++ expect(workflowStoreState.showConfirm).toEqual(+ expect.objectContaining({+ title: 'workflow.common.clearCanvasConfirmTitle',+ desc: 'workflow.common.clearCanvasConfirmDescription',+ }),+ )+ expect(mockSyncWorkflowDraft).not.toHaveBeenCalled()+ expect(callbacks.onSettled).not.toHaveBeenCalled()++ await act(async () => {+ workflowStoreState.showConfirm?.onConfirm()+ await expect(syncPromise).resolves.toEqual({ hash: 'new', updatedAt: 1 })+ })++ expect(workflowStoreState.showConfirm).toBeUndefined()+ expect(mockSyncWorkflowDraft).toHaveBeenCalledOnce()+ expect(mockSyncWorkflowDraft).toHaveBeenCalledWith(+ expect.objectContaining({+ params: expect.objectContaining({+ graph: expect.objectContaining({ nodes: [], edges: [] }),+ force: true,+ }),+ }),+ )+ expect(callbacks.onSuccess).toHaveBeenCalledOnce()+ expect(callbacks.onError).not.toHaveBeenCalled()+ expect(callbacks.onSettled).toHaveBeenCalledOnce()+ })++ it('should settle a canceled empty save without posting or reporting an error', async () => {+ mockGetNodes.mockReturnValue([])+ const callbacks = {+ onSuccess: vi.fn(),+ onError: vi.fn(),+ onSettled: vi.fn(),+ }+ const { result } = renderUseNodesSyncDraft()+ let syncPromise!: ReturnType<typeof result.current.doSyncWorkflowDraft>++ act(() => {+ syncPromise = result.current.doSyncWorkflowDraft(false, callbacks)+ })++ expect(workflowStoreState.showConfirm?.onCancel).toBeDefined()+ await act(async () => {+ workflowStoreState.showConfirm?.onCancel?.()+ await expect(syncPromise).resolves.toBeNull()+ })++ expect(workflowStoreState.showConfirm).toBeUndefined()+ expect(mockSyncWorkflowDraft).not.toHaveBeenCalled()+ expect(callbacks.onSuccess).not.toHaveBeenCalled()+ expect(callbacks.onError).not.toHaveBeenCalled()+ expect(callbacks.onSettled).toHaveBeenCalledOnce()+ })++ it('should save a nonempty graph without confirmation or force', async () => {+ const { result } = renderUseNodesSyncDraft()++ await act(async () => {+ await result.current.doSyncWorkflowDraft()+ })++ expect(mockSetShowConfirm).not.toHaveBeenCalled()+ expect(mockSyncWorkflowDraft).toHaveBeenCalledWith(+ expect.objectContaining({+ params: expect.not.objectContaining({ force: expect.anything() }),+ }),+ )+ })++ it('should confirm a graph that is empty after filtering placeholders and temporary entities', async () => {+ mockGetNodes.mockReturnValue([+ {+ id: 'start-placeholder',+ position: { x: 0, y: 0 },+ data: { type: BlockEnum.StartPlaceholder },+ },+ {+ id: 'temp-node',+ position: { x: 1, y: 1 },+ data: { type: BlockEnum.Answer, _isTempNode: true },+ },+ ])+ reactFlowState.edges = [+ {+ id: 'temp-edge',+ source: 'start-placeholder',+ target: 'temp-node',+ data: { _isTemp: true },+ },+ ]+ const { result } = renderUseNodesSyncDraft()+ let syncPromise!: ReturnType<typeof result.current.doSyncWorkflowDraft>++ act(() => {+ syncPromise = result.current.doSyncWorkflowDraft()+ })++ expect(workflowStoreState.showConfirm).toBeDefined()+ expect(mockSyncWorkflowDraft).not.toHaveBeenCalled()++ await act(async () => {+ workflowStoreState.showConfirm?.onConfirm()+ await syncPromise+ })++ expect(mockSyncWorkflowDraft).toHaveBeenCalledWith(+ expect.objectContaining({+ params: expect.objectContaining({+ graph: expect.objectContaining({ nodes: [], edges: [] }),+ force: true,+ }),+ }),+ )+ })++ it('should skip an empty page-close save without opening confirmation', () => {+ mockGetNodes.mockReturnValue([])+ const { result } = renderUseNodesSyncDraft()++ act(() => {+ result.current.syncWorkflowDraftWhenPageClose()+ })++ expect(mockPostWithKeepalive).not.toHaveBeenCalled()+ expect(mockSetShowConfirm).not.toHaveBeenCalled()+ })++ it('should keep one confirmation when another hook instance tries to save the empty graph', async () => {+ mockGetNodes.mockReturnValue([])+ const first = renderUseNodesSyncDraft()+ const second = renderUseNodesSyncDraft()+ const secondCallbacks = { onError: vi.fn(), onSettled: vi.fn() }+ let firstSave!: ReturnType<typeof first.result.current.doSyncWorkflowDraft>++ act(() => {+ firstSave = first.result.current.doSyncWorkflowDraft()+ })+ const confirmation = workflowStoreState.showConfirm++ await act(async () => {+ await expect(+ second.result.current.doSyncWorkflowDraft(false, secondCallbacks),+ ).resolves.toBeNull()+ })++ expect(mockSetShowConfirm).toHaveBeenCalledOnce()+ expect(workflowStoreState.showConfirm).toBe(confirmation)+ expect(secondCallbacks.onError).not.toHaveBeenCalled()+ expect(secondCallbacks.onSettled).toHaveBeenCalledOnce()++ await act(async () => {+ confirmation?.onConfirm()+ await firstSave+ })++ expect(mockSyncWorkflowDraft).toHaveBeenCalledOnce()+ })++ it('should not save the old empty graph when a node is added before confirmation', async () => {+ mockGetNodes.mockReturnValue([])+ const callbacks = { onError: vi.fn(), onSettled: vi.fn() }+ const { result } = renderUseNodesSyncDraft()+ let syncPromise!: ReturnType<typeof result.current.doSyncWorkflowDraft>++ act(() => {+ syncPromise = result.current.doSyncWorkflowDraft(false, callbacks)+ })++ mockGetNodes.mockReturnValue([+ { id: 'new-node', position: { x: 0, y: 0 }, data: { type: BlockEnum.Start } },+ ])++ await act(async () => {+ workflowStoreState.showConfirm?.onConfirm()+ await expect(syncPromise).resolves.toBeNull()+ })++ expect(mockSyncWorkflowDraft).not.toHaveBeenCalled()+ expect(callbacks.onError).not.toHaveBeenCalled()+ expect(callbacks.onSettled).toHaveBeenCalledOnce()+ })++ it('should recheck a confirmed empty graph after an earlier save finishes', async () => {+ let finishEarlierSave!: (response: { hash: string; updated_at: number }) => void+ let notifySaveStarted!: () => void+ const saveStarted = new Promise<void>((resolve) => {+ notifySaveStarted = resolve+ })+ mockSyncWorkflowDraft.mockImplementationOnce(+ () =>+ new Promise((resolve) => {+ finishEarlierSave = resolve+ notifySaveStarted()+ }),+ )+ const callbacks = { onError: vi.fn(), onSettled: vi.fn() }+ const { result } = renderUseNodesSyncDraft()+ let earlierSave!: ReturnType<typeof result.current.doSyncWorkflowDraft>+ let emptySave!: ReturnType<typeof result.current.doSyncWorkflowDraft>++ act(() => {+ earlierSave = result.current.doSyncWorkflowDraft()+ })+ await saveStarted+ mockGetNodes.mockReturnValue([])++ act(() => {+ emptySave = result.current.doSyncWorkflowDraft(false, callbacks)+ })++ await act(async () => {+ workflowStoreState.showConfirm?.onConfirm()+ })++ mockGetNodes.mockReturnValue([+ { id: 'restored-node', position: { x: 0, y: 0 }, data: { type: BlockEnum.Start } },+ ])++ await act(async () => {+ finishEarlierSave({ hash: 'earlier-save', updated_at: 1 })+ await earlierSave+ await expect(emptySave).resolves.toBeNull()+ })++ expect(mockSyncWorkflowDraft).toHaveBeenCalledOnce()+ expect(callbacks.onError).not.toHaveBeenCalled()+ expect(callbacks.onSettled).toHaveBeenCalledOnce()+ })++ it('should not apply empty-canvas consent to another app', async () => {+ mockGetNodes.mockReturnValue([])+ const { result } = renderUseNodesSyncDraft()+ let syncPromise!: ReturnType<typeof result.current.doSyncWorkflowDraft>++ act(() => {+ syncPromise = result.current.doSyncWorkflowDraft()+ })++ workflowStoreState.appId = 'app-2'+ await act(async () => {+ workflowStoreState.showConfirm?.onConfirm()+ await expect(syncPromise).resolves.toBeNull()+ })++ expect(mockSyncWorkflowDraft).not.toHaveBeenCalled()+ })++ it('should cancel a pending empty save when its owning hook unmounts', async () => {+ mockGetNodes.mockReturnValue([])+ const callbacks = { onError: vi.fn(), onSettled: vi.fn() }+ const { result, unmount } = renderUseNodesSyncDraft()+ let syncPromise!: ReturnType<typeof result.current.doSyncWorkflowDraft>++ act(() => {+ syncPromise = result.current.doSyncWorkflowDraft(false, callbacks)+ })+ expect(workflowStoreState.showConfirm).toBeDefined()++ unmount()+ await expect(syncPromise).resolves.toBeNull()++ expect(workflowStoreState.showConfirm).toBeUndefined()+ expect(mockSyncWorkflowDraft).not.toHaveBeenCalled()+ expect(callbacks.onError).not.toHaveBeenCalled()+ expect(callbacks.onSettled).toHaveBeenCalledOnce()+ })++ it('should confirm and save an empty collaborative follower graph in the initiating tab', async () => {+ isCollaborationEnabled = true+ mockCollaborationIsConnected.mockReturnValue(true)+ mockCollaborationGetIsLeader.mockReturnValue(false)+ mockGetNodes.mockReturnValue([])+ const { result } = renderUseNodesSyncDraft()+ let syncPromise!: ReturnType<typeof result.current.doSyncWorkflowDraft>++ act(() => {+ syncPromise = result.current.doSyncWorkflowDraft()+ })++ expect(workflowStoreState.showConfirm).toBeDefined()+ expect(mockCollaborationRequestWorkflowSync).not.toHaveBeenCalled()+ expect(mockSyncWorkflowDraft).not.toHaveBeenCalled()++ await act(async () => {+ workflowStoreState.showConfirm?.onConfirm()+ await syncPromise+ })++ expect(mockCollaborationRequestWorkflowSync).not.toHaveBeenCalled()+ expect(mockSyncWorkflowDraft).toHaveBeenCalledWith(+ expect.objectContaining({+ params: expect.objectContaining({ force: true, _is_collaborative: true }),+ }),+ )+ })+it('should call handleRefreshWorkflowDraft(true) — not updating canvas — on draft_workflow_not_sync', async () => {const error = {json: vi.fn().mockResolvedValue({ code: 'draft_workflow_not_sync' }),diff --git a/web/app/components/workflow-app/hooks/__tests__/use-workflow-init.spec.ts b/web/app/components/workflow-app/hooks/__tests__/use-workflow-init.spec.tsindex 216c7e0e24e..6918bacaecf 100644--- a/web/app/components/workflow-app/hooks/__tests__/use-workflow-init.spec.ts+++ b/web/app/components/workflow-app/hooks/__tests__/use-workflow-init.spec.ts@@ -192,6 +192,7 @@ describe('useWorkflowInit', () => {nodes: [],edges: [],},+ force: true,}),}),)@@ -224,6 +225,7 @@ describe('useWorkflowInit', () => {nodes: [{ id: 'start', data: { type: BlockEnum.Start } }],edges: [],},+ force: true,}),}),),diff --git a/web/app/components/workflow-app/hooks/use-nodes-sync-draft.ts b/web/app/components/workflow-app/hooks/use-nodes-sync-draft.tsindex 1a1f2953050..4e9e2123ac6 100644--- a/web/app/components/workflow-app/hooks/use-nodes-sync-draft.ts+++ b/web/app/components/workflow-app/hooks/use-nodes-sync-draft.ts@@ -6,7 +6,8 @@ import type {import type { WorkflowDraftFeaturesPayload } from '@/service/workflow'import { useSuspenseQuery } from '@tanstack/react-query'import { produce } from 'immer'-import { useCallback } from 'react'+import { useCallback, useEffect, useRef } from 'react'+import { useTranslation } from 'react-i18next'import { useStoreApi } from 'reactflow'import { useFeaturesStore } from '@/app/components/base/features/hooks'import { collaborationManager } from '@/app/components/workflow/collaboration/core/collaboration-manager'@@ -31,7 +32,11 @@ import { useWorkflowRefreshDraft } from './use-workflow-refresh-draft'const shouldSkipDraftSync = (appId: string | undefined, isWorkflowDataLoaded: boolean) =>!appId || !isWorkflowDataLoaded || isAppDeletingOrDeleted(appId)+const isEmptyGraph = (graph: { nodes: unknown[]; edges: unknown[] }) =>+ graph.nodes.length === 0 && graph.edges.length === 0+const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {+ const { t } = useTranslation(['workflow'])const store = useStoreApi()const workflowStore = useWorkflowStore()const featuresStore = useFeaturesStore()@@ -40,6 +45,16 @@ const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {...systemFeaturesQueryOptions(),select: (s) => s.enable_collaboration_mode,})+ const isMountedRef = useRef(false)+ const cancelConfirmationRef = useRef<(() => void) | undefined>(undefined)++ useEffect(() => {+ isMountedRef.current = true+ return () => {+ isMountedRef.current = false+ cancelConfirmationRef.current?.()+ }+ }, [])const getPostParams = useCallback(() => {const { getNodes, edges, transform } = store.getState()@@ -135,7 +150,9 @@ const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {const postParams = getPostParams()- if (postParams) postWithKeepalive(`${API_PREFIX}${postParams.url}`, postParams.params)+ // Page-close saves cannot wait for the user's consent to clear the canvas.+ if (postParams && !isEmptyGraph(postParams.params.graph))+ postWithKeepalive(`${API_PREFIX}${postParams.url}`, postParams.params)}, [getPostParams, getNodesReadOnly, isCollaborationEnabled])const performLocalSync = useCallback(@@ -144,6 +161,7 @@ const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {notRefreshWhenSyncError?: boolean,callback?: SyncDraftCallback,options?: SyncDraftOptions,+ force?: boolean,): Promise<SyncDraftResult | null> => {if (getNodesReadOnly()) return nullconst { appId, isWorkflowDataLoaded } = workflowStore.getState()@@ -157,6 +175,18 @@ const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {return null}+ if (force) {+ const currentParams = getPostParams()+ if (+ !currentParams ||+ currentParams.url !== baseParams.url ||+ !isEmptyGraph(currentParams.params.graph)+ ) {+ callback?.onSettled?.()+ return null+ }+ }+const { setSyncWorkflowDraftHash, setDraftUpdatedAt } = workflowStore.getState()try {@@ -167,6 +197,7 @@ const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {params: {...baseParams.params,hash: latestHash || null,+ ...(force ? { force: true } : {}),...(options?.environmentVariablePatch? {environment_variable_patch: {@@ -207,7 +238,13 @@ const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {callback?.onSettled?.()}},- [workflowStore, getNodesReadOnly, handleRefreshWorkflowDraft, isCollaborationEnabled],+ [+ workflowStore,+ getNodesReadOnly,+ getPostParams,+ handleRefreshWorkflowDraft,+ isCollaborationEnabled,+ ],)const doSyncWorkflowDraftLocally = useSerialAsyncCallback(performLocalSync, getNodesReadOnly)@@ -224,21 +261,65 @@ const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {return null}+ // Capture before ReactFlow resets its store during route unmount.+ const baseParams = getPostParams()+ if (!baseParams) {+ callback?.onSettled?.()+ return null+ }++ const emptyGraph = isEmptyGraph(baseParams.params.graph)+ if (emptyGraph) {+ const { showConfirm, setShowConfirm } = workflowStore.getState()+ if (+ !isMountedRef.current ||+ showConfirm ||+ (isCollaborationEnabled && !collaborationManager.canPersistLocalGraph())+ ) {+ callback?.onSettled?.()+ return null+ }++ const confirmed = await new Promise<boolean>((resolve) => {+ let settled = false+ const finish = (confirmed: boolean) => {+ if (settled) return+ settled = true+ cancelConfirmationRef.current = undefined+ setShowConfirm(undefined)+ resolve(confirmed)+ }+ cancelConfirmationRef.current = () => finish(false)+ setShowConfirm({+ title: t(($) => $['common.clearCanvasConfirmTitle'], { ns: 'workflow' }),+ desc: t(($) => $['common.clearCanvasConfirmDescription'], { ns: 'workflow' }),+ onConfirm: () => finish(true),+ onCancel: () => finish(false),+ })+ })++ if (!confirmed) {+ callback?.onSettled?.()+ return null+ }+ }+const shouldRequestLeader =+ !emptyGraph &&isCollaborationEnabled &&collaborationManager.isConnected() &&!collaborationManager.getIsLeader() &&!options?.forceLocalif (!shouldRequestLeader) {- // Capture before ReactFlow resets its store during route unmount.- const baseParams = getPostParams()- if (!baseParams) {- callback?.onSettled?.()- return null- }-- return doSyncWorkflowDraftLocally(baseParams, notRefreshWhenSyncError, callback, options)+ // The user grants consent in this tab, so persist a confirmed empty graph here.+ return doSyncWorkflowDraftLocally(+ baseParams,+ notRefreshWhenSyncError,+ callback,+ options,+ emptyGraph,+ )}try {@@ -261,6 +342,7 @@ const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {getNodesReadOnly,getPostParams,isCollaborationEnabled,+ t,workflowStore,],)diff --git a/web/app/components/workflow-app/hooks/use-workflow-init.ts b/web/app/components/workflow-app/hooks/use-workflow-init.tsindex 2625cc33765..1e6037e8405 100644--- a/web/app/components/workflow-app/hooks/use-workflow-init.ts+++ b/web/app/components/workflow-app/hooks/use-workflow-init.ts@@ -169,6 +169,7 @@ export const useWorkflowInit = () => {url: `/apps/${appDetail.id}/workflows/draft`,params: {graph: initialGraph,+ force: true,features: {retriever_resource: { enabled: true },},diff --git a/web/app/components/workflow/__tests__/workflow-edge-events.spec.tsx b/web/app/components/workflow/__tests__/workflow-edge-events.spec.tsxindex 871c9798e78..706e6378461 100644--- a/web/app/components/workflow/__tests__/workflow-edge-events.spec.tsx+++ b/web/app/components/workflow/__tests__/workflow-edge-events.spec.tsx@@ -1,5 +1,6 @@import type { Edge, Node } from '../types'import { act, fireEvent, screen, waitFor } from '@testing-library/react'+import userEvent from '@testing-library/user-event'import * as React from 'react'import { BaseEdge, internalsSymbol, Position, ReactFlowProvider, useStoreApi } from 'reactflow'import { FlowType } from '@/types/common'@@ -772,13 +773,16 @@ describe('Workflow edge event wiring', () => {})it('should render confirm description and clear showConfirm when cancelled', async () => {+ const user = userEvent.setup()const onConfirm = vi.fn()+ const onCancel = vi.fn()const { store } = renderSubject({initialStoreState: {showConfirm: {title: 'Confirm title',desc: 'Confirm description',onConfirm,+ onCancel,},},})@@ -787,13 +791,14 @@ describe('Workflow edge event wiring', () => {expect(screen.getByText('Confirm title')).toBeInTheDocument()expect(screen.getByText('Confirm description')).toBeInTheDocument()- fireEvent.click(screen.getByRole('button', { name: 'common.operation.cancel' }))+ await user.click(screen.getByRole('button', { name: 'common.operation.cancel' }))await waitFor(() => {expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument()})expect(store.getState().showConfirm).toBeUndefined()expect(onConfirm).not.toHaveBeenCalled()+ expect(onCancel).toHaveBeenCalledTimes(1)})it('should call showConfirm.onConfirm when confirm is clicked', () => {diff --git a/web/app/components/workflow/index.tsx b/web/app/components/workflow/index.tsxindex 2a0501263b4..e2f3a6bd476 100644--- a/web/app/components/workflow/index.tsx+++ b/web/app/components/workflow/index.tsx@@ -640,7 +640,12 @@ export const Workflow: FC<WorkflowProps> = memo(<HelpLine /><AlertDialogopen={!!showConfirm}- onOpenChange={(open) => !open && setShowConfirm(undefined)}+ onOpenChange={(open) => {+ if (!open) {+ showConfirm?.onCancel?.()+ setShowConfirm(undefined)+ }+ }}><AlertDialogContent><div className="flex flex-col gap-2 px-6 pt-6 pb-4">diff --git a/web/app/components/workflow/store/workflow/workflow-slice.ts b/web/app/components/workflow/store/workflow/workflow-slice.tsindex 47421620f88..074cebe02cb 100644--- a/web/app/components/workflow/store/workflow/workflow-slice.ts+++ b/web/app/components/workflow/store/workflow/workflow-slice.ts@@ -62,7 +62,7 @@ export type WorkflowSliceShape = {setCommentPreviewHovering: (hovering: boolean) => voidmousePosition: { pageX: number; pageY: number; elementX: number; elementY: number }setMousePosition: (mousePosition: WorkflowSliceShape['mousePosition']) => void- showConfirm?: { title: string; desc?: string; onConfirm: () => void }+ showConfirm?: { title: string; desc?: string; onConfirm: () => void; onCancel?: () => void }setShowConfirm: (showConfirm: WorkflowSliceShape['showConfirm']) => voidcontrolPromptEditorRerenderKey: numbersetControlPromptEditorRerenderKey: (controlPromptEditorRerenderKey: number) => voiddiff --git a/web/i18n/locales/ar-TN/workflow.json b/web/i18n/locales/ar-TN/workflow.jsonindex 66f48ae9eac..a2aaa137abc 100644--- a/web/i18n/locales/ar-TN/workflow.json+++ b/web/i18n/locales/ar-TN/workflow.json@@ -117,6 +117,8 @@"common.branch": "فرع","common.chooseDSL": "اختر ملف DSL","common.chooseStartNodeToRun": "اختر عقدة البداية للتشغيل",+ "common.clearCanvasConfirmDescription": "سيؤدي الحفظ إلى مسح سير العمل هذا. هل تريد المتابعة؟",+ "common.clearCanvasConfirmTitle": "هل تريد مسح اللوحة؟","common.clipboardVersionCompatibilityWarning": "تم نسخ هذا المحتوى من إصدار مختلف من تطبيق Dify. قد تكون بعض الأجزاء غير متوافقة.","common.commentMode": "وضع التعليقات","common.configure": "تكوين",diff --git a/web/i18n/locales/az-AZ/workflow.json b/web/i18n/locales/az-AZ/workflow.jsonindex eb429176edf..1e06d072daf 100644--- a/web/i18n/locales/az-AZ/workflow.json+++ b/web/i18n/locales/az-AZ/workflow.json@@ -117,6 +117,8 @@"common.branch": "Qol","common.chooseDSL": "DSL faylını seç","common.chooseStartNodeToRun": "İcra etmək üçün başlanğıc qovşağını seç",+ "common.clearCanvasConfirmDescription": "Yadda saxlamaq bu iş axınını təmizləyəcək. Davam edilsin?",+ "common.clearCanvasConfirmTitle": "Kətanı təmizləmək istəyirsiniz?","common.clipboardVersionCompatibilityWarning": "Bu məzmun Dify tətbiqinin fərqli versiyasından kopyalanıb. Bəzi hissələr uyğun olmaya bilər.","common.commentMode": "Şərh rejimi","common.configure": "Konfiqurasiya et",diff --git a/web/i18n/locales/de-DE/workflow.json b/web/i18n/locales/de-DE/workflow.jsonindex 14f908cda0f..9c53c0da655 100644--- a/web/i18n/locales/de-DE/workflow.json+++ b/web/i18n/locales/de-DE/workflow.json@@ -117,6 +117,8 @@"common.branch": "ZWEIG","common.chooseDSL": "Wählen Sie eine DSL(yml)-Datei","common.chooseStartNodeToRun": "Wählen Sie den Startknoten zum Ausführen",+ "common.clearCanvasConfirmDescription": "Beim Speichern wird dieser Workflow geleert. Fortfahren?",+ "common.clearCanvasConfirmTitle": "Die Arbeitsfläche leeren?","common.clipboardVersionCompatibilityWarning": "Dieser Inhalt wurde aus einer anderen Dify-App-Version kopiert. Einige Teile sind möglicherweise nicht kompatibel.","common.commentMode": "Kommentar-Modus","common.configure": "Konfigurieren",diff --git a/web/i18n/locales/en-US/workflow.json b/web/i18n/locales/en-US/workflow.jsonindex bb08be341e9..a8e9df05c11 100644--- a/web/i18n/locales/en-US/workflow.json+++ b/web/i18n/locales/en-US/workflow.json@@ -117,6 +117,8 @@"common.branch": "BRANCH","common.chooseDSL": "Choose DSL file","common.chooseStartNodeToRun": "Choose the start node to run",+ "common.clearCanvasConfirmDescription": "Saving will clear this workflow. Continue?",+ "common.clearCanvasConfirmTitle": "Clear the canvas?","common.clipboardVersionCompatibilityWarning": "This content was copied from a different Dify app version. Some parts may be incompatible.","common.commentMode": "Comment Mode","common.configure": "Configure",diff --git a/web/i18n/locales/es-ES/workflow.json b/web/i18n/locales/es-ES/workflow.jsonindex 762a78cfeed..9ab3b0be704 100644--- a/web/i18n/locales/es-ES/workflow.json+++ b/web/i18n/locales/es-ES/workflow.json@@ -117,6 +117,8 @@"common.branch": "RAMA","common.chooseDSL": "Elegir archivo DSL (yml)","common.chooseStartNodeToRun": "Elige el nodo de inicio para ejecutar",+ "common.clearCanvasConfirmDescription": "Al guardar, se vaciará este flujo de trabajo. ¿Continuar?",+ "common.clearCanvasConfirmTitle": "¿Vaciar el lienzo?","common.clipboardVersionCompatibilityWarning": "Este contenido se copió desde una versión diferente de la aplicación Dify. Es posible que algunas partes no sean compatibles.","common.commentMode": "Modo de comentarios","common.configure": "Configurar",diff --git a/web/i18n/locales/fa-IR/workflow.json b/web/i18n/locales/fa-IR/workflow.jsonindex db9c71d1709..62d25da6c56 100644--- a/web/i18n/locales/fa-IR/workflow.json+++ b/web/i18n/locales/fa-IR/workflow.json@@ -117,6 +117,8 @@"common.branch": "شاخه","common.chooseDSL": "انتخاب فایل DSL (yml)","common.chooseStartNodeToRun": "گره شروع را برای اجرا انتخاب کنید",+ "common.clearCanvasConfirmDescription": "ذخیره کردن این گردش کار را پاک میکند. ادامه میدهید؟",+ "common.clearCanvasConfirmTitle": "بوم را پاک میکنید؟","common.clipboardVersionCompatibilityWarning": "این محتوا از نسخه دیگری از برنامه Dify کپی شده است. ممکن است برخی بخشها ناسازگار باشند.","common.commentMode": "حالت نظرات","common.configure": "پیکربندی",diff --git a/web/i18n/locales/fr-FR/workflow.json b/web/i18n/locales/fr-FR/workflow.jsonindex 09a9d01f165..b7d4884d9c3 100644--- a/web/i18n/locales/fr-FR/workflow.json+++ b/web/i18n/locales/fr-FR/workflow.json@@ -117,6 +117,8 @@"common.branch": "BRANCHE","common.chooseDSL": "Choisir le fichier DSL(yml)","common.chooseStartNodeToRun": "Choisissez le nœud de départ pour lancer",+ "common.clearCanvasConfirmDescription": "L’enregistrement videra ce workflow. Continuer ?",+ "common.clearCanvasConfirmTitle": "Vider le canevas ?","common.clipboardVersionCompatibilityWarning": "Ce contenu a été copié depuis une version différente de l'application Dify. Certaines parties peuvent être incompatibles.","common.commentMode": "Mode commentaires","common.configure": "Configurer",diff --git a/web/i18n/locales/hi-IN/workflow.json b/web/i18n/locales/hi-IN/workflow.jsonindex 8d90c9cc632..4d5a50e5196 100644--- a/web/i18n/locales/hi-IN/workflow.json+++ b/web/i18n/locales/hi-IN/workflow.json@@ -117,6 +117,8 @@"common.branch": "शाखा","common.chooseDSL": "डीएसएल (वाईएमएल) फ़ाइल चुनें","common.chooseStartNodeToRun": "चलाने के लिए प्रारंभ नोड चुनें",+ "common.clearCanvasConfirmDescription": "सहेजने पर यह वर्कफ़्लो साफ़ हो जाएगा। जारी रखें?",+ "common.clearCanvasConfirmTitle": "कैनवास साफ़ करें?","common.clipboardVersionCompatibilityWarning": "यह सामग्री Dify ऐप के किसी अलग संस्करण से कॉपी की गई है। इसके कुछ हिस्से असंगत हो सकते हैं।","common.commentMode": "टिप्पणी मोड","common.configure": "कॉन्फ़िगर करें",diff --git a/web/i18n/locales/id-ID/workflow.json b/web/i18n/locales/id-ID/workflow.jsonindex 0abc1125fd5..b03fba74126 100644--- a/web/i18n/locales/id-ID/workflow.json+++ b/web/i18n/locales/id-ID/workflow.json@@ -117,6 +117,8 @@"common.branch": "CABANG","common.chooseDSL": "Pilih file DSL","common.chooseStartNodeToRun": "Pilih node awal untuk dijalankan",+ "common.clearCanvasConfirmDescription": "Menyimpan akan mengosongkan alur kerja ini. Lanjutkan?",+ "common.clearCanvasConfirmTitle": "Kosongkan kanvas?","common.clipboardVersionCompatibilityWarning": "Konten ini disalin dari versi aplikasi Dify yang berbeda. Beberapa bagian mungkin tidak kompatibel.","common.commentMode": "Mode komentar","common.configure": "Konfigurasikan",diff --git a/web/i18n/locales/it-IT/workflow.json b/web/i18n/locales/it-IT/workflow.jsonindex c9cf305c02d..e1099986206 100644--- a/web/i18n/locales/it-IT/workflow.json+++ b/web/i18n/locales/it-IT/workflow.json@@ -117,6 +117,8 @@"common.branch": "RAMO","common.chooseDSL": "Scegli file DSL(yml)","common.chooseStartNodeToRun": "Scegli il nodo di partenza da eseguire",+ "common.clearCanvasConfirmDescription": "Il salvataggio svuoterà questo flusso di lavoro. Continuare?",+ "common.clearCanvasConfirmTitle": "Svuotare l’area di lavoro?","common.clipboardVersionCompatibilityWarning": "Questo contenuto è stato copiato da una versione diversa dell'app Dify. Alcune parti potrebbero non essere compatibili.","common.commentMode": "Modalità commenti","common.configure": "Configura",diff --git a/web/i18n/locales/ja-JP/workflow.json b/web/i18n/locales/ja-JP/workflow.jsonindex f1282edf44f..e7a88de5597 100644--- a/web/i18n/locales/ja-JP/workflow.json+++ b/web/i18n/locales/ja-JP/workflow.json@@ -117,6 +117,8 @@"common.branch": "ブランチ","common.chooseDSL": "DSL(yml) ファイルを選択","common.chooseStartNodeToRun": "実行する開始ノードを選択",+ "common.clearCanvasConfirmDescription": "保存すると、このワークフローが空になります。続行しますか?",+ "common.clearCanvasConfirmTitle": "キャンバスを空にしますか?","common.clipboardVersionCompatibilityWarning": "このコンテンツは別の Dify アプリバージョンからコピーされました。一部が互換性のない可能性があります。","common.commentMode": "コメントモード","common.configure": "設定",diff --git a/web/i18n/locales/ko-KR/workflow.json b/web/i18n/locales/ko-KR/workflow.jsonindex 8055d8303fd..8daeef65162 100644--- a/web/i18n/locales/ko-KR/workflow.json+++ b/web/i18n/locales/ko-KR/workflow.json@@ -117,6 +117,8 @@"common.branch": "브랜치","common.chooseDSL": "DSL(yml) 파일 선택","common.chooseStartNodeToRun": "실행할 시작 노드를 선택하세요",+ "common.clearCanvasConfirmDescription": "저장하면 이 워크플로가 비워집니다. 계속하시겠습니까?",+ "common.clearCanvasConfirmTitle": "캔버스를 비우시겠습니까?","common.clipboardVersionCompatibilityWarning": "이 콘텐츠는 다른 Dify 앱 버전에서 복사되었습니다. 일부 항목은 호환되지 않을 수 있습니다.","common.commentMode": "댓글 모드","common.configure": "구성",diff --git a/web/i18n/locales/lo-LA/workflow.json b/web/i18n/locales/lo-LA/workflow.jsonindex 6cfdbebb699..b8a576d8bc5 100644--- a/web/i18n/locales/lo-LA/workflow.json+++ b/web/i18n/locales/lo-LA/workflow.json@@ -117,6 +117,8 @@"common.branch": "BRANCH","common.chooseDSL": "ເລືອກໄຟລ໌ DSL","common.chooseStartNodeToRun": "ເລືອກໂນດເລີ່ມຕົ້ນເພື່ອລັນ",+ "common.clearCanvasConfirmDescription": "ການບັນທຶກຈະລ້າງຂັ້ນຕອນການເຮັດວຽກນີ້. ຕ້ອງການດຳເນີນຕໍ່ບໍ?",+ "common.clearCanvasConfirmTitle": "ຕ້ອງການລ້າງ Canvas ບໍ?","common.clipboardVersionCompatibilityWarning": "ເນື້ອໃນນີ້ຖືກກັອບປີ້ມາຈາກເວີຊັນ Dify ທີ່ແຕກຕ່າງ. ບາງສ່ວນອາດຈະບໍ່ເຂົ້າກັນໄດ້.","common.commentMode": "ໂໝດຄຳເຫັນ","common.configure": "ຕັ້ງຄ່າ",diff --git a/web/i18n/locales/nl-NL/workflow.json b/web/i18n/locales/nl-NL/workflow.jsonindex be98cccc484..15f2364efef 100644--- a/web/i18n/locales/nl-NL/workflow.json+++ b/web/i18n/locales/nl-NL/workflow.json@@ -117,6 +117,8 @@"common.branch": "BRANCH","common.chooseDSL": "Choose DSL file","common.chooseStartNodeToRun": "Choose the start node to run",+ "common.clearCanvasConfirmDescription": "Opslaan maakt deze workflow leeg. Doorgaan?",+ "common.clearCanvasConfirmTitle": "Het canvas leegmaken?","common.clipboardVersionCompatibilityWarning": "Deze inhoud is gekopieerd vanuit een andere Dify-appversie. Sommige onderdelen zijn mogelijk niet compatibel.","common.commentMode": "Opmerkingsmodus","common.configure": "Configure",diff --git a/web/i18n/locales/pl-PL/workflow.json b/web/i18n/locales/pl-PL/workflow.jsonindex 3d38bb2c82d..a6bc017c28b 100644--- a/web/i18n/locales/pl-PL/workflow.json+++ b/web/i18n/locales/pl-PL/workflow.json@@ -117,6 +117,8 @@"common.branch": "GAŁĄŹ","common.chooseDSL": "Wybierz plik DSL(yml)","common.chooseStartNodeToRun": "Wybierz węzeł początkowy, aby uruchomić",+ "common.clearCanvasConfirmDescription": "Zapisanie wyczyści ten przepływ pracy. Kontynuować?",+ "common.clearCanvasConfirmTitle": "Wyczyścić obszar roboczy?","common.clipboardVersionCompatibilityWarning": "Ta zawartość została skopiowana z innej wersji aplikacji Dify. Niektóre elementy mogą być niekompatybilne.","common.commentMode": "Tryb komentarzy","common.configure": "Skonfiguruj",diff --git a/web/i18n/locales/pt-BR/workflow.json b/web/i18n/locales/pt-BR/workflow.jsonindex 4722571f021..e74d67ddaa5 100644--- a/web/i18n/locales/pt-BR/workflow.json+++ b/web/i18n/locales/pt-BR/workflow.json@@ -117,6 +117,8 @@"common.branch": "RAMIFICAÇÃO","common.chooseDSL": "Escolha o arquivo DSL(yml)","common.chooseStartNodeToRun": "Escolha o nó inicial para executar",+ "common.clearCanvasConfirmDescription": "Salvar limpará este fluxo de trabalho. Continuar?",+ "common.clearCanvasConfirmTitle": "Limpar a tela?","common.clipboardVersionCompatibilityWarning": "Este conteúdo foi copiado de uma versão diferente do aplicativo Dify. Algumas partes podem ser incompatíveis.","common.commentMode": "Modo de comentários","common.configure": "Configurar",diff --git a/web/i18n/locales/ro-RO/workflow.json b/web/i18n/locales/ro-RO/workflow.jsonindex 950dcc03c96..88c42fedcf2 100644--- a/web/i18n/locales/ro-RO/workflow.json+++ b/web/i18n/locales/ro-RO/workflow.json@@ -117,6 +117,8 @@"common.branch": "RAMURĂ","common.chooseDSL": "Alegeți fișierul DSL(yml)","common.chooseStartNodeToRun": "Alegeți nodul de start pentru a rula",+ "common.clearCanvasConfirmDescription": "Salvarea va goli acest flux de lucru. Continui?",+ "common.clearCanvasConfirmTitle": "Golești zona de lucru?","common.clipboardVersionCompatibilityWarning": "Acest conținut a fost copiat dintr-o altă versiune a aplicației Dify. Unele părți pot fi incompatibile.","common.commentMode": "Mod comentarii","common.configure": "Configurează",diff --git a/web/i18n/locales/ru-RU/workflow.json b/web/i18n/locales/ru-RU/workflow.jsonindex 4d0c76e6f37..eafb02b7e45 100644--- a/web/i18n/locales/ru-RU/workflow.json+++ b/web/i18n/locales/ru-RU/workflow.json@@ -117,6 +117,8 @@"common.branch": "ВЕТКА","common.chooseDSL": "Выберите файл DSL(yml)","common.chooseStartNodeToRun": "Выберите начальный узел для запуска",+ "common.clearCanvasConfirmDescription": "Сохранение очистит этот рабочий процесс. Продолжить?",+ "common.clearCanvasConfirmTitle": "Очистить холст?","common.clipboardVersionCompatibilityWarning": "Этот контент был скопирован из другой версии приложения Dify. Некоторые части могут быть несовместимы.","common.commentMode": "Режим комментариев","common.configure": "Настроить",diff --git a/web/i18n/locales/sl-SI/workflow.json b/web/i18n/locales/sl-SI/workflow.jsonindex 10c23ebb15f..878b588a894 100644--- a/web/i18n/locales/sl-SI/workflow.json+++ b/web/i18n/locales/sl-SI/workflow.json@@ -117,6 +117,8 @@"common.branch": "VEJA","common.chooseDSL": "Izberi DSL datoteko","common.chooseStartNodeToRun": "Izberite začetno vozlišče za zagon",+ "common.clearCanvasConfirmDescription": "Shranjevanje bo počistilo ta delovni tok. Želite nadaljevati?",+ "common.clearCanvasConfirmTitle": "Počisti platno?","common.clipboardVersionCompatibilityWarning": "Ta vsebina je bila kopirana iz druge različice aplikacije Dify. Nekateri deli morda niso združljivi.","common.commentMode": "Način komentarjev","common.configure": "Konfiguriraj",diff --git a/web/i18n/locales/th-TH/workflow.json b/web/i18n/locales/th-TH/workflow.jsonindex 5f69dde0169..33c1bff8d17 100644--- a/web/i18n/locales/th-TH/workflow.json+++ b/web/i18n/locales/th-TH/workflow.json@@ -117,6 +117,8 @@"common.branch": "กิ่ง","common.chooseDSL": "เลือกไฟล์ DSL","common.chooseStartNodeToRun": "เลือกโหนดเริ่มต้นเพื่อรัน",+ "common.clearCanvasConfirmDescription": "การบันทึกจะล้างเวิร์กโฟลว์นี้ ต้องการดำเนินการต่อหรือไม่?",+ "common.clearCanvasConfirmTitle": "ต้องการล้างพื้นที่ทำงานหรือไม่?","common.clipboardVersionCompatibilityWarning": "เนื้อหานี้ถูกคัดลอกจากแอป Dify คนละเวอร์ชัน บางส่วนอาจไม่เข้ากัน","common.commentMode": "โหมดความคิดเห็น","common.configure": "กําหนดค่า",diff --git a/web/i18n/locales/tr-TR/workflow.json b/web/i18n/locales/tr-TR/workflow.jsonindex f8160037b2b..67bc25121fe 100644--- a/web/i18n/locales/tr-TR/workflow.json+++ b/web/i18n/locales/tr-TR/workflow.json@@ -117,6 +117,8 @@"common.branch": "DAL","common.chooseDSL": "DSL(yml) dosyasını seçin","common.chooseStartNodeToRun": "Çalıştırmak için başlangıç düğümünü seçin",+ "common.clearCanvasConfirmDescription": "Kaydetmek bu iş akışını temizleyecek. Devam edilsin mi?",+ "common.clearCanvasConfirmTitle": "Tuval temizlensin mi?","common.clipboardVersionCompatibilityWarning": "Bu içerik farklı bir Dify uygulama sürümünden kopyalandı. Bazı bölümler uyumsuz olabilir.","common.commentMode": "Yorum modu","common.configure": "Yapılandır",diff --git a/web/i18n/locales/uk-UA/workflow.json b/web/i18n/locales/uk-UA/workflow.jsonindex 42d875a9037..b523b53da13 100644--- a/web/i18n/locales/uk-UA/workflow.json+++ b/web/i18n/locales/uk-UA/workflow.json@@ -117,6 +117,8 @@"common.branch": "ГІЛКА","common.chooseDSL": "Виберіть файл DSL(yml)","common.chooseStartNodeToRun": "Виберіть початковий вузол для запуску",+ "common.clearCanvasConfirmDescription": "Збереження очистить цей робочий процес. Продовжити?",+ "common.clearCanvasConfirmTitle": "Очистити полотно?","common.clipboardVersionCompatibilityWarning": "Цей вміст скопійовано з іншої версії застосунку Dify. Деякі частини можуть бути несумісними.","common.commentMode": "Режим коментарів","common.configure": "Налаштувати",diff --git a/web/i18n/locales/vi-VN/workflow.json b/web/i18n/locales/vi-VN/workflow.jsonindex e777ff8eb00..9f91f197a1b 100644--- a/web/i18n/locales/vi-VN/workflow.json+++ b/web/i18n/locales/vi-VN/workflow.json@@ -117,6 +117,8 @@"common.branch": "NHÁNH","common.chooseDSL": "Chọn tệp DSL(yml)","common.chooseStartNodeToRun": "Chọn nút bắt đầu để chạy",+ "common.clearCanvasConfirmDescription": "Lưu sẽ xóa toàn bộ nội dung quy trình này. Tiếp tục?",+ "common.clearCanvasConfirmTitle": "Xóa toàn bộ nội dung khung vẽ?","common.clipboardVersionCompatibilityWarning": "Nội dung này được sao chép từ một phiên bản ứng dụng Dify khác. Một số phần có thể không tương thích.","common.commentMode": "Chế độ bình luận","common.configure": "Cấu hình",diff --git a/web/i18n/locales/zh-Hans/workflow.json b/web/i18n/locales/zh-Hans/workflow.jsonindex e047ca8ba7b..052c8215fed 100644--- a/web/i18n/locales/zh-Hans/workflow.json+++ b/web/i18n/locales/zh-Hans/workflow.json@@ -117,6 +117,8 @@"common.branch": "分支","common.chooseDSL": "选择 DSL(yml) 文件","common.chooseStartNodeToRun": "选择启动节点进行运行",+ "common.clearCanvasConfirmDescription": "保存将清空此工作流,确定继续吗?",+ "common.clearCanvasConfirmTitle": "确定清空画布?","common.clipboardVersionCompatibilityWarning": "此内容复制自不同版本的 Dify 应用,部分内容可能不兼容。","common.commentMode": "评论模式","common.configure": "配置",diff --git a/web/i18n/locales/zh-Hant/workflow.json b/web/i18n/locales/zh-Hant/workflow.jsonindex 69e0636fd4c..cdf0eabff29 100644--- a/web/i18n/locales/zh-Hant/workflow.json+++ b/web/i18n/locales/zh-Hant/workflow.json@@ -117,6 +117,8 @@"common.branch": "分支","common.chooseDSL": "選擇 DSL(yml)檔","common.chooseStartNodeToRun": "選擇要執行的起始節點",+ "common.clearCanvasConfirmDescription": "儲存將清空此工作流程,確定繼續嗎?",+ "common.clearCanvasConfirmTitle": "確定清空畫布?","common.clipboardVersionCompatibilityWarning": "此內容複製自不同版本的 Dify 應用,部分內容可能不相容。","common.commentMode": "評論模式","common.configure": "配置",diff --git a/web/i18n/resources.generated.d.ts b/web/i18n/resources.generated.d.tsindex ccda1f67f6d..7829f211584 100644--- a/web/i18n/resources.generated.d.ts+++ b/web/i18n/resources.generated.d.ts@@ -4926,6 +4926,8 @@ export default interface Resources {'common.branch': 'BRANCH''common.chooseDSL': 'Choose DSL file''common.chooseStartNodeToRun': 'Choose the start node to run'+ 'common.clearCanvasConfirmDescription': 'Saving will clear this workflow. Continue?'+ 'common.clearCanvasConfirmTitle': 'Clear the canvas?''common.clipboardVersionCompatibilityWarning': 'This content was copied from a different Dify app version. Some parts may be incompatible.''common.commentMode': 'Comment Mode''common.configure': 'Configure'diff --git a/web/service/workflow.ts b/web/service/workflow.tsindex f8f42de7fd6..4d39477709c 100644--- a/web/service/workflow.ts+++ b/web/service/workflow.ts@@ -41,6 +41,7 @@ export const syncWorkflowDraft = ({params: Pick<FetchWorkflowDraftResponse, 'graph' | 'features' | 'conversation_variables'> &Partial<Pick<FetchWorkflowDraftResponse, 'environment_variables'>> & {environment_variable_patch?: EnvironmentVariablePatchPayload+ force?: boolean}}) => {return post<CommonResponse & { updated_at: number; hash: string }>(