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