refactor: make diff mode toggle interactive and improve status display

This commit is contained in:
Mohamed Boudra
2026-02-03 10:03:50 +07:00
parent 1ea071adb6
commit 0804f51b03
+49 -30
View File
@@ -16,7 +16,7 @@ import { ScrollView, type ScrollView as ScrollViewType } from "react-native-gest
import { StyleSheet, useUnistyles } from "react-native-unistyles"; import { StyleSheet, useUnistyles } from "react-native-unistyles";
import AsyncStorage from "@react-native-async-storage/async-storage"; import AsyncStorage from "@react-native-async-storage/async-storage";
import * as Linking from "expo-linking"; import * as Linking from "expo-linking";
import { ChevronDown, ChevronRight, GitBranch, MoreVertical } from "lucide-react-native"; import { ChevronDown, ChevronRight, GitBranch, MoreVertical, ArrowLeftRight } from "lucide-react-native";
import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useSessionStore } from "@/stores/session-store"; import { useSessionStore } from "@/stores/session-store";
import { import {
@@ -1107,28 +1107,19 @@ export function GitDiffPane({ serverId, agentId, cwd }: GitDiffPaneProps) {
<MoreVertical size={16} color={theme.colors.foregroundMuted} /> <MoreVertical size={16} color={theme.colors.foregroundMuted} />
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent align="end" width={220} testID="changes-overflow-content"> <DropdownMenuContent align="end" width={220} testID="changes-overflow-content">
<DropdownMenuItem
testID="changes-menu-toggle-view"
onSelect={() => setDiffModeOverride(diffMode === "uncommitted" ? "base" : "uncommitted")}
>
{diffMode === "uncommitted" ? `Show changes vs ${baseRefLabel}` : "Show uncommitted changes"}
</DropdownMenuItem>
{gitStatus?.isPaseoOwnedWorktree ? ( {gitStatus?.isPaseoOwnedWorktree ? (
<> <DropdownMenuItem
<DropdownMenuSeparator /> testID="changes-menu-archive"
<DropdownMenuItem destructive
testID="changes-menu-archive" disabled={archiveDisabled}
destructive status={archiveAction.status}
disabled={archiveDisabled} pendingLabel="Archiving..."
status={archiveAction.status} successLabel="Archived"
pendingLabel="Archiving..." closeOnSelect={false}
successLabel="Archived" onSelect={archiveAction.trigger}
closeOnSelect={false} >
onSelect={archiveAction.trigger} Archive worktree
> </DropdownMenuItem>
Archive worktree
</DropdownMenuItem>
</>
) : null} ) : null}
</DropdownMenuContent> </DropdownMenuContent>
</DropdownMenu> </DropdownMenu>
@@ -1137,10 +1128,26 @@ export function GitDiffPane({ serverId, agentId, cwd }: GitDiffPaneProps) {
</View> </View>
{isGit && hasChanges ? ( {isGit && hasChanges ? (
<View style={styles.diffStatusRow} testID="changes-diff-status"> <View style={styles.diffStatusContainer}>
<Text style={styles.diffStatusText}> <Pressable
{diffMode === "uncommitted" ? "Uncommitted changes" : `Changes vs ${baseRefLabel}`} style={({ hovered }) => [
</Text> styles.diffStatusRow,
hovered && styles.diffStatusRowHovered,
]}
testID="changes-diff-status"
onPress={() => setDiffModeOverride(diffMode === "uncommitted" ? "base" : "uncommitted")}
>
{({ hovered }) => (
<>
<Text style={styles.diffStatusText}>
{diffMode === "uncommitted" ? "Uncommitted" : "Committed"}
</Text>
{hovered ? (
<ArrowLeftRight size={12} color={theme.colors.foregroundMuted} />
) : null}
</>
)}
</Pressable>
</View> </View>
) : null} ) : null}
@@ -1188,12 +1195,24 @@ const styles = StyleSheet.create((theme) => ({
fontWeight: theme.fontWeight.medium, fontWeight: theme.fontWeight.medium,
flexShrink: 1, flexShrink: 1,
}, },
diffStatusRow: { diffStatusContainer: {
paddingHorizontal: theme.spacing[3],
paddingVertical: theme.spacing[2],
borderBottomWidth: 1, borderBottomWidth: 1,
borderBottomColor: theme.colors.border, borderBottomColor: theme.colors.border,
}, },
diffStatusRow: {
flexDirection: "row",
alignItems: "center",
alignSelf: "flex-start",
gap: theme.spacing[1],
marginHorizontal: theme.spacing[3],
marginVertical: theme.spacing[2],
paddingHorizontal: theme.spacing[2],
paddingVertical: theme.spacing[1],
borderRadius: theme.borderRadius.base,
},
diffStatusRowHovered: {
backgroundColor: theme.colors.surface2,
},
diffStatusText: { diffStatusText: {
fontSize: theme.fontSize.xs, fontSize: theme.fontSize.xs,
color: theme.colors.foregroundMuted, color: theme.colors.foregroundMuted,
@@ -1387,7 +1406,7 @@ const styles = StyleSheet.create((theme) => ({
flex: 1, flex: 1,
}, },
fileName: { fileName: {
fontWeight: theme.fontWeight.semibold, color: theme.colors.foreground,
}, },
fileDir: { fileDir: {
color: theme.colors.foregroundMuted, color: theme.colors.foregroundMuted,