Skip to content

Commit 3d3f71e

Browse files
Copilotalexr00
andcommitted
Add JSDoc comments and improve undefined handling
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 891548e commit 3d3f71e

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/commands.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff 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 } {

0 commit comments

Comments
 (0)