"use client"; import { Folder, FolderPlus, Search, X } from "lucide-react"; import { useRef, useState } from "react"; import { Input } from "@/components/ui/input"; import { Separator } from "@/components/ui/separator"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { useDebouncedValue } from "@/hooks/use-debounced-value"; import { LocalFilesystemBrowser } from "./LocalFilesystemBrowser"; const getFolderDisplayName = (rootPath: string): string => rootPath.split(/[\\/]/).at(-1) || rootPath; interface DesktopLocalTabContentProps { localRootPaths: string[]; canAddMoreLocalRoots: boolean; maxLocalFilesystemRoots: number; searchSpaceId: number; onPickFilesystemRoot: () => Promise | void; onRemoveFilesystemRoot: (rootPath: string) => Promise | void; onClearFilesystemRoots: () => Promise | void; onOpenLocalFile: (localFilePath: string) => void; electronAvailable: boolean; } export function DesktopLocalTabContent({ localRootPaths, canAddMoreLocalRoots, maxLocalFilesystemRoots, searchSpaceId, onPickFilesystemRoot, onRemoveFilesystemRoot, onClearFilesystemRoots, onOpenLocalFile, electronAvailable, }: DesktopLocalTabContentProps) { const [localSearch, setLocalSearch] = useState(""); const debouncedLocalSearch = useDebouncedValue(localSearch, 250); const localSearchInputRef = useRef(null); return (
{localRootPaths.length > 0 ? ( Selected folders {localRootPaths.map((rootPath) => ( event.preventDefault()} className="group h-8 gap-1.5 px-1.5 text-sm text-foreground" > {getFolderDisplayName(rootPath)} ))} { void onClearFilesystemRoots(); }} > Clear all folders ) : (
No local folders selected
)} {electronAvailable ? ( {canAddMoreLocalRoots ? "Add folder" : `You can add up to ${maxLocalFilesystemRoots} folders`} ) : null}
setLocalSearch(e.target.value)} placeholder="Search local files" type="text" aria-label="Search local files" /> {Boolean(localSearch) && ( )}
); }