Allow folders in file picker and use them as search filters
- Remove directory filtering from file picker - When folder selected, insert folder path into input (not as attachment) - Folder path becomes search query to filter files in that folder - Files still create attachments as before - User can navigate folder structure using @ mentions
This commit is contained in:
@@ -48,14 +48,12 @@ const FilePicker: Component<FilePickerProps> = (props) => {
|
||||
console.log(`[FilePicker] Git files response received in ${elapsed}ms:`, gitResponse)
|
||||
|
||||
if (gitResponse?.data && gitResponse.data.length > 0) {
|
||||
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,
|
||||
}))
|
||||
const gitFiles: FileItem[] = gitResponse.data.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 {
|
||||
@@ -93,23 +91,21 @@ const FilePicker: Component<FilePickerProps> = (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,
|
||||
isGitFile: false,
|
||||
}))
|
||||
} else {
|
||||
console.log(`[FilePicker] Empty query, fetching all files with wildcard`)
|
||||
console.log(`[FilePicker] Empty query, fetching all files`)
|
||||
const searchResponse = await props.instanceClient.find.files({
|
||||
query: { query: "." },
|
||||
query: { query: "" },
|
||||
})
|
||||
const elapsed = Date.now() - startTime
|
||||
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user