From 7f4b1fd19235fe4a7316e522ef79e5935fdb3af7 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Fri, 24 Oct 2025 17:07:45 -0700 Subject: [PATCH] fix(vfs): correct root entity selection when duplicates exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When multiple root directory entities exist, initializeRoot() was using the wrong field name to sort by creation time, causing it to select the NEWER root (no children) instead of the OLDER root (with children). Changed from metadata.createdAt (doesn't exist) to entity.createdAt (correct field). This ensures VFS correctly uses the root with all the Contains relationships. Fixes Workshop File Explorer showing 0 files despite 579 VFS entities being created during import. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/vfs/PathResolver.ts | 2 +- src/vfs/VirtualFileSystem.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vfs/PathResolver.ts b/src/vfs/PathResolver.ts index 3b49b1f1..4d8d3de5 100644 --- a/src/vfs/PathResolver.ts +++ b/src/vfs/PathResolver.ts @@ -232,7 +232,7 @@ export class PathResolver { includeVFS: true // v4.5.1: Required to see VFS relationships }) - const validChildren: VFSEntity[] = [] + const validChildren: VFSEntity[]= [] const childNames = new Set() // Fetch all child entities via relationships diff --git a/src/vfs/VirtualFileSystem.ts b/src/vfs/VirtualFileSystem.ts index 4069b94f..b127a529 100644 --- a/src/vfs/VirtualFileSystem.ts +++ b/src/vfs/VirtualFileSystem.ts @@ -177,9 +177,10 @@ export class VirtualFileSystem implements IVirtualFileSystem { console.warn(`⚠️ Found ${existing.length} root entities! Using first one, consider cleanup.`) // Sort by creation time - use oldest root (most likely to have children) + // v4.5.2: FIX - createdAt is at entity level, not metadata level! existing.sort((a, b) => { - const aTime = a.metadata?.createdAt || a.metadata?.modified || 0 - const bTime = b.metadata?.createdAt || b.metadata?.modified || 0 + const aTime = (a as any).createdAt || a.metadata?.modified || 0 + const bTime = (b as any).createdAt || b.metadata?.modified || 0 return aTime - bTime }) }