File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -550,17 +550,29 @@ export function registerCommands(
550550 }
551551 } ;
552552
553+ /**
554+ * Metadata passed from chat/agent sessions containing repository information.
555+ * This is provided by VS Code when commands are invoked from chat session toolbars.
556+ */
553557 interface SessionMetadata {
558+ /** GitHub repository owner/organization name */
554559 owner ?: string ;
560+ /** GitHub repository name */
555561 repo ?: string ;
556562 [ key : string ] : unknown ;
557563 }
558564
565+ /**
566+ * Get the folder manager for a repository based on metadata.
567+ * Falls back to the first folder manager if metadata is not provided or repository not found.
568+ * @param metadata Session metadata containing owner and repo information
569+ * @returns FolderRepositoryManager or undefined if no folder managers exist
570+ */
559571 function getFolderManagerFromMetadata ( metadata : SessionMetadata | undefined ) : FolderRepositoryManager | undefined {
560572 if ( metadata ?. owner && metadata ?. repo ) {
561573 return reposManager . getManagerForRepository ( metadata . owner , metadata . repo ) ?? reposManager . folderManagers [ 0 ] ;
562574 }
563- return reposManager . folderManagers [ 0 ] ;
575+ return reposManager . folderManagers . length > 0 ? reposManager . folderManagers [ 0 ] : undefined ;
564576 }
565577
566578 function contextHasPath ( ctx : OverviewContext | { path : string } | undefined ) : ctx is { path : string } {
You can’t perform that action at this time.
0 commit comments