"use client"; import { useState } from "react"; import { IconChevronDown, IconChevronRight, IconGitPullRequest } from "@tabler/icons-react"; import { LineStat } from "@/components/diff-stat"; import { cn } from "@/lib/utils"; import { useDockviewStore } from "@/lib/state/dockview-store"; import { FileStatusIcon } from "./file-status-icon"; import { groupByRepositoryName } from "@/lib/group-by-repo"; import type { PRChangedFile } from "./changes-panel-timeline"; import type { OpenDiffOptions } from "./changes-diff-target"; type PRFilesSectionContentProps = { files: PRChangedFile[]; onOpenDiff: (path: string, options?: OpenDiffOptions) => void; /** Maps a repository_name to a human-readable label for the per-repo header. */ repoDisplayName?: (repositoryName: string) => string | undefined; }; /** * Body of the PR Changes section: groups files by `repository_name` so * multi-repo tasks render one sub-header per repo, mirroring the Commits * and Changes sections. Single-repo tasks (one group with empty name) * render the file list flat — the section header is enough. */ export function PRFilesGroupedList({ files, onOpenDiff, repoDisplayName, }: PRFilesSectionContentProps) { const activeFilePath = useDockviewStore((s) => s.activeFilePath); const groups = groupByRepositoryName(files, (f) => f.repository_name); const showRepoHeaders = groups.length > 1 || (groups[0]?.repositoryName ?? "") !== ""; return (