2781556ead
* perf(backend): cap cumulative diff bytes and file count during large rebases * perf(web): coalesce cumulative-diff refetches and skip redundant status compares * feat(web): warn when the changes panel hides files from a capped diff * fix(backend): enforce cumulative diff total byte budget strictly * fix(web): keep coalesced refetch timer shared across envKey subscribers * fix(web): drop unsound git-status SHA fast-path that staled live diffs * fix(web): cancel coalesced timer on mid-flight drain to avoid duplicate refetch * refactor(web): move changes-panel banner and helper to a sibling file * docs(backend): clarify cumulative diff truncated-files-count semantics * fix(web): tighten useSelectedFileKey mode param to the all|file union
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { useMemo } from "react";
|
|
import { IconAlertTriangle } from "@tabler/icons-react";
|
|
import { reviewFileKey } from "@/components/review/types";
|
|
|
|
/** Composite key for the file currently selected in single-file mode. */
|
|
export function useSelectedFileKey(
|
|
mode: "all" | "file",
|
|
filePath: string | undefined,
|
|
fileRepositoryName: string | undefined,
|
|
): string | undefined {
|
|
return useMemo(
|
|
() =>
|
|
mode === "file" && filePath
|
|
? reviewFileKey({ path: filePath, repository_name: fileRepositoryName })
|
|
: undefined,
|
|
[mode, filePath, fileRepositoryName],
|
|
);
|
|
}
|
|
|
|
/** Banner shown when the backend dropped files from a huge cumulative diff
|
|
* (large rebase) to keep the rendered row count bounded. */
|
|
export function TruncatedFilesBanner({ count }: { count: number }) {
|
|
if (count <= 0) return null;
|
|
return (
|
|
<div
|
|
data-testid="changes-truncated-banner"
|
|
className="flex items-center gap-2 px-4 py-2 text-xs text-yellow-600 bg-yellow-500/10 border-b border-yellow-500/20"
|
|
>
|
|
<IconAlertTriangle className="h-3.5 w-3.5 shrink-0" />
|
|
<span>
|
|
{count.toLocaleString()} more changed {count === 1 ? "file is" : "files are"} hidden — the
|
|
change set is too large to render in full.
|
|
</span>
|
|
</div>
|
|
);
|
|
}
|