diff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.ts index e8ce744236..4cde06ed2b 100644 --- a/web/app/components/base/chat/chat/hooks.ts +++ b/web/app/components/base/chat/chat/hooks.ts @@ -957,6 +957,7 @@ export const useChat = ( }) }, onNodeStarted: ({ data: nodeStartedData }) => { + // `data` is the outer send payload for this request; loop child runs should not emit top-level node traces here. if (data.loop_id) return @@ -977,6 +978,7 @@ export const useChat = ( }) }, onNodeFinished: ({ data: nodeFinishedData }) => { + // Use the outer request payload here as well so loop child runs skip top-level finish handling entirely. if (data.loop_id) return diff --git a/web/app/components/share/text-generation/result/index.tsx b/web/app/components/share/text-generation/result/index.tsx index e3ffe9d209..a11e7436b5 100644 --- a/web/app/components/share/text-generation/result/index.tsx +++ b/web/app/components/share/text-generation/result/index.tsx @@ -337,7 +337,7 @@ const Result: FC = ({ onIterationFinish: ({ data }) => { setWorkflowProcessData(produce(getWorkflowProcessData()!, (draft) => { draft.expand = true - const iterationsIndex = draft.tracing.findIndex(item => item.id === data.id)! + const iterationsIndex = draft.tracing.findIndex(item => item.id === data.id) if (iterationsIndex > -1) { draft.tracing[iterationsIndex] = { ...data, @@ -367,7 +367,7 @@ const Result: FC = ({ onLoopFinish: ({ data }) => { setWorkflowProcessData(produce(getWorkflowProcessData()!, (draft) => { draft.expand = true - const loopsIndex = draft.tracing.findIndex(item => item.id === data.id)! + const loopsIndex = draft.tracing.findIndex(item => item.id === data.id) if (loopsIndex > -1) { draft.tracing[loopsIndex] = { ...data, diff --git a/web/app/components/workflow/utils/top-level-tracing.ts b/web/app/components/workflow/utils/top-level-tracing.ts index 564812b105..30e0b5c8f6 100644 --- a/web/app/components/workflow/utils/top-level-tracing.ts +++ b/web/app/components/workflow/utils/top-level-tracing.ts @@ -15,6 +15,7 @@ export const upsertTopLevelTracingNodeOnStart = ( ? tracing.findIndex(item => item.id === startedNode.id) : tracing.findIndex(item => item.node_id === startedNode.node_id) if (currentIndex > -1) + // Started events are the authoritative snapshot for an execution; merging would retain stale client-side fields. tracing[currentIndex] = startedNode else tracing.push(startedNode)