langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
52.45k stars 7.65k forks source link

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

Open johnpccd opened 7 hours ago

johnpccd commented 7 hours ago

Self Checks

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

dosubot[bot] commented 7 hours ago

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.