From 9f649ff3969edb44cfabd539ccf6d2c202bd2eb8 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Mon, 27 Oct 2025 08:02:01 -0700 Subject: [PATCH] fix(vfs): correct createdAt access in initializeRoot() - v4.5.3: Fix root selection when multiple roots exist - brain.find() returns Result[] which has entity.createdAt, not top-level createdAt - Changed from (a as any).createdAt to a.entity?.createdAt - Ensures oldest root is selected (most likely to have VFS files) - Fixes Workshop team bug where VFS files exist but readdir('/') returns empty Related: v4.5.2 tried to fix field name but accessed wrong object level --- src/vfs/VirtualFileSystem.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vfs/VirtualFileSystem.ts b/src/vfs/VirtualFileSystem.ts index b127a529..8a9ce6a1 100644 --- a/src/vfs/VirtualFileSystem.ts +++ b/src/vfs/VirtualFileSystem.ts @@ -177,10 +177,11 @@ 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! + // v4.5.3: FIX - createdAt is in entity object, not at Result level! + // brain.find() returns Result[], which has entity.createdAt, not top-level createdAt existing.sort((a, b) => { - const aTime = (a as any).createdAt || a.metadata?.modified || 0 - const bTime = (b as any).createdAt || b.metadata?.modified || 0 + const aTime = a.entity?.createdAt || a.metadata?.modified || 0 + const bTime = b.entity?.createdAt || b.metadata?.modified || 0 return aTime - bTime }) }