import H2 from "@moduletrace/twui/layout/H2"; import Row from "@moduletrace/twui/layout/Row"; import Span from "@moduletrace/twui/layout/Span"; import Stack from "@moduletrace/twui/layout/Stack"; import type { StorageFolderPayload, StorageSpecOption } from "@/src/types"; import type { StorageSpec } from "@/src/utils/storage-volumes"; import FilesBreadcrumbRow from "../(partials)/files-breadcrumb-row"; import FilesSearchInput from "../(partials)/files-search-input"; import FilesVolumeRow from "../(partials)/files-volume-row"; import StorageEntryRow from "../(partials)/storage-entry-row"; import Divider from "@moduletrace/twui/layout/Divider"; import Paper from "@moduletrace/twui/elements/Paper"; type Props = { folders: StorageSpecOption[]; folder: StorageFolderPayload | null; spec: StorageSpec | null; path: string; search: string; loading?: boolean; error?: string; onSearch: (search: string) => void; onSubmitSearch: () => void; onOpenFolder: (path: string) => void; onOpenVolume: (option: StorageSpecOption) => void; }; /** * The files browser: the folders the user reaches on the left, the open * folder's entries on the right. Read-only: a bot changes its own files * with its tools, and the chat's files modal can delete them. */ export default function FilesBrowser({ folders, folder, spec, path, search, loading, error, onSearch, onSubmitSearch, onOpenFolder, onOpenVolume, }: Props) { return (

Folders

{folders.length ? ( folders.map((option) => ( onOpenVolume(option)} /> )) ) : ( Nothing to show yet: give a bot a file, or let one work on a computer. )}

{folder?.breadcrumbs.at(-1)?.name || folder?.label || "Files"}

{folder ? `${folder.label}: ${folder.total} item(s). Everything a bot, a workspace or a computer keeps for you.` : "Pick a folder to look inside."}
{folder?.entries.length ? ( folder.entries.map((entry) => ( )) ) : ( {loading ? "Loading..." : error || (search ? `Nothing matches "${search}".` : "This folder is empty.")} )}
); }