mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 08:05:59 +08:00
feat: sort variables in the selector by x axis for most recent order (#19243)
This commit is contained in:
parent
9231c197a5
commit
b979a8a707
@ -577,8 +577,20 @@ export const toNodeOutputVars = (
|
||||
chatVarList: conversationVariables,
|
||||
},
|
||||
}
|
||||
// Sort nodes in reverse chronological order (most recent first)
|
||||
const sortedNodes = [...nodes].sort((a, b) => {
|
||||
if (a.data.type === BlockEnum.Start) return 1
|
||||
if (b.data.type === BlockEnum.Start) return -1
|
||||
if (a.data.type === 'env') return 1
|
||||
if (b.data.type === 'env') return -1
|
||||
if (a.data.type === 'conversation') return 1
|
||||
if (b.data.type === 'conversation') return -1
|
||||
// sort nodes by x position
|
||||
return (b.position?.x || 0) - (a.position?.x || 0)
|
||||
})
|
||||
|
||||
const res = [
|
||||
...nodes.filter(node => SUPPORT_OUTPUT_VARS_NODE.includes(node?.data?.type)),
|
||||
...sortedNodes.filter(node => SUPPORT_OUTPUT_VARS_NODE.includes(node?.data?.type)),
|
||||
...(environmentVariables.length > 0 ? [ENV_NODE] : []),
|
||||
...((isChatMode && conversationVariables.length > 0) ? [CHAT_VAR_NODE] : []),
|
||||
].map((node) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user