fix: batchDeleteGroups should ungroup (rename to Unassigned), not hard delete

Changed from apiCall('delete_trace', ...) to updateTraceProfileGroup(name='Unassigned').
This preserves all trace data and just removes the group assignment.
Traces move back to Pending Faces instead of being deleted.
This commit is contained in:
2026-08-01 05:40:46 +08:00
parent adc8d944c6
commit 1c0f15664e

View File

@@ -1698,39 +1698,33 @@ async function batchDeleteGroups() {
allTraceIds.push(...(g.trace_ids || [])) allTraceIds.push(...(g.trace_ids || []))
} }
if (!confirm(`Delete ${groupsToDelete.length} group(s) with ${totalTraces} trace(s)?`)) return if (!confirm(`Ungroup ${groupsToDelete.length} group(s) with ${totalTraces} trace(s)?\n\nTraces will be renamed to "Unassigned", not deleted.`)) return
operationLoading.value = true operationLoading.value = true
operationMessage.value = `Deleting ${totalTraces} trace(s)...` operationMessage.value = `Ungrouping ${totalTraces} trace(s)...`
lastDeletedTraces.value = []
for (const g of groupsToDelete) { for (const g of groupsToDelete) {
const traceIds = g.trace_ids || [] const traceIds = g.trace_ids || []
for (const tid of traceIds) { if (!traceIds.length) continue
const trace = clusterTracesMap.value[String(tid)] const fileUuid = g.rep_trace?.file_uuid || selectedFileUuid.value
const fileUuid = trace?.file_uuid if (!fileUuid) continue
console.log('[batchDeleteGroups] trace_id:', tid, 'trace:', trace, 'fileUuid:', fileUuid) try {
if (!fileUuid) { await updateTraceProfileGroup(fileUuid, traceIds, { name: 'Unassigned' })
console.error('[batchDeleteGroups] Missing file_uuid for trace:', tid) } catch (e) {
continue console.error('Ungroup failed:', g.name, e)
}
try {
await apiCall('delete_trace', { file_uuid: fileUuid, trace_id: tid })
lastDeletedTraces.value.push({ file_uuid: fileUuid, trace_id: tid })
console.log('[batchDeleteGroups] Deleted trace:', tid)
} catch (e) {
console.error('Delete trace failed:', tid, e)
}
} }
} }
removeTracesFromClusterCache(allTraceIds) // Remove ungrouped traces from cluster cache so they show in Pending Faces
for (const tid of allTraceIds) {
delete clusterTracesMap.value[String(tid)]
}
operationLoading.value = false operationLoading.value = false
operationMessage.value = '' operationMessage.value = ''
clearSelection() clearSelection()
showUndoBannerWithTimer() await loadClusterResults()
} }
async function batchMergeGroups() { async function batchMergeGroups() {