From b13080e5dc6b9a4d55ce76d1e83cfa9fbe6e1398 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Fri, 24 Oct 2025 01:33:40 +0100 Subject: [PATCH] Filter out directories from file picker, show only files - Filter git files ending with / (directories) - Filter search results ending with / (directories) - Only show actual files in file picker - Directories cannot be attached as files --- src/components/file-picker.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/file-picker.tsx b/src/components/file-picker.tsx index 5c9d8c5a..aee138eb 100644 --- a/src/components/file-picker.tsx +++ b/src/components/file-picker.tsx @@ -48,12 +48,14 @@ const FilePicker: Component = (props) => { console.log(`[FilePicker] Git files response received in ${elapsed}ms:`, gitResponse) if (gitResponse?.data && gitResponse.data.length > 0) { - const gitFiles: FileItem[] = gitResponse.data.map((file: any) => ({ - path: file.path, - added: file.added, - removed: file.removed, - isGitFile: true, - })) + const gitFiles: FileItem[] = gitResponse.data + .filter((file: any) => !file.path.endsWith("/")) + .map((file: any) => ({ + path: file.path, + added: file.added, + removed: file.removed, + isGitFile: true, + })) console.log(`[FilePicker] Cached ${gitFiles.length} git files`) setCachedGitFiles(gitFiles) } else { @@ -91,6 +93,7 @@ const FilePicker: Component = (props) => { console.log(`[FilePicker] Search response received in ${elapsed}ms:`, searchResponse) searchFiles = (searchResponse?.data || []) + .filter((path: string) => !path.endsWith("/")) .filter((path: string) => !gitFiles.some((gf) => gf.path === path)) .map((path: string) => ({ path, @@ -106,6 +109,7 @@ const FilePicker: Component = (props) => { console.log(`[FilePicker] All files response received in ${elapsed}ms:`, searchResponse) searchFiles = (searchResponse?.data || []) + .filter((path: string) => !path.endsWith("/")) .filter((path: string) => !gitFiles.some((gf) => gf.path === path)) .map((path: string) => ({ path,