fix: per-sheet column detection in Excel importer

CRITICAL FIX for Entity_* placeholder names in multi-sheet Excel imports

Root Cause:
- Column detection ran globally on first row of all combined sheets
- Different sheets have different column structures (Term vs Name, etc.)
- Concepts sheet: [Term, Definition] → detected 'Term' column 
- Characters sheet: [Name, Description] → looked for 'Term' column 
- Result: Characters/Places/Other fell back to Entity_* placeholders

Fix:
- Group rows by sheet (_sheet field)
- Detect columns per-sheet, not globally
- Each sheet now uses its own column mapping
- Characters/Places sheets now correctly find 'Name' column

Impact:
- Concepts: Still work (no change)
- Characters/Places/Other: NOW USE ACTUAL NAMES! 🎉

Also removed debug logging from v4.8.5 (performance overhead)

Fixes: Workshop File Explorer showing Entity_* instead of real names
Ref: BRAINY_V4.8.4_VFS_UNDEFINED_NAMES_BUG.md
This commit is contained in:
David Snelling 2025-10-28 14:30:31 -07:00
parent 14ffd3a477
commit 401443a4b0
4 changed files with 24 additions and 50 deletions

View file

@ -230,7 +230,6 @@ export class PathResolver {
from: dirId,
type: VerbType.Contains
})
console.log(`[DEBUG PathResolver] getChildren(${dirId}): Found ${relations.length} Contains relations`)
const validChildren: VFSEntity[]= []
const childNames = new Set<string>()
@ -238,24 +237,12 @@ export class PathResolver {
// Fetch all child entities via relationships
for (const relation of relations) {
const entity = await this.brain.get(relation.to)
console.log(`[DEBUG PathResolver] Retrieved entity ${relation.to}:`, {
exists: !!entity,
type: entity?.type,
hasMetadata: !!entity?.metadata,
metadataKeys: entity?.metadata ? Object.keys(entity.metadata) : [],
metadata_vfsType: entity?.metadata?.vfsType,
metadata_name: entity?.metadata?.name
})
if (entity && entity.metadata?.vfsType && entity.metadata?.name) {
validChildren.push(entity as VFSEntity)
childNames.add(entity.metadata.name)
} else {
console.log(`[DEBUG PathResolver] ❌ FILTERED OUT entity ${relation.to} - missing vfsType or name`)
}
}
console.log(`[DEBUG PathResolver] Returning ${validChildren.length} valid children (filtered from ${relations.length})`)
// Update cache
this.parentCache.set(dirId, childNames)
return validChildren