diff --git a/web/app/components/workflow/run/utils/format-log/agent/data.ts b/web/app/components/workflow/run/utils/format-log/agent/data.ts index a159fc2832..9ffac8ec45 100644 --- a/web/app/components/workflow/run/utils/format-log/agent/data.ts +++ b/web/app/components/workflow/run/utils/format-log/agent/data.ts @@ -133,14 +133,14 @@ export const multiStepsCircle = (() => { { id: '2', parent_id: '1', label: 'Node 2' }, { id: '3', parent_id: '1', label: 'Node 3' }, { id: '4', parent_id: '2', label: 'Node 4' }, + // Loop - { id: '1', parent_id: '1', label: 'Node 1' }, + { id: '1', parent_id: '4', label: 'Node 1' }, + { id: '2', parent_id: '1', label: 'Node 2' }, + { id: '4', parent_id: '2', label: 'Node 4' }, + { id: '1', parent_id: '4', label: 'Node 1' }, { id: '2', parent_id: '1', label: 'Node 2' }, { id: '4', parent_id: '2', label: 'Node 4' }, - // { id: '1', parent_id: '1', label: 'Node 1' }, - // { id: '2', parent_id: '1', label: 'Node 2' }, - // { id: '4', parent_id: '2', label: 'Node 4' }, - ], }, } diff --git a/web/app/components/workflow/run/utils/format-log/agent/index.spec.ts b/web/app/components/workflow/run/utils/format-log/agent/index.spec.ts index e211744bbe..2cd61e99e4 100644 --- a/web/app/components/workflow/run/utils/format-log/agent/index.spec.ts +++ b/web/app/components/workflow/run/utils/format-log/agent/index.spec.ts @@ -10,8 +10,7 @@ describe('agent', () => { test('list should remove circle log item', () => { // format(oneStepCircle.in as any) - console.log(JSON.stringify(format(multiStepsCircle.in as any)[0].agentLog)) - // expect(format(oneStepCircle.in as any)).toEqual(oneStepCircle.expect) - // expect(format(multiStepsCircle.in as any)).toEqual(multiStepsCircle.expect) + expect(format(oneStepCircle.in as any)).toEqual(oneStepCircle.expect) + expect(format(multiStepsCircle.in as any)).toEqual(multiStepsCircle.expect) }) }) diff --git a/web/app/components/workflow/run/utils/format-log/agent/index.ts b/web/app/components/workflow/run/utils/format-log/agent/index.ts index 8d95c76f24..65c7f6d36e 100644 --- a/web/app/components/workflow/run/utils/format-log/agent/index.ts +++ b/web/app/components/workflow/run/utils/format-log/agent/index.ts @@ -19,8 +19,24 @@ const remove = (node: AgentLogItemWithChildren, removeId: string) => { }) } +const removeRepeatedSiblings = (list: AgentLogItemWithChildren[]) => { + if (!list || list.length === 0) { + return [] + } + const result: AgentLogItemWithChildren[] = [] + const addedItemIds: string[] = [] + list.forEach((item) => { + if (!addedItemIds.includes(item.id)) { + result.push(item) + addedItemIds.push(item.id) + } + }) + return result +} + const removeCircleLogItem = (log: AgentLogItemWithChildren) => { let newLog = cloneDeep(log) + newLog.children = removeRepeatedSiblings(newLog.children) let { id, children } = newLog if (!children || children.length === 0) { return log @@ -31,6 +47,7 @@ const removeCircleLogItem = (log: AgentLogItemWithChildren) => { newLog.hasCircle = true newLog.children = newLog.children.filter(c => c.id !== id) children = newLog.children + } children.forEach((child, index) => {