Add git changes viewer with diff display

- Add backend git-operations service for git status and file diffs
- Add git/status and git/diff API routes to repos
- Add GitChangesPanel component to list changed files with status
- Add FileDiffView component with unified diff rendering
- Add GitChangesSheet as full-screen dialog wrapper
- Integrate View Changes option into BranchSwitcher dropdown
- Support both mobile (stacked) and desktop (split) layouts
This commit is contained in:
Chris Scott committed 2025-11-27 10:10:49 -05:00
1 parent 12b7ab54b2
commit ed82b99236
8 files changed
+815 -3

No files matched your search

@@ -7,10 +7,12 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { GitBranch, Check, Plus } from "lucide-react";
import { GitBranch, Check, Plus, GitCommit } from "lucide-react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { listBranches, switchBranch } from "@/api/repos";
import { useGitStatus } from "@/api/git";
import { AddBranchWorkspaceDialog } from "@/components/repo/AddBranchWorkspaceDialog";
import { GitChangesSheet } from "@/components/file-browser/GitChangesSheet";
interface BranchSwitcherProps {
repoId: number;
@@ -21,7 +23,9 @@ interface BranchSwitcherProps {
export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl }: BranchSwitcherProps) {
const [addBranchOpen, setAddBranchOpen] = useState(false);
const [gitChangesOpen, setGitChangesOpen] = useState(false);
const queryClient = useQueryClient();
const { data: gitStatus } = useGitStatus(repoId);
const { data: branches } = useQuery({
queryKey: ["branches", repoId],
@@ -75,6 +79,21 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl }: B
Loading branches...
</DropdownMenuItem>
)}
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => setGitChangesOpen(true)}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
>
<div className="flex items-center gap-2 w-full">
<GitCommit className="w-3 h-3" />
<span className="flex-1">View Changes</span>
{gitStatus?.hasChanges && (
<span className="text-xs text-yellow-500">
{gitStatus.files.length}
</span>
)}
</div>
</DropdownMenuItem>
{!isWorktree && (
<>
<DropdownMenuSeparator />
@@ -97,6 +116,13 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl }: B
onOpenChange={setAddBranchOpen}
repoUrl={repoUrl}
/>
<GitChangesSheet
isOpen={gitChangesOpen}
onClose={() => setGitChangesOpen(false)}
repoId={repoId}
currentBranch={currentBranch}
/>
</>
);
}