fix(web): var-aggregator‘s variable delay calculate

This commit is contained in:
zhaoying
2026-04-22 15:33:59 +08:00
parent b488590537
commit 124e8d0639

View File

@@ -393,18 +393,19 @@ export const useVariableList = (
// Add chat variables // Add chat variables
chatVariables?.forEach(v => addVariable(list, keys, `CONVERSATION_${v.name}`, v.name, v.type, `conv.${v.name}`, { type: 'CONVERSATION', name: 'CONVERSATION', icon: '' }, { group: 'CONVERSATION' })); chatVariables?.forEach(v => addVariable(list, keys, `CONVERSATION_${v.name}`, v.name, v.type, `conv.${v.name}`, { type: 'CONVERSATION', name: 'CONVERSATION', icon: '' }, { group: 'CONVERSATION' }));
// Process each relevant node: non-list-operator first, then list-operator // Process each relevant node: deferred types last (they depend on prior variables)
const listOperatorIds: string[] = []; const deferredIds: string[] = [];
relevantIds.forEach(id => { relevantIds.forEach(id => {
const node = nodes.find(n => n.id === id); const node = nodes.find(n => n.id === id);
if (!node) return; if (!node) return;
if (node.getData()?.type === 'list-operator') { const t = node.getData()?.type;
listOperatorIds.push(id); if (['var-aggregator', 'list-operator', 'iteration'].includes(t)) {
deferredIds.push(id);
} else { } else {
processNodeVariables(node.getData(), node.getData().id, list, keys); processNodeVariables(node.getData(), node.getData().id, list, keys);
} }
}); });
listOperatorIds.forEach(id => { deferredIds.forEach(id => {
const node = nodes.find(n => n.id === id); const node = nodes.find(n => n.id === id);
if (node) processNodeVariables(node.getData(), node.getData().id, list, keys); if (node) processNodeVariables(node.getData(), node.getData().id, list, keys);
}); });