mirror of
https://github.com/langgenius/dify.git
synced 2026-04-11 06:00:28 -04:00
fix: scope top-level trace reuse to debug preview
This commit is contained in:
@@ -518,6 +518,8 @@ export const useChat = (
|
||||
upsertTopLevelTracingNodeOnStart(responseItem.workflowProcess!.tracing!, {
|
||||
...data,
|
||||
status: NodeRunningStatus.Running,
|
||||
}, {
|
||||
reuseRunningNodeId: true,
|
||||
})
|
||||
updateCurrentQAOnTree({
|
||||
placeholderQuestionId,
|
||||
@@ -807,6 +809,8 @@ export const useChat = (
|
||||
upsertTopLevelTracingNodeOnStart(responseItem.workflowProcess.tracing, {
|
||||
...nodeStartedData,
|
||||
status: NodeRunningStatus.Running,
|
||||
}, {
|
||||
reuseRunningNodeId: true,
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
@@ -105,12 +105,33 @@ describe('upsertTopLevelTracingNodeOnStart', () => {
|
||||
status: NodeRunningStatus.Running,
|
||||
})
|
||||
|
||||
const updated = upsertTopLevelTracingNodeOnStart(tracing, startedNode)
|
||||
const updated = upsertTopLevelTracingNodeOnStart(tracing, startedNode, {
|
||||
reuseRunningNodeId: true,
|
||||
})
|
||||
|
||||
expect(updated).toBe(true)
|
||||
expect(tracing).toEqual([startedNode])
|
||||
})
|
||||
|
||||
it('should keep separate running top-level traces by default when a new execution id appears', () => {
|
||||
const existingTrace = createTrace({
|
||||
id: 'trace-1',
|
||||
node_id: 'node-1',
|
||||
status: NodeRunningStatus.Running,
|
||||
})
|
||||
const tracing: NodeTracing[] = [existingTrace]
|
||||
const startedNode = createTrace({
|
||||
id: 'trace-2',
|
||||
node_id: 'node-1',
|
||||
status: NodeRunningStatus.Running,
|
||||
})
|
||||
|
||||
const updated = upsertTopLevelTracingNodeOnStart(tracing, startedNode)
|
||||
|
||||
expect(updated).toBe(true)
|
||||
expect(tracing).toEqual([existingTrace, startedNode])
|
||||
})
|
||||
|
||||
it('should ignore nested iteration node starts even when the node id matches a top-level trace', () => {
|
||||
const existingTrace = createTrace({
|
||||
id: 'top-level-trace',
|
||||
|
||||
@@ -8,6 +8,9 @@ const isNestedTracingNode = (trace: Pick<NodeTracing, 'iteration_id' | 'loop_id'
|
||||
export const upsertTopLevelTracingNodeOnStart = (
|
||||
tracing: NodeTracing[],
|
||||
startedNode: NodeTracing,
|
||||
options?: {
|
||||
reuseRunningNodeId?: boolean
|
||||
},
|
||||
) => {
|
||||
if (isNestedTracingNode(startedNode))
|
||||
return false
|
||||
@@ -16,6 +19,9 @@ export const upsertTopLevelTracingNodeOnStart = (
|
||||
if (item.id === startedNode.id)
|
||||
return true
|
||||
|
||||
if (!options?.reuseRunningNodeId)
|
||||
return false
|
||||
|
||||
return item.node_id === startedNode.node_id && item.status === NodeRunningStatus.Running
|
||||
})
|
||||
if (currentIndex > -1)
|
||||
|
||||
Reference in New Issue
Block a user