setQuery(e.target.value)}
onKeyDown={handleKeyDown}
onFocus={() => { if (results.length > 0) {setOpen(true);} }}
placeholder="Search files..."
className="w-full pl-8 pr-3 py-1.5 rounded-lg text-xs outline-none transition-colors"
style={{
background: "var(--color-bg)",
color: "var(--color-text)",
border: "1px solid var(--color-border)",
}}
/>
{loading && (
)}
{open && results.length > 0 && (
{results.map((item, i) => (
))}
)}
{open && query.trim() && !loading && results.length === 0 && (
)}
);
}
/** Extract the directory name from an absolute path for display. */
function dirDisplayName(dir: string): string {
if (dir === "/") {return "/";}
return dir.split("/").pop() || dir;
}
export function WorkspaceSidebar({
tree,
activePath,
onSelect,
onRefresh,
orgName,
loading,
browseDir,
parentDir,
onNavigateUp,
onGoHome,
onFileSearchSelect,
workspaceRoot,
onGoToChat,
onExternalDrop,
mobile,
onClose,
activeProfile,
onProfileSwitch,
showHidden,
onToggleHidden,
width: widthProp,
onCollapse,
}: WorkspaceSidebarProps) {
const isBrowsing = browseDir != null;
const [showCreateWorkspace, setShowCreateWorkspace] = useState(false);
const width = mobile ? "280px" : (widthProp ?? 260);
const sidebar = (
void onClose?.()}>
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
e.stopPropagation()} className="fixed inset-y-0 left-0 z-50">
{sidebar}
);
}