Principle:Langgenius Dify Workflow Publishing
Appearance
| Knowledge Sources | Dify |
|---|---|
| Domains | Workflow, DAG, Frontend |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Description
Workflow Publishing and Versioning is the principle that governs how workflow drafts are promoted to production and how version history is managed in the Dify platform. The workflow lifecycle follows a draft-publish model:
- Draft: All edits (node additions, variable wiring, configuration changes) are saved to the draft version of the workflow via
syncWorkflowDraft. The draft is the working copy that can be tested and iterated upon. - Publish: When the developer is satisfied with the draft, they publish it to create a new immutable version. The published version becomes the active workflow that end users interact with. Each publish creates a timestamped snapshot with an optional title (marked_name) and release notes (marked_comment).
- Version History: All published versions are retained in a paginated version history, allowing developers to review past versions, compare changes, and roll back if needed.
The platform provides four key version management operations:
- Publish: Promote the current draft to a new published version with metadata.
- Update: Modify the title and release notes of an existing published version.
- Delete: Remove a specific published version from the history.
- Version History: Browse all published versions with pagination, optional filtering by user and named-only versions.
This model ensures that production workflows are never directly edited, providing a safety layer between development and deployment.
Usage
When publishing and managing workflow versions:
- Use usePublishWorkflow to publish the current draft as a new version, providing an optional title and release notes.
- Use useWorkflowVersionHistory to browse the paginated list of published versions, with optional filters for user and named-only versions.
- Use useUpdateWorkflow to modify the title or release notes of a previously published version.
- Use useDeleteWorkflow to remove a published version from the history.
- All four operations are implemented as React Query mutations/queries, providing automatic cache invalidation, loading states, and error handling.
Theoretical Basis
This principle is grounded in:
- Draft-Publish Content Model: This is the same pattern used by content management systems (WordPress, Drupal) and infrastructure-as-code tools (Terraform plan/apply). The separation between draft and published states ensures that incomplete changes never affect production, while the explicit publish action serves as a deployment gate.
- Immutable Version History: Each published version is an immutable snapshot, following the event sourcing principle where state changes are recorded as a sequence of events. This enables auditing, rollback, and comparison between versions.
- Optimistic Mutations with React Query: The implementation uses TanStack React Query's
useMutationhook, which provides optimistic UI updates, automatic retry, and cache invalidation. This ensures that version management operations feel responsive to the user while maintaining consistency with the backend. - Infinite Scroll Pagination: Version history uses
useInfiniteQuerywith agetNextPageParamfunction, implementing the infinite scroll pattern for browsing large version histories without loading all versions upfront.
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment