loop node dynamic height (#3092)

* loop node dynamic height

* fix

* fix
This commit is contained in:
heheer
2024-11-08 12:10:15 +08:00
committed by archer
parent 91645cc420
commit 8ede7add01
11 changed files with 176 additions and 118 deletions

View File

@@ -5,7 +5,7 @@ import { StoreNodeItemType } from '../type/node';
import { StoreEdgeItemType } from '../type/edge';
import { RuntimeEdgeItemType, RuntimeNodeItemType } from './type';
import { VARIABLE_NODE_ID } from '../constants';
import { isReferenceValue, isReferenceValueArray } from '../utils';
import { isReferenceValueFormat } from '../utils';
import { FlowNodeOutputItemType, ReferenceValueType } from '../type/io';
import { ChatItemType, NodeOutputItemType } from '../../../core/chat/type';
import { ChatItemValueTypeEnum, ChatRoleEnum } from '../../../core/chat/constants';
@@ -244,7 +244,7 @@ export const getReferenceVariableValue = ({
const nodeIds = nodes.map((node) => node.nodeId);
// handle single reference value
if (isReferenceValue(value, nodeIds)) {
if (isReferenceValueFormat(value)) {
const sourceNodeId = value[0];
const outputId = value[1];
@@ -261,7 +261,11 @@ export const getReferenceVariableValue = ({
}
// handle reference array
if (isReferenceValueArray(value, nodeIds)) {
if (
Array.isArray(value) &&
value.length > 0 &&
value.every((item) => isReferenceValueFormat(item))
) {
const result = value.map<any>((val) => {
return getReferenceVariableValue({
value: val,
@@ -270,7 +274,7 @@ export const getReferenceVariableValue = ({
});
});
return result.flat();
return result.flat().filter((item) => item !== undefined);
}
return value;

View File

@@ -111,7 +111,7 @@ export const Input_Template_Node_Height: FlowNodeInputItemType = {
renderTypeList: [FlowNodeInputTypeEnum.hidden],
valueType: WorkflowIOValueTypeEnum.number,
label: '',
value: 960
value: 600
};
export const Input_Template_Stream_MODE: FlowNodeInputItemType = {

View File

@@ -306,6 +306,15 @@ export const isReferenceValue = (value: any, nodeIds: string[]): value is [strin
const validIdSet = new Set([VARIABLE_NODE_ID, ...nodeIds]);
return validIdSet.has(value[0]);
};
export const isReferenceValueFormat = (value: any): value is [string, string] => {
return (
Array.isArray(value) &&
value.length === 2 &&
typeof value[0] === 'string' &&
typeof value[1] === 'string'
);
};
export const isReferenceValueArray = (
value: any,
nodeIds: string[]