Skip to content

Commit 80d59e0

Browse files
authored
Make diff stats indicator clickable to toggle review mode (#1560)
## TL;DR The diff stats indicator in the message editor is now clickable to toggle between split and closed review modes, providing a more intuitive way for users to control the code review interface. ## Problem Users need a quick way to toggle the code review mode without using alternative controls. Making the diff stats indicator interactive provides an obvious, discoverable control point. ## Changes - **DiffStatsIndicator component**: - Converted from a `Flex` container to a clickable `button` element with transparent background and pointer cursor - Added `taskId` prop to identify which review task to control - Integrated with `useReviewNavigationStore` to read and update review mode state - Added click handler that toggles review mode between "closed" and "split" states - Applied inline-flex styling to maintain visual layout while functioning as a button - **MessageEditor component**: - Passed `taskId` prop to `DiffStatsIndicator` component ## How did you test this? The changes maintain the visual appearance of the diff stats while converting it to a functional button element. The component will properly read the current review mode state and toggle it when clicked. --- *Created with [PostHog Code](https://posthog.com/code?ref=pr)*
1 parent 316d23e commit 80d59e0

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

apps/code/src/renderer/features/message-editor/components/DiffStatsIndicator.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import type { DiffStats } from "@features/git-interaction/utils/diffStats";
2-
import { Flex, Text } from "@radix-ui/themes";
2+
import { Text } from "@radix-ui/themes";
3+
import { useReviewNavigationStore } from "@renderer/features/code-review/stores/reviewNavigationStore";
34
import { useTRPC } from "@renderer/trpc";
45
import { useQuery } from "@tanstack/react-query";
56

67
interface DiffStatsIndicatorProps {
78
repoPath: string | null | undefined;
89
overrideStats?: DiffStats | null;
10+
taskId?: string;
911
}
1012

1113
export function DiffStatsIndicator({
1214
repoPath,
1315
overrideStats,
16+
taskId,
1417
}: DiffStatsIndicatorProps) {
1518
const trpc = useTRPC();
1619
const { data: localStats } = useQuery(
@@ -26,13 +29,28 @@ export function DiffStatsIndicator({
2629
);
2730

2831
const diffStats = overrideStats ?? localStats;
32+
const reviewMode = useReviewNavigationStore((s) =>
33+
taskId ? (s.reviewModes[taskId] ?? "closed") : "closed",
34+
);
35+
const setReviewMode = useReviewNavigationStore((s) => s.setReviewMode);
2936

3037
if (!diffStats || diffStats.filesChanged === 0) {
3138
return null;
3239
}
3340

41+
const handleClick = () => {
42+
if (taskId) {
43+
setReviewMode(taskId, reviewMode !== "closed" ? "closed" : "split");
44+
}
45+
};
46+
3447
return (
35-
<Flex align="center" gap="2" style={{ whiteSpace: "nowrap" }}>
48+
<button
49+
type="button"
50+
onClick={handleClick}
51+
className="inline-flex cursor-pointer items-center gap-2 border-none bg-transparent px-1.5 py-0.5"
52+
style={{ whiteSpace: "nowrap" }}
53+
>
3654
<Text
3755
size="1"
3856
style={{
@@ -61,6 +79,6 @@ export function DiffStatsIndicator({
6179
>
6280
-{diffStats.linesRemoved}
6381
</Text>
64-
</Flex>
82+
</button>
6583
);
6684
}

apps/code/src/renderer/features/message-editor/components/MessageEditor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ function ModeAndBranchRow({
104104
<DiffStatsIndicator
105105
repoPath={repoPath}
106106
overrideStats={cloudDiffStats}
107+
taskId={taskId}
107108
/>
108109
{showBranchSelector && showDiffStats && (
109110
<Flex

0 commit comments

Comments
 (0)