Revert "fix: match cluster custom names by both cluster_id and name keys"

This reverts commit 1f3bb31b2d.
This commit is contained in:
2026-11-01 14:40:58 +08:00
parent 2949a665f3
commit 09b6ca6fc8

View File

@@ -382,10 +382,8 @@ export function setClusterResults(fileUuid: string, results: any[]) {
const savedCache = JSON.parse(saved) const savedCache = JSON.parse(saved)
const existing = savedCache[fileUuid] || [] const existing = savedCache[fileUuid] || []
for (const r of existing) { for (const r of existing) {
// Use cluster_id as key (can be integer or string like "Person_0") if (r.cluster_id && r.name && !r.name.startsWith('Person_') && !r.name.startsWith('Trace ') && !r.name.startsWith('Face Trace ')) {
const key = r.cluster_id ?? r.name existingNames[r.cluster_id] = r.name
if (key && r.name && !r.name.startsWith('Person_') && !r.name.startsWith('Trace ') && !r.name.startsWith('Face Trace ')) {
existingNames[String(key)] = r.name
} }
} }
console.log('[setClusterResults] Loaded custom names from localStorage:', existingNames) console.log('[setClusterResults] Loaded custom names from localStorage:', existingNames)
@@ -397,13 +395,10 @@ export function setClusterResults(fileUuid: string, results: any[]) {
// Create new objects to trigger Vue reactivity // Create new objects to trigger Vue reactivity
const newResults = results.map(r => { const newResults = results.map(r => {
const newR = { ...r, trace_ids: [...(r.trace_ids || [])] } const newR = { ...r, trace_ids: [...(r.trace_ids || [])] }
// Apply custom names - try matching by cluster_id first, then by original name // Apply custom names to new results
const cidKey = String(r.cluster_id ?? '') if (r.cluster_id && existingNames[r.cluster_id]) {
const nameKey = r.name || '' newR.name = existingNames[r.cluster_id]
const customName = existingNames[cidKey] || existingNames[nameKey] console.log('[setClusterResults] Applied custom name:', existingNames[r.cluster_id], 'for cluster:', r.cluster_id)
if (customName) {
newR.name = customName
console.log('[setClusterResults] Applied custom name:', customName, 'for cluster:', r.cluster_id, '(name:', r.name, ')')
} }
return newR return newR
}) })