import { Link } from "@tanstack/react-router";
import { Markdown, Panel, RelativeTime, StatusDot } from "./ui/Primitives";
import { buttonClass } from "./ui/Button";
import { Breadcrumbs, RefSwitcher } from "./RefNavigation";
import { useLastCommits } from "~/hooks/use-last-commits";
import type { CommitSummary, StatusState, TreeEntry } from "~/lib/types";
import type { CommitBrief } from "~/lib/code-intel";
type Props = {
owner: string;
repo: string;
gitRef: { kind: string; name: string; sha: string };
path: string;
entries: TreeEntry[];
commit: CommitSummary;
commitStatus: StatusState | null;
readme: { path: string; html: string | null; text: string | null } | null;
branches: string[];
tags: string[];
canWrite: boolean;
};
function EntryCommit({ commit }: { commit: CommitBrief | null | undefined }) {
if (commit === undefined) return <span className="ml-auto h-3 w-24 animate-pulse rounded bg-gray-900" />;
if (commit === null) return null;
return (
<span className="ml-auto flex min-w-0 items-center gap-3 font-sans text-xs text-gray-500">
<span className="hidden max-w-md truncate md:inline">{commit.subject}</span>
<span className="shrink-0">
<RelativeTime timestamp={commit.committedAt} />
</span>
</span>
);
}
const ICONS: Record<TreeEntry["type"], string> = { tree: "▸", blob: "·", exec: "⚙", symlink: "↪", gitlink: "⊙" };
export function TreeView({
owner,
repo,