dify icon indicating copy to clipboard operation
dify copied to clipboard

[Organize blocks] messes up the vertical order of nodes stemming from the same source

Open johnpccd opened this issue 1 year ago • 1 comments

Self Checks

  • [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [X] I have searched for existing issues search for existing issues, including closed ones.
  • [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [X] Please do not modify this template :) and fill in all the required fields.

Dify version

0.11.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Create a Workflow that looks like this: image Click the Organize block button

✔️ Expected Behavior

Correct vertical order of blocks

❌ Actual Behavior

image

johnpccd avatar Nov 24 '24 01:11 johnpccd

The issue you're experiencing with the 'Organize blocks' feature affecting the vertical order of nodes might be related to how the current implementation determines the order of nodes. The implementation compares the x-coordinates of nodes to determine their vertical order, which might not always align with the expected behavior [1].

The handleLayout function in the useWorkflowOrganize hook is responsible for organizing the nodes. It uses the getLayoutByDagre utility to calculate the layout and updates the node positions based on this layout. This process might be causing the unexpected vertical order [2].

To address this, you might want to review the logic in the handleLayout function and the criteria used for node positioning. Adjusting the logic to better account for the desired vertical order could help resolve the issue.

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Nov 24 '24 01:11 dosubot[bot]