@@ -111,6 +111,7 @@ export class CollectionReader {
111111 const documents : ExtractedDocument [ ] = [ ]
112112 let skippedNoFolder = 0
113113 let skippedWrongFolder = 0
114+ const wrongFolderSamples : string [ ] = [ ] // Log first few for debugging
114115
115116 for ( const actor of game . actors . values ( ) ) {
116117 if ( ! actor . folder ) {
@@ -119,6 +120,9 @@ export class CollectionReader {
119120 }
120121 if ( ! allFolderIds . includes ( actor . folder . id ) ) {
121122 skippedWrongFolder ++
123+ if ( wrongFolderSamples . length < 5 ) {
124+ wrongFolderSamples . push ( `"${ actor . name } " in folder "${ actor . folder . name } " (${ actor . folder . id } )` )
125+ }
122126 continue
123127 }
124128
@@ -145,6 +149,9 @@ export class CollectionReader {
145149 console . log (
146150 `FoundryAI | getActorsByFolders: found ${ documents . length } actors, skipped ${ skippedNoFolder } (no folder), ${ skippedWrongFolder } (wrong folder)` ,
147151 )
152+ if ( wrongFolderSamples . length > 0 ) {
153+ console . log ( `FoundryAI | getActorsByFolders: sample skipped actors:` , wrongFolderSamples )
154+ }
148155
149156 return documents
150157 }
@@ -483,9 +490,22 @@ export class CollectionReader {
483490
484491 const result = new Set < string > ( folderIds )
485492
493+ // Debug: log all folders and their parents
494+ console . log ( `FoundryAI | resolveWithChildren: input IDs:` , folderIds )
495+ console . log ( `FoundryAI | resolveWithChildren: total folders in game:` , game . folders . size )
496+
497+ // Log parent relationships for debugging
498+ for ( const id of folderIds ) {
499+ const parentFolder = game . folders . get ( id )
500+ if ( parentFolder ) {
501+ console . log ( `FoundryAI | resolveWithChildren: selected folder "${ parentFolder . name } " (${ id } ), type=${ parentFolder . type } ` )
502+ }
503+ }
504+
486505 const addChildren = ( parentId : string ) => {
487506 for ( const folder of game . folders . values ( ) ) {
488507 if ( folder . parent ?. id === parentId && ! result . has ( folder . id ) ) {
508+ console . log ( `FoundryAI | resolveWithChildren: found child "${ folder . name } " (${ folder . id } ) of parent ${ parentId } ` )
489509 result . add ( folder . id )
490510 addChildren ( folder . id ) // Recurse
491511 }
@@ -496,6 +516,8 @@ export class CollectionReader {
496516 addChildren ( id )
497517 }
498518
519+ console . log ( `FoundryAI | resolveWithChildren: resolved to ${ result . size } folders:` , Array . from ( result ) )
520+
499521 return Array . from ( result )
500522 }
501523
0 commit comments