Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import type { DiffStats } from "@features/git-interaction/utils/diffStats";
import { Flex, Text } from "@radix-ui/themes";
import { Text } from "@radix-ui/themes";
import { useReviewNavigationStore } from "@renderer/features/code-review/stores/reviewNavigationStore";
import { useTRPC } from "@renderer/trpc";
import { useQuery } from "@tanstack/react-query";

interface DiffStatsIndicatorProps {
repoPath: string | null | undefined;
overrideStats?: DiffStats | null;
taskId?: string;
}

export function DiffStatsIndicator({
repoPath,
overrideStats,
taskId,
}: DiffStatsIndicatorProps) {
const trpc = useTRPC();
const { data: localStats } = useQuery(
Expand All @@ -26,13 +29,28 @@ export function DiffStatsIndicator({
);

const diffStats = overrideStats ?? localStats;
const reviewMode = useReviewNavigationStore((s) =>
taskId ? (s.reviewModes[taskId] ?? "closed") : "closed",
);
const setReviewMode = useReviewNavigationStore((s) => s.setReviewMode);

if (!diffStats || diffStats.filesChanged === 0) {
return null;
}

const handleClick = () => {
if (taskId) {
setReviewMode(taskId, reviewMode !== "closed" ? "closed" : "split");
}
};

return (
<Flex align="center" gap="2" style={{ whiteSpace: "nowrap" }}>
<button
type="button"
onClick={handleClick}
className="inline-flex cursor-pointer items-center gap-2 border-none bg-transparent px-1.5 py-0.5"
style={{ whiteSpace: "nowrap" }}
>
<Text
size="1"
style={{
Expand Down Expand Up @@ -61,6 +79,6 @@ export function DiffStatsIndicator({
>
-{diffStats.linesRemoved}
</Text>
</Flex>
</button>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function ModeAndBranchRow({
<DiffStatsIndicator
repoPath={repoPath}
overrideStats={cloudDiffStats}
taskId={taskId}
/>
{showBranchSelector && showDiffStats && (
<Flex
Expand Down
Loading