debug: add comprehensive logging for merge groups functionality

Add debug logs to diagnose merge not working issue:

1. batchMergeGroups():
   - Log selected groupIds
   - Log mergeCandidateGroups count

2. executeMerge():
   - Log targetGroupId and targetGroup
   - Log targetTraceId type and value
   - Log targetTrace data
   - Log sourceGroups count
   - Log totalTraces and validTraces
   - Log each merge_trace API call params
   - Log success/fail counts

Purpose: Identify why merge fails when move works
Next: Check browser console for specific errors
This commit is contained in:
2026-07-25 13:24:45 +08:00
parent 69601fe512
commit 361a01a025

View File

@@ -1706,23 +1706,31 @@ async function batchMergeGroups() {
} }
const groupIds = Array.from(selectedGroups.value) const groupIds = Array.from(selectedGroups.value)
console.log('[batchMergeGroups] groupIds:', groupIds)
mergeCandidateGroups.value = clusterAsPending.value.filter((c: any) => groupIds.includes(c.identity_uuid)) mergeCandidateGroups.value = clusterAsPending.value.filter((c: any) => groupIds.includes(c.identity_uuid))
console.log('[batchMergeGroups] mergeCandidateGroups:', mergeCandidateGroups.value.length)
showMergeTargetModal.value = true showMergeTargetModal.value = true
} }
async function executeMerge(targetGroupId: string) { async function executeMerge(targetGroupId: string) {
console.log('[executeMerge] targetGroupId:', targetGroupId)
showMergeTargetModal.value = false showMergeTargetModal.value = false
const targetGroup = clusterAsPending.value.find((c: any) => c.identity_uuid === targetGroupId) const targetGroup = clusterAsPending.value.find((c: any) => c.identity_uuid === targetGroupId)
console.log('[executeMerge] targetGroup:', targetGroup)
if (!targetGroup) return if (!targetGroup) return
const targetTraceId = targetGroup.trace_ids?.[0] const targetTraceId = targetGroup.trace_ids?.[0]
console.log('[executeMerge] targetTraceId:', targetTraceId, typeof targetTraceId)
if (!targetTraceId) { if (!targetTraceId) {
alert('Target group has no traces') alert('Target group has no traces')
return return
} }
const targetTrace = clusterTracesMap.value[String(targetTraceId)] const targetTrace = clusterTracesMap.value[String(targetTraceId)]
console.log('[executeMerge] targetTrace:', targetTrace)
const targetFileUuid = targetTrace?.file_uuid const targetFileUuid = targetTrace?.file_uuid
if (!targetFileUuid) { if (!targetFileUuid) {
alert('Target trace has no file_uuid') alert('Target trace has no file_uuid')
@@ -1732,6 +1740,7 @@ async function executeMerge(targetGroupId: string) {
const groupIds = Array.from(selectedGroups.value) const groupIds = Array.from(selectedGroups.value)
const sourceGroupIds = groupIds.filter(id => id !== targetGroupId) const sourceGroupIds = groupIds.filter(id => id !== targetGroupId)
const sourceGroups = clusterAsPending.value.filter((c: any) => sourceGroupIds.includes(c.identity_uuid)) const sourceGroups = clusterAsPending.value.filter((c: any) => sourceGroupIds.includes(c.identity_uuid))
console.log('[executeMerge] sourceGroups:', sourceGroups.length)
let totalTraces = 0 let totalTraces = 0
let validTraces = 0 let validTraces = 0
@@ -1743,6 +1752,8 @@ async function executeMerge(targetGroupId: string) {
} }
} }
console.log('[executeMerge] totalTraces:', totalTraces, 'validTraces:', validTraces)
if (validTraces === 0) { if (validTraces === 0) {
alert('No valid traces to merge (all missing file_uuid)') alert('No valid traces to merge (all missing file_uuid)')
return return
@@ -1753,31 +1764,45 @@ async function executeMerge(targetGroupId: string) {
operationLoading.value = true operationLoading.value = true
operationMessage.value = `Merging ${validTraces} trace(s)...` operationMessage.value = `Merging ${validTraces} trace(s)...`
let successCount = 0
let failCount = 0
for (const g of sourceGroups) { for (const g of sourceGroups) {
for (const srcTraceId of g.trace_ids || []) { for (const srcTraceId of g.trace_ids || []) {
const srcTrace = clusterTracesMap.value[String(srcTraceId)] const srcTrace = clusterTracesMap.value[String(srcTraceId)]
const srcFileUuid = srcTrace?.file_uuid const srcFileUuid = srcTrace?.file_uuid
if (!srcFileUuid) { if (!srcFileUuid) {
console.warn('[merge] skipping trace without file_uuid:', srcTraceId) console.warn('[merge] skipping trace without file_uuid:', srcTraceId)
failCount++
continue continue
} }
if (srcFileUuid !== targetFileUuid) { if (srcFileUuid !== targetFileUuid) {
console.warn('[merge] skipping cross-file trace:', srcTraceId, srcFileUuid, '!=', targetFileUuid) console.warn('[merge] skipping cross-file trace:', srcTraceId, srcFileUuid, '!=', targetFileUuid)
failCount++
continue continue
} }
try { try {
console.log('[executeMerge] calling merge_trace:', {
file_uuid: srcFileUuid,
source_id: srcTraceId,
target_id: targetTraceId
})
await apiCall('merge_trace', { await apiCall('merge_trace', {
file_uuid: srcFileUuid, file_uuid: srcFileUuid,
source_id: srcTraceId, source_id: srcTraceId,
target_id: targetTraceId target_id: targetTraceId
}) })
successCount++
updateClusterAfterMerge(g.identity_uuid, targetGroupId) updateClusterAfterMerge(g.identity_uuid, targetGroupId)
} catch (e) { } catch (e) {
console.error('Merge trace failed:', srcTraceId, e) console.error('Merge trace failed:', srcTraceId, e)
failCount++
} }
} }
} }
console.log('[executeMerge] completed:', successCount, 'success,', failCount, 'failed')
operationLoading.value = false operationLoading.value = false
operationMessage.value = '' operationMessage.value = ''