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