Compare commits

...

2 Commits

Author SHA1 Message Date
c235d11d03 fix: handle empty groups after merge operation
Problem:
- After merge, source groups become empty
- Empty groups stay in UI as garbage data
- User sees empty groups with 0 faces

Solution:
- updateClusterAfterMerge() now removes source groups after merge
- Added removal from clusterAsPending computed property
- Ensures clean UI after merge operation

Behavior:
- Source group is deleted after all members merged to target
- Target group receives all members
- No empty groups left in UI

Related: merge functionality debug logging added in previous commit
2026-07-25 13:25:16 +08:00
361a01a025 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
2026-07-25 13:24:45 +08:00

View File

@@ -1611,9 +1611,15 @@ function updateClusterAfterMerge(sourceGroupId: string, targetGroupId: string) {
const idx = clusters.findIndex((c: any) => c.identity_uuid === sourceGroupId)
if (idx >= 0) {
clusters.splice(idx, 1)
clusters.splice(idx, 1) // ← Remove empty source group
}
}
// Also remove from clusterAsPending computed
const idx2 = clusterAsPending.value.findIndex((c: any) => c.identity_uuid === sourceGroupId)
if (idx2 >= 0) {
clusterAsPending.value.splice(idx2, 1)
}
}
async function batchDeleteFaces() {
@@ -1706,23 +1712,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 +1746,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 +1758,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 +1770,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 = ''