From ad7620770812d442c3ea5c6814231707f9607bfd Mon Sep 17 00:00:00 2001 From: Somil450 Date: Fri, 31 Jul 2026 14:59:12 +0530 Subject: [PATCH] fix: exclude test files from AI context window Closes #528 Test files (.test.*, .spec.*) can be very large and are rarely useful in the general AI context window for code generation and Chat. This commit excludes them in collectFilePaths(), saving tokens and improving context relevance. --- modules/playground/hooks/useAI.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/playground/hooks/useAI.ts b/modules/playground/hooks/useAI.ts index 8bbea5b1..7c6ace2d 100644 --- a/modules/playground/hooks/useAI.ts +++ b/modules/playground/hooks/useAI.ts @@ -151,7 +151,9 @@ export function collectFilePaths(items: FileSystemItem[], prefix = ""): string[] paths.push(...collectFilePaths(item.items, fp)); } else { const ext = item.fileExtension ? `.${item.fileExtension}` : ""; - paths.push(prefix ? `${prefix}/${item.filename}${ext}` : `${item.filename}${ext}`); + const fileName = `${item.filename}${ext}`; + if (fileName.includes(".test.") || fileName.includes(".spec.")) continue; + paths.push(prefix ? `${prefix}/${fileName}` : fileName); } } return paths;