fix(FileCommandLoader): Remove error logs if the operation was aborted (#12927)

Co-authored-by: Shnatu <snatu@google.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Shardul Natu
2025-11-12 08:33:28 -08:00
committed by GitHub
parent 570ccc7da0
commit 1ffb9c4188
2 changed files with 58 additions and 6 deletions
@@ -85,6 +85,10 @@ export class FileCommandLoader implements ICommandLoader {
* @returns A promise that resolves to an array of all loaded SlashCommands.
*/
async loadCommands(signal: AbortSignal): Promise<SlashCommand[]> {
if (this.folderTrustEnabled && !this.isTrustedFolder) {
return [];
}
const allCommands: SlashCommand[] = [];
const globOptions = {
nodir: true,
@@ -102,10 +106,6 @@ export class FileCommandLoader implements ICommandLoader {
cwd: dirInfo.path,
});
if (this.folderTrustEnabled && !this.isTrustedFolder) {
return [];
}
const commandPromises = files.map((file) =>
this.parseAndAdaptFile(
path.join(dirInfo.path, file),
@@ -122,7 +122,10 @@ export class FileCommandLoader implements ICommandLoader {
// Add all commands without deduplication
allCommands.push(...commands);
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
if (
!signal.aborted &&
(error as { code?: string })?.code !== 'ENOENT'
) {
console.error(
`[FileCommandLoader] Error loading commands from ${dirInfo.path}:`,
error,