Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

chore: not use step_boundary field (#7231)

Joel9381c08c4365
diff --git a/web/app/components/workflow/run/index.tsx b/web/app/components/workflow/run/index.tsx
index 8b9981346bc..702ce06e1ce 100644
--- a/web/app/components/workflow/run/index.tsx
+++ b/web/app/components/workflow/run/index.tsx
@@ -63,30 +63,25 @@ const RunPanel: FC<RunProps> = ({ hideResult, activeTab = 'RESULT', runID, getRe
const formatNodeList = useCallback((list: NodeTracing[]) => {
const allItems = list.reverse()
const result: NodeTracing[] = []
- let iterationIndexInfos: {
- start: number
- end: number
- }[] = []
+ let iterationIndex = 0
allItems.forEach((item) => {
- const { node_type, index, execution_metadata } = item
+ const { node_type, execution_metadata } = item
if (node_type !== BlockEnum.Iteration) {
- let isInIteration = false
- let isIterationFirstNode = false
- iterationIndexInfos.forEach(({ start, end }) => {
- if (index >= start && index < end) {
- if (index === start)
- isIterationFirstNode = true
+ const isInIteration = !!execution_metadata?.iteration_id
- isInIteration = true
- }
- })
if (isInIteration) {
const iterationDetails = result[result.length - 1].details!
- if (isIterationFirstNode)
+ const currentIterationIndex = execution_metadata?.iteration_index
+ const isIterationFirstNode = iterationIndex !== currentIterationIndex || iterationDetails.length === 0
+
+ if (isIterationFirstNode) {
iterationDetails!.push([item])
+ iterationIndex = currentIterationIndex!
+ }
- else
+ else {
iterationDetails[iterationDetails.length - 1].push(item)
+ }
return
}
@@ -96,26 +91,6 @@ const RunPanel: FC<RunProps> = ({ hideResult, activeTab = 'RESULT', runID, getRe
return
}
- const { steps_boundary } = execution_metadata
- iterationIndexInfos = []
- steps_boundary.forEach((boundary, index) => {
- if (index === 0) {
- iterationIndexInfos.push({
- start: boundary,
- end: 0,
- })
- }
- else if (index === steps_boundary.length - 1) {
- iterationIndexInfos[iterationIndexInfos.length - 1].end = boundary
- }
- else {
- iterationIndexInfos[iterationIndexInfos.length - 1].end = boundary
- iterationIndexInfos.push({
- start: boundary,
- end: 0,
- })
- }
- })
result.push({
...item,
details: [],
diff --git a/web/app/components/workflow/run/node.tsx b/web/app/components/workflow/run/node.tsx
index f5df961d21e..f0f7ec51732 100644
--- a/web/app/components/workflow/run/node.tsx
+++ b/web/app/components/workflow/run/node.tsx
@@ -123,7 +123,7 @@ const NodePanel: FC<Props> = ({
<div
className='flex items-center h-[34px] justify-between px-3 bg-gray-100 border-[0.5px] border-gray-200 rounded-lg cursor-pointer'
onClick={handleOnShowIterationDetail}>
- <div className='leading-[18px] text-[13px] font-medium text-gray-700'>{t('workflow.nodes.iteration.iteration', { count: nodeInfo.metadata?.iterator_length || (nodeInfo.execution_metadata?.steps_boundary?.length - 1) })}</div>
+ <div className='leading-[18px] text-[13px] font-medium text-gray-700'>{t('workflow.nodes.iteration.iteration', { count: nodeInfo.metadata?.iterator_length })}</div>
{justShowIterationNavArrow
? (
<RiArrowRightSLine className='w-3.5 h-3.5 text-gray-500' />
diff --git a/web/types/workflow.ts b/web/types/workflow.ts
index 72475ce55c5..f7991bc4e09 100644
--- a/web/types/workflow.ts
+++ b/web/types/workflow.ts
@@ -24,7 +24,8 @@ export type NodeTracing = {
total_tokens: number
total_price: number
currency: string
- steps_boundary: number[]
+ iteration_id?: string
+ iteration_index?: number
}
metadata: {
iterator_length: number