feat: git panel redesign (#535)

* feat(git-panel): add Branches tab, Fetch always visible, inline error banners

- Add dedicated Branches tab (local/remote sections, switch with confirmation, delete branch, create branch)
- Rename History tab to Commits; add change-count badge on Changes tab
- Fetch button always visible when remote exists (not only when both ahead & behind)
- Inline error banner below header for failed push/pull/fetch, with dismiss button
- Server: /api/git/branches now returns localBranches + remoteBranches separately
- Server: add /api/git/delete-branch endpoint (prevents deleting current branch)
- Controller: expose operationError, clearOperationError, deleteBranch, localBranches, remoteBranches
- Constants: add deleteBranch to all ConfirmActionType record maps

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: git log datetime

* feat(git-panel): add staged/unstaged sections and enhanced commit details

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Haile <118998054+blackmammoth@users.noreply.github.com>
This commit is contained in:
Simos Mikelatos
2026-03-13 15:38:53 +01:00
committed by GitHub
parent 1d31c3ec83
commit adb3a06d7e
13 changed files with 732 additions and 172 deletions

View File

@@ -1,7 +1,16 @@
import { ChevronDown, ChevronRight } from 'lucide-react';
import { useMemo } from 'react';
import type { GitCommitSummary } from '../../types/types';
import { getStatusBadgeClass, parseCommitFiles } from '../../utils/gitPanelUtils';
import GitDiffViewer from '../shared/GitDiffViewer';
function formatDate(dateString: string): string {
return new Date(dateString).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
});
}
type CommitHistoryItemProps = {
commit: GitCommitSummary;
@@ -20,6 +29,11 @@ export default function CommitHistoryItem({
wrapText,
onToggle,
}: CommitHistoryItemProps) {
const fileSummary = useMemo(() => {
if (!diff) return null;
return parseCommitFiles(diff);
}, [diff]);
return (
<div className="border-b border-border last:border-0">
<button
@@ -50,10 +64,83 @@ export default function CommitHistoryItem({
{isExpanded && diff && (
<div className="bg-muted/50">
<div className="max-h-96 overflow-y-auto p-2">
<div className="mb-2 font-mono text-sm text-muted-foreground">
{commit.stats}
<div className="max-h-[32rem] overflow-y-auto p-3">
{/* Full hash */}
<p className="mb-2 select-all font-mono text-xs text-muted-foreground/70">
{commit.hash}
</p>
{/* Author + Date */}
<div className="mb-3 flex gap-4 text-xs text-muted-foreground">
<span>
<span className="text-muted-foreground/60">Author </span>
{commit.author}
</span>
<span>
<span className="text-muted-foreground/60">Date </span>
{formatDate(commit.date)}
</span>
</div>
{/* Stats card */}
{fileSummary && (
<div className="mb-3 flex gap-4 rounded-md bg-muted/80 px-4 py-2 text-center text-xs">
<div>
<div className="text-muted-foreground/60">Files</div>
<div className="font-semibold text-foreground">{fileSummary.totalFiles}</div>
</div>
<div>
<div className="text-muted-foreground/60">Added</div>
<div className="font-semibold text-green-600 dark:text-green-400">+{fileSummary.totalInsertions}</div>
</div>
<div>
<div className="text-muted-foreground/60">Removed</div>
<div className="font-semibold text-red-600 dark:text-red-400">-{fileSummary.totalDeletions}</div>
</div>
</div>
)}
{/* Changed files list */}
{fileSummary && fileSummary.files.length > 0 && (
<div className="mb-3">
<p className="mb-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground/60">
Changed Files
</p>
<div className="rounded-md border border-border/60">
{fileSummary.files.map((file, idx) => (
<div
key={file.path}
className={`flex items-center gap-2 px-2.5 py-1.5 text-xs ${
idx < fileSummary.files.length - 1 ? 'border-b border-border/40' : ''
}`}
>
<span
className={`inline-flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border text-[9px] font-bold ${getStatusBadgeClass(file.status)}`}
>
{file.status}
</span>
<span className="min-w-0 flex-1 truncate">
{file.directory && (
<span className="text-muted-foreground/60">{file.directory}</span>
)}
<span className="font-medium text-foreground">{file.filename}</span>
</span>
<span className="flex-shrink-0 font-mono text-muted-foreground/60">
{file.insertions > 0 && (
<span className="text-green-600 dark:text-green-400">+{file.insertions}</span>
)}
{file.insertions > 0 && file.deletions > 0 && '/'}
{file.deletions > 0 && (
<span className="text-red-600 dark:text-red-400">-{file.deletions}</span>
)}
</span>
</div>
))}
</div>
</div>
)}
{/* Diff viewer */}
<GitDiffViewer diff={diff} isMobile={isMobile} wrapText={wrapText} />
</div>
</div>