Skip to content

fix(workflow): resolve occasional issues with syncing historical states or clearing DSL in draft mode#27391

Merged
lyzno1 merged 3 commits intofeat/triggerfrom
fix/workflow-draft
Oct 24, 2025
Merged

fix(workflow): resolve occasional issues with syncing historical states or clearing DSL in draft mode#27391
lyzno1 merged 3 commits intofeat/triggerfrom
fix/workflow-draft

Conversation

@lyzno1
Copy link
Copy Markdown
Member

@lyzno1 lyzno1 commented Oct 24, 2025

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 🌊 feat:workflow Workflow related stuff. labels Oct 24, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @lyzno1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where the DSL content of workflows and chatflows could occasionally be reset to their initial values. The changes focus on refining the client-side workflow draft synchronization and refresh processes. By preventing temporary UI elements from being inadvertently persisted and by enhancing the robustness of draft loading and error handling, the PR aims to improve the stability and integrity of workflow definitions.

Highlights

  • Preventing Temporary Node/Edge Persistence: The workflow draft synchronization process now explicitly filters out temporary nodes (those marked with _isTempNode) and temporary edges (those marked with _isTemp) before sending data to the backend. This ensures that only permanent workflow elements are saved, preventing transient UI states from corrupting the workflow definition.
  • Enhanced Workflow Draft Refresh Logic: The mechanism for refreshing workflow drafts has been improved. It now cancels any pending debounced sync operations before initiating a refresh, preventing potential race conditions. Additionally, the isWorkflowDataLoaded state is managed more robustly, ensuring correct loading indicators and proper state restoration even if the draft fetch operation encounters an error.
  • Code Cleanup and Simplification: Several import statements have been streamlined, and the logic for constructing the URL used in navigator.sendBeacon has been simplified. Conditional checks for appId and isWorkflowDataLoaded have also been made more concise.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@lyzno1 lyzno1 changed the title fix: https://linear.app/dify/issue/FPRD-43/%E5%81%B6%E7%8E%B0-workflow-%E5%92%8C-chatflow-%E7%9A%84-dsl-%E7%9A%84%E5%86%85%E5%AE%B9%E8%A2%AB%E9%87%8D%E7%BD%AE%E6%88%90%E5%88%9D%E5%A7%8B%E5%80%BC fix: workflow draft Oct 24, 2025
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 旨在修复一个竞态条件问题,该问题可能导致工作流内容被意外重置。您所做的更改通过以下方式解决了这个问题:

  1. 在从服务器刷新工作流之前,取消任何待处理的草稿同步操作。
  2. 在刷新过程中暂时禁用草稿同步,以防止冲突。
  3. 从保存的数据中过滤掉临时节点,确保只持久化有效状态。
    这些更改逻辑清晰,有效地解决了问题的根源。通过一些小的重构,代码质量也得到了提升。这是一个可靠的修复。

@lyzno1 lyzno1 changed the title fix: workflow draft fix(workflow): resolve occasional issues with syncing historical states or clearing DSL in draft mode Oct 24, 2025
@lyzno1 lyzno1 merged commit 1dddcf1 into feat/trigger Oct 24, 2025
@lyzno1 lyzno1 deleted the fix/workflow-draft branch October 24, 2025 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌊 feat:workflow Workflow related stuff. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant