From d7e4431e84bc2d0999b85e9a1111cac82337f52b Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sat, 16 May 2026 12:17:07 -0700 Subject: [PATCH] feat: surface commit details in history graph (#2094) --- .../components/editor/CombinedDiffViewer.tsx | 119 +++++++++++++----- .../right-sidebar/GitHistoryGraphSvg.tsx | 7 +- .../right-sidebar/GitHistoryPanel.tsx | 115 +++++++++++++---- .../right-sidebar/SourceControl.tsx | 3 +- src/renderer/src/store/slices/editor.ts | 21 +++- 5 files changed, 196 insertions(+), 69 deletions(-) diff --git a/src/renderer/src/components/editor/CombinedDiffViewer.tsx b/src/renderer/src/components/editor/CombinedDiffViewer.tsx index 2e48be0fc..cef5efde6 100644 --- a/src/renderer/src/components/editor/CombinedDiffViewer.tsx +++ b/src/renderer/src/components/editor/CombinedDiffViewer.tsx @@ -112,6 +112,18 @@ function getInitialCombinedDiffSideBySide(diffDefaultView: string | undefined): return combinedDiffSideBySidePreference ?? diffDefaultView === 'side-by-side' } +function commitMessageBody(message: string | undefined, subject: string | undefined): string { + const normalized = (message ?? '').replace(/\r\n/g, '\n').trim() + if (!normalized) { + return '' + } + const [firstLine = '', ...bodyLines] = normalized.split('\n') + if (subject && firstLine.trim() === subject.trim()) { + return bodyLines.join('\n').trim() + } + return normalized +} + export default function CombinedDiffViewer({ file, viewStateKey @@ -840,39 +852,76 @@ export default function CombinedDiffViewer({ } }, [clearDiffComments, diffCommentCount, file.worktreeId, isClearingNotes]) + const commitBody = commitMessageBody(commitCompare?.message, commitCompare?.subject) + const commitHeader = + isCommitMode && commitCompare ? ( +
+
+
+ {commitCompare.subject && ( + + +
+ {commitCompare.subject} +
+
+ + {commitCompare.subject} + +
+ )} + {commitBody && ( +
+ {commitBody} +
+ )} +
+ + {commitCompare.compareRef} + +
+
+ ) : null + if (sections.length === 0 && (file.skippedConflicts?.length ?? 0) > 0) { return ( -
-
-
- Conflicted files are reviewed separately -
-
- This diff view excludes unresolved conflicts because the normal two-way diff pipeline is - not conflict-safe. -
-
- {file.skippedConflicts!.map((entry) => entry.path).join(', ')} -
-
- +
+ {commitHeader} +
+
+
+ Conflicted files are reviewed separately +
+
+ This diff view excludes unresolved conflicts because the normal two-way diff pipeline + is not conflict-safe. +
+
+ {file.skippedConflicts!.map((entry) => entry.path).join(', ')} +
+
+ +
@@ -881,8 +930,11 @@ export default function CombinedDiffViewer({ if (sections.length === 0) { return ( -
- No changes to display +
+ {commitHeader} +
+ No changes to display +
) } @@ -1012,6 +1064,7 @@ export default function CombinedDiffViewer({
+ {commitHeader}
{skippedConflictNotice}
diff --git a/src/renderer/src/components/right-sidebar/GitHistoryGraphSvg.tsx b/src/renderer/src/components/right-sidebar/GitHistoryGraphSvg.tsx index b1e1b2937..6eea947b4 100644 --- a/src/renderer/src/components/right-sidebar/GitHistoryGraphSvg.tsx +++ b/src/renderer/src/components/right-sidebar/GitHistoryGraphSvg.tsx @@ -6,9 +6,10 @@ import { type GitHistoryItemViewModel } from '../../../../shared/git-history-graph' -const SWIMLANE_HEIGHT = 22 +const SWIMLANE_HEIGHT = 34 const SWIMLANE_WIDTH = 11 const SWIMLANE_CURVE_RADIUS = 5 +const SWIMLANE_NODE_Y = SWIMLANE_HEIGHT / 2 const CIRCLE_RADIUS = 3.5 const CIRCLE_STROKE_WIDTH = 1.5 @@ -66,7 +67,7 @@ export function GitHistoryGraphSvg({ color={color} d={[ `M ${SWIMLANE_WIDTH * (index + 1)} 0`, - `A ${SWIMLANE_WIDTH} ${SWIMLANE_WIDTH} 0 0 1 ${SWIMLANE_WIDTH * index} ${SWIMLANE_WIDTH}`, + `A ${SWIMLANE_WIDTH} ${SWIMLANE_WIDTH} 0 0 1 ${SWIMLANE_WIDTH * index} ${SWIMLANE_NODE_Y}`, `H ${SWIMLANE_WIDTH * (circleIndex + 1)}` ].join(' ')} /> @@ -153,7 +154,7 @@ export function GitHistoryGraphSvg({ } const cx = SWIMLANE_WIDTH * (circleIndex + 1) - const cy = SWIMLANE_WIDTH + const cy = SWIMLANE_NODE_Y const width = SWIMLANE_WIDTH * (Math.max(inputSwimlanes.length, outputSwimlanes.length, 1) + 1) const isBoundaryNode = viewModel.kind === 'incoming-changes' || viewModel.kind === 'outgoing-changes' diff --git a/src/renderer/src/components/right-sidebar/GitHistoryPanel.tsx b/src/renderer/src/components/right-sidebar/GitHistoryPanel.tsx index 5e9844cc8..98136a43c 100644 --- a/src/renderer/src/components/right-sidebar/GitHistoryPanel.tsx +++ b/src/renderer/src/components/right-sidebar/GitHistoryPanel.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react' -import { ChevronDown, RefreshCw } from 'lucide-react' +import { ChevronDown, CircleHelp, RefreshCw } from 'lucide-react' import { Button } from '@/components/ui/button' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' import { cn } from '@/lib/utils' @@ -30,17 +30,26 @@ function GitHistoryRefBadge({ }: { itemRef: NonNullable }): React.JSX.Element { + const refLabel = itemRef.category ? `${itemRef.name} (${itemRef.category})` : itemRef.name + return ( - - {itemRef.name} - + + + + {itemRef.name} + + + + {refLabel} + + ) } @@ -56,16 +65,20 @@ function GitHistoryRow({ const isBoundaryNode = viewModel.kind === 'incoming-changes' || viewModel.kind === 'outgoing-changes' const canOpenCommit = !isBoundaryNode && Boolean(onOpenCommit) + const refs = item.references ?? [] + const visibleRefs = refs.slice(0, 2) + const hiddenRefs = refs.slice(2) + const rowTooltip = item.message || item.subject return ( + + + + + + Refs are branch or tag names pointing at that exact commit. They only appear where Git + has a named ref for the commit. + +