import { useEffect } from "react"; import type { Project } from "../../../lib/types"; import { useFileManager } from "../../../hooks/useFileManager"; import Button from "../../ui/Button"; import { formatBytes } from "./format"; interface Props { project: Project; } /** The old 42rem FileManager popup, now a main-area section. */ export default function FilesTab({ project }: Props) { const { currentPath, entries, loading, error, navigate, goUp, refresh, downloadFile, uploadFile, } = useFileManager(project.id); const running = project.status === "running"; useEffect(() => { if (running) navigate("/workspace"); // Re-list when the container comes up. }, [navigate, running]); const breadcrumbs = currentPath === "/" ? [{ label: "/", path: "/" }] : currentPath .split("/") .reduce<{ label: string; path: string }[]>((acc, part, i) => { if (i === 0) { acc.push({ label: "/", path: "/" }); } else if (part) { const parentPath = acc[acc.length - 1].path; const fullPath = parentPath === "/" ? `/${part}` : `${parentPath}/${part}`; acc.push({ label: part, path: fullPath }); } return acc; }, []); if (!running) { return (

Start the container to browse its files.

); } return (
{error && (
{error}
)} {loading && entries.length === 0 ? (
Loading…
) : ( {currentPath !== "/" && ( )} {entries.map((entry) => ( entry.is_directory && navigate(entry.path)} className={`${ entry.is_directory ? "cursor-pointer" : "" } hover:bg-[var(--bg-tertiary)] transition-colors`} > ))} {entries.length === 0 && !loading && ( )}
..
{entry.is_directory ? "📁 " : ""} {entry.name} {!entry.is_directory && formatBytes(entry.size)} {entry.modified} {!entry.is_directory && ( )}
Empty directory
)}
); }